justmoon / node-extend

Simple function to extend objects
MIT License
341 stars 68 forks source link

Usage in the readme could be more explicit #33

Closed blaise-io closed 9 years ago

blaise-io commented 9 years ago

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?

ljharb commented 9 years ago

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?

blaise-io commented 9 years ago

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.

ljharb commented 9 years ago

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.

blaise-io commented 9 years ago

Thanks, that's good to know.

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