https://github.com/netbeast/challenge-mqtt
:checkered_flag: Developer challenge
https://github.com/netbeast/challenge-mqtt
Last synced: 10 months ago
JSON representation
:checkered_flag: Developer challenge
- Host: GitHub
- URL: https://github.com/netbeast/challenge-mqtt
- Owner: netbeast
- Created: 2016-01-07T16:03:41.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-22T16:17:43.000Z (over 10 years ago)
- Last Synced: 2025-01-22T13:46:27.111Z (over 1 year ago)
- Language: HTML
- Homepage: http://netbeast.co
- Size: 6.55 MB
- Stars: 5
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
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)
```