1.0.0 • Published 8 years ago

delegate-normalizer v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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);

  // Do something usefull and then...

  cb.forEach(f => { cb(); });
}

Installation

$ npm install delegate-normalizer --save