bound-compose

1.0.1 • Public • Published

bound-compose

Build Status Dependency Status Devdependency Status npm version License

Create a bound composed function. using the redux#compose .

npm i bound-compose

Usage

// For example,
// `boundCompose(f, g, h)(b)(...args)` is identical to doing
// `(b, ...args) => f(g(h(b, ...args), ...args), ...args)` .
 
let result;
result = doSomething1(result, ...args)
result = doSomething2(result, ...args)
result = doSomething3(result, ...args)
 
// ↓
 
result = doSomething3(doSomething2(doSomething1(result, ...args), ...args), ...args)
 
// ↓
 
const result = boundCompose(doSomething3, doSomething2, doSomething1)(arg)(...args)
 
// or
 
const result = boundCompose.left(doSomething1, doSomething2, doSomething3)(arg)(...args)

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

© sugarshin

Package Sidebar

Install

npm i bound-compose

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • sugarshin