justmoon/node-extend

Usage in the readme could be more explicit

Closed this issue · 4 comments

I assumed I could do var extend = require('extend'); to get the extend function, but I had to look at the source code to confirm this was correct. Maybe be explicit about this by adding the require part to the readme?

That's how the vast majority of npm modules work, so while we could certainly add it, I'm not sure it's necessary. Have you found many modules where this isn't the case, and they don't document the divergence explicitly?

I don't know what the standard practice is, as most npm modules I have worked with so far return an object because they expose multiple functions. Although my expectation matched the implementation, I had to check, so being explicit about it is probably a good idea as there are more inexperienced node users out there that you can save some time.

I'd be open to a PR for it - improving docs readability is always a good thing.

The overwhelmingly standard practice is for modules to have a single default export that's a function, and if extra properties are required, stick them on there. Modules that are grab bags of properties on an object tightly couple the requiring code to the implementation, and are discouraged.

Thanks, that's good to know.

I'll close this issue and open a pull request in a few minutes.