Sha256: 0d2537e86a9e5ae85d8e53910d779895179035c9daa35555874ec19f1225c224
Contents?: true
Size: 685 Bytes
Versions: 1036
Compression:
Stored size: 685 Bytes
Contents
# wrappy Callback wrapping utility ## USAGE ```javascript var wrappy = require("wrappy") // var wrapper = wrappy(wrapperFunction) // make sure a cb is called only once // See also: http://npm.im/once for this specific use case var once = wrappy(function (cb) { var called = false return function () { if (called) return called = true return cb.apply(this, arguments) } }) function printBoo () { console.log('boo') } // has some rando property printBoo.iAmBooPrinter = true var onlyPrintOnce = once(printBoo) onlyPrintOnce() // prints 'boo' onlyPrintOnce() // does nothing // random property is retained! assert.equal(onlyPrintOnce.iAmBooPrinter, true) ```
Version data entries
1,036 entries across 414 versions & 47 rubygems