Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Singleton design pattern implementation which easy to use
JavaScript
branch: master
Failed to load latest commit information.
example
tests Reformat code and fix typos.
.gitignore Add ignore files for git and npm.
.jscs.json Reformat code and fix typos.
.jshintrc
.npmignore Add ignore files for git and npm.
.travis.yml
LICENCE Initial commit
PragmaSingleton.js Reformat code and fix typos.
README.md Merge branch 'release/1.0.2'
package.json Update contributers.

README.md

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

Something went wrong with that request. Please try again.