1t
Ensures that only one instance of your module exists either serverside or in the browser.
Last updated 7 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install 1t 
SYNC missed versions from official npm registry.

1t build status

Ensures that only one instance of your module exists either serverside or in the browser.

1t == one ton == a singleton

var singleton = require('1t');

// #ifndef
singleton('__FOO__', module, function () {
// #define __FOO__

var path = require('path');

exports.hello = 'world';  
exports.filename = path.basename(__filename);

})
// #endif

Installation

npm install 1t

API

singleton(id, mdl, fn)

Ensures that only one instance for the wrapped module is instantiated. Works similar to #ifndef/#define pragmas in C

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

Current Tags

  • 0.1.0                                ...           latest (7 years ago)

1 Versions

  • 0.1.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 5
Dependencies (0)
None
Dev Dependencies (1)

Copyright 2014 - 2017 © taobao.org |