stupid-singleton

1.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i stupid-singleton

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • adalberth