cbd
1.0.0 • Public • Published cbd
For functions with optional callbacks.
Callback default. Return a noop function for when no callback function has been passed.
Usage
Instead of
function foo (arg1, cb) {
if (cb) {
cb()
}
}
You do
var cbd = require("cbd")
function foo (arg1, cb) {
cbd(cb)()
}
Set default cb
var cbd = require("cbd")
cbd.setDefault(function (er, res) {
if (er) return console.error(er)
console.log(res)
})
Pass default cb
var cbd = require("cbd")
function foo (arg1, cb) {
cbd(cb, function () { console.log("foo callback", arguments) })()
}
Readme
Keywords
nonePackage Sidebar
Install
Weekly Downloads