delegate-normalizer
Normalizes the value of a function parameter that expects to be passed a callback function or an array of callback functions.
delegate-normalizer always returns an array of functions. If the parameter is undefined
or contains no functions, an array with the only function () {}
function is returned. This allows for invoking callbacks without any extra check:
const delegateNormalizer = require('delegate-normalizer');
function (cb) {
cb = delegateNormalizer(cb);
cb.forEach(f => { cb(); });
}
Installation
$ npm install delegate-normalizer --save