4 ms·
> The module pattern is pretty well known and you can use it to return a singleton. How would you even make it _not_ return a singleton? I thought that was def
by Kiro 9y ago
> The module pattern is pretty well known and you can use it to return a singleton.
How would you even make it _not_ return a singleton? I thought that was default.
- svckr 9y agoOne way is to delete entries from `require.cache`. Either way you might get a separate instance if npm decided that your module and another module require different version of a given module. These would both be singletons though. Just singletons of instances of different versions of the same module.
- BinaryIdiot 9y agoIt is, I only meant that's a way it can be handled not that it wasn't common or anything.