Skip to content

chandu1310/promise-welder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

promise-welder

Build Status npm latest version Maintainability Test Coverage

Installation

Run the following command to install as a dependency in your project.

npm install promise-welder

Usage

PromiseChain: This handy utility lets you chain functions which have inter dependency and return Promise which drives the next function in the chain. An initial state is provided as part of the call. Usage Example:

const { PromiseChain } = require('promise-welder');

const A = ({ x }) => Promise.resolve({ y: x*x });
const B = ({ y }) => Promise.resolve({ z: y*2 });
const C = ({ z }) => Promise.resolve(z*10);

PromiseChain( [A, B, C], {x:2} ).then(console.log);

Output: 80

Credits

Chandra Shekar Chennamsetty

This project was bootstrapped using Nodeneeds utility.