3 [![build status][build-png]][build] [![Coverage Status][cover-png]][cover] [![Davis Dependency status][dep-png]][dep]
7 [![browser support][test-png]][test]
9 Garantueed individual values
14 var Individual = require("individual")
16 var moduleCache = Individual("__MY_MODULE_CACHE", {})
18 // moduleCache is a individual variable local to this file.
19 // It will always be the same value and defaults to {}.
22 This gives you a singleton value by a unique name (it stores it
23 as a global variable).
27 Your module has an internal cache. If your module is loaded
28 twice, (someone didn't npm dedup and has two copies of your
29 module) you would have two seperate caches that dont talk
32 Best case your cache is less efficient. Worst case you have a
33 cache because the native C++ extension you talk to crashes
34 if you instantiate something twice.
36 You need a garantuee that this value is an individual, there is
39 I use it myself because opening a SockJS websocket to the same
40 URI twice causes an infinite loop. I need a garantuee that
41 I have an individual value for the SockJS connection so I
42 can see whether I already have an open connection.
46 I can't imagine any other way to do it. I hate it too. Make a
47 pull request if you know the real solution
51 `npm install individual`
59 [build-png]: https://secure.travis-ci.org/Raynos/individual.png
60 [build]: https://travis-ci.org/Raynos/individual
61 [cover-png]: https://coveralls.io/repos/Raynos/individual/badge.png
62 [cover]: https://coveralls.io/r/Raynos/individual
63 [dep-png]: https://david-dm.org/Raynos/individual.png
64 [dep]: https://david-dm.org/Raynos/individual
65 [test-png]: https://ci.testling.com/Raynos/individual.png
66 [test]: https://ci.testling.com/Raynos/individual
67 [npm-png]: https://nodei.co/npm/individual.png?stars&downloads
68 [npm]: https://nodei.co/npm/individual