1.0.0 • Published 8 years ago

stupid-singleton v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Stupid Singleton

Simple singleton creater for js (browserify).

Usage

Creating a singleton:

var Singleton = require('stupid-singleton');

function moduleConstructor(opts){
	var self = {};
	var opts = opts || {};
	self.name = "I am module";
	return self;
}
var Module = Singleton(moduleConstructor); 
var mod1 = Module.getInstance(); // returns an instance of moduleConstructor
var mod2 = Module.getInstance(); // return the same instance
console.log(mod1 === mod2); // true