1.0.0 • Published 7 years ago

single-space v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

single-space

A module which provides a simple way for ensuring singleton in node.

npm version Build Status Coverage Status

Code copied and modified gently from

https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/

Thanks to this developer.

Ussage

const SingleSpace = require('single-space');

module.exports = SingleSpace('module.my.namespace.example', () => {
    function Example(options) {
        if (!(this instanceof Example)) {
            return new Example(options);
        }

        this.options = options;
    }

    Example.prototype.echo = function echo(sound) {
        return sound;
    }

    return Example;
});