delegate-normalizer

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i delegate-normalizer

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • agorokhov