pragma-singleton

Singleton design pattern implementation which easy to use

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
Last updated 11 years ago by pragma-dudes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install pragma-singleton 
SYNC missed versions from official npm registry.

#Pragma Singleton Build Status NPM version

Singleton design pattern implementation which easy to use.

Just apply this to any constructor function and all 'new' operators for this constructor will return the same instance.

##Usage To install just use NPM

npm install pragma-singleton
var singleton = require('pragma-singleton');

function Constructor(someValue) {
	this.someValue = someValue;
}

var SingletonConstructor = singleton(Constructor),
	instance1 = new SingletonConstructor('value1'),
	instance2 = new SingletonConstructor('value2');

console.log(instance1 == instance2); // true, because the same instance
console.log(instance2.someValue); // value1, because the value of first created instance

Pragma Dudes wish you live long and prosper.

info@pragma-dudes.org

Current Tags

  • 1.0.3                                ...           latest (11 years ago)

1 Versions

  • 1.0.3 [deprecated]           ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |