3 Callback wrapping utility
8 var wrappy = require("wrappy")
10 // var wrapper = wrappy(wrapperFunction)
12 // make sure a cb is called only once
13 // See also: http://npm.im/once for this specific use case
14 var once = wrappy(function (cb) {
19 return cb.apply(this, arguments)
23 function printBoo () {
26 // has some rando property
27 printBoo.iAmBooPrinter = true
29 var onlyPrintOnce = once(printBoo)
31 onlyPrintOnce() // prints 'boo'
32 onlyPrintOnce() // does nothing
34 // random property is retained!
35 assert.equal(onlyPrintOnce.iAmBooPrinter, true)