On Thu, Jul 4, 2013 at 5:05 PM, Axel Rauschmayer <[email protected]> wrote:

> In Node.js, the difference is:
>
>     module.exports = function () { … };
>
> versus
>
>     module.exports = {
>         foo: …,
>         bar: …,
>         baz: …
>     };
>
> So, conceptually, the former piece of code exports a single value, while
> the latter exports multiple values.
>
>
I would say (in my purely anecdotal experience) that "most" of the
well-written and idiomatic node modules that I have used use the former
technique. In a lot of cases, the exported function is a "basic, 95% of use
cases" functionality, and then the module exposes a richer, more advanced
API by adding attributes to the function object.

Here are a couple examples:
https://github.com/isaacs/minimatch
https://github.com/substack/dnode
https://github.com/mikeal/request

-- Sean Silva
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to