promise.compose2

1.0.0 • Public • Published

promise.compose2


NPM version Build Status

compose an array of promises ,return a function that chain resolve promise with an initialization parameter

Install

$ npm install promise.compose2

Usage

var compose = require('promise.compose2')
 
function makeAdder (a) {
  return function (b) {
    b = b || 0
    return Promise.resolve(+ b)
  }
}
 
var addOne = makeAdder(1)
 
let composeFn=compose([
                addOne,  // 1
                addOne, // 2
                addOne  // 3
              ]);
composeFn(10)
.then(console.log)
.catch(console.error)

API

compose(functions) -> function(ctx) ->`promise

like koa-compose Runs the array of functions in series, waiting for each to resolve and passing each result to the next function in the array.

functions

Required Type: array[function]

Package Sidebar

Install

npm i promise.compose2

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.48 kB

Total Files

4

Last publish

Collaborators

  • x373241884y