Singleton.js

This function will transform any given function into singleton pattern

License

MIT-style license.

Author

Takashi Mizohata bea.nosp@m.tak@nydd.nosp@m..org

Copyright

2008 [nydd](http://code.nydd.org/).

Summary
Singleton.jsThis function will transform any given function into singleton pattern
Functions
SingletonThis function will transform any given function into singleton pattern

Functions

Singleton

var Singleton = function (str)

This function will transform any given function into singleton pattern

Arguments

str(String) Very important!  You have to pass a name of the object by string

Return

(Object)

Examples

var Foo = function () {...}
Foo.prototype.bar = function () {...}
Foo = Singleton('Foo');
var a = Foo.getInstance(); // ok!
var b = new Foo() // -> raise an error
var Singleton = function (str)
This function will transform any given function into singleton pattern
Close