Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage in the readme could be more explicit #33

Closed
blaise-io opened this issue Jul 2, 2015 · 4 comments
Closed

Usage in the readme could be more explicit #33

blaise-io opened this issue Jul 2, 2015 · 4 comments

Comments

@blaise-io
Copy link
Contributor

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
Copy link
Collaborator

ljharb commented Jul 2, 2015

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
Copy link
Contributor Author

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
Copy link
Collaborator

ljharb commented Jul 2, 2015

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
Copy link
Contributor Author

Thanks, that's good to know.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants