
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
Powerful and easy to use JavaScript implementation of the Singleton design pattern. It creates singleton instance which nobody can to change or replace. Now it supports Node.js (CommonJS modules) only, but frontend support needed (AMD, etc.). Help wanted.
npm i --save singletone
var singletone = require('singletone');
function Player() {
// save the instance local variable for the moment
var singletonInstance = singletone(this);
// rewrite our singleton constructor
Player = singletonInstance.constructor;
// add some instance properties
this.status = "stopped";
// return singleton instance
return singletonInstance;
}
Player.prototype.play = function () {
this.status = "playing";
};
Player.prototype.stop = function () {
this.status = "stopped";
};
var player = new Player();
player.play();
console.log(player.status);
// "playing"
var player2 = Player();
console.log(player2.status);
// "playing"
For more information and examples look at the tests.
If you want to send some PR, checkout develop branch please. It contains the latest commits.
FAQs
Powerful JavaScript singleton design pattern implementation
We found that singletone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.