3 ms·
Maybe I'm a dumb idiot but I'm definitely guilty of using this so-called anti-pattern, and I don't really see the big deal. In a lot of places I define module.
by rubbingalcohol 9y ago
Maybe I'm a dumb idiot but I'm definitely guilty of using this so-called anti-pattern, and I don't really see the big deal.
In a lot of places I define module.exports as a function that takes some inputs, eg. db params, and returns a promise that results in an object containing the methods I wish to expose externally, _after_ any initialization, eg. connecting to the db.
That's a convenient way to guarantee a module is ready to use to the bigger app. Naming each export as a constant would break this.
So what's the benefit? You want to use some fancy IDE with Auto complete? Well la-di-da some of us old farts are still on text editors. So unless I'm missing something I don't see why I should change my habits to cater to someone else's convenience.
If someone can provide a better case against default exports, I'm all ears.