Module singletons
Raul-Sebastian Mihăilă
raul.mihaila at gmail.com
Thu Feb 9 14:57:20 UTC 2017
On Thu, Feb 9, 2017 at 4:41 PM, Romuald Quantin <romu at soundstep.com> wrote:
> Usually solved this way:
>
> - export something to instantiate (a function or a class)
>
> ```
> module.exports = MyClass;
> ```
> - export an object (will be shared, only one instance)
>
> ```
> module.exports = {};
> ```
> - export a new instance every time
>
> ```
> module.exports = new MyClass();
> ```
>
My question was about some spec details wrt standard ES modules, not about
nodejs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170209/3728260a/attachment.html>
More information about the es-discuss
mailing list