1t ![build status](https://secure.travis-ci.org/thlorenz/1t.png)
Ensures that only one instance of your module exists either serverside or in the browser.
1t == one ton == a singleton
var singleton = require('1t');
singleton('__FOO__', module, function () {
var path = require('path');
exports.hello = 'world';
exports.filename = path.basename(__filename);
})
Installation
npm install 1t
API
-
singleton(id, mdl, fn)
-
Parameters:
Name | Type | Description |
---|
id |
string
| the unique id under which the module is stored in the global namespace |
mdl |
Object
| the module variable that is passed to each node/browserify module |
fn |
function
| function that wraps the code of the module |
- Source:
generated with docme
License
MIT