https://github.com/kshirish/i-will-todo-you
Todo apps for frameworks/libraries
https://github.com/kshirish/i-will-todo-you
Last synced: 12 months ago
JSON representation
Todo apps for frameworks/libraries
- Host: GitHub
- URL: https://github.com/kshirish/i-will-todo-you
- Owner: kshirish
- Created: 2015-07-06T13:10:55.000Z (about 11 years ago)
- Default Branch: gh-pages
- Last Pushed: 2015-07-25T02:46:41.000Z (almost 11 years ago)
- Last Synced: 2024-03-15T22:03:38.500Z (over 2 years ago)
- Language: JavaScript
- Size: 2.91 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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)
```