get-single
Singleton Pattern the JavaScript way
Install
$ npm install --save get-single
Usage
const getSingle = require('get-single')
function fn(name) {
return {name: name}
}
const singleFn = getSingle(fn)
let obj1 = singleFn('obj1')
let obj2 = singleFn('obj2')
let obj3 = singleFn('obj3')
console.log(obj1 === obj2) // true
console.log(obj2 === obj3) // true
API
getSingle(fn)
fn
Type: function
License
MIT © JIANG Di