Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 1.03 KB

README.md

File metadata and controls

34 lines (24 loc) · 1.03 KB

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;
});