Skip to content

mohamedhayibor/callback-chainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

callback-chainer

This module returns the result from callbacks in a specific order (array of functions), one feeding the next.

Installation

  > npm install callback-chainer

Usage

Params: [array of functions with desired order] and arg

callbackChainer([fn1, fn2, fn3, ...])(arg)

import callbackChainer from 'callback-chainer' // or  const callbackChainer = require('callback-chainer')

const add = function (i) { return i + 2; };
const mul = function (i) { return 2 * i; };
const sub = function (i) { return i - 5; };

callbackChainer([add, mul, sub])(8) // ==> 15

Raison d'être

Functions are super cool in JS but in the end what matters is how you call them within your logic. In the case you need a number of functions to be called in a specific order this module might be a help.

Super Light (7 sloc). No dependencies.

License

© Mohamed Hayibor

About

This module returns the result from callbacks in a specific order (array of functions), one feeding the next.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published