Skip to content

chain promise function with different arguments sequentially

Notifications You must be signed in to change notification settings

AliKarami/promisefall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

node-promisefall

Chains an promise with array of arguments that return result in type of array of promises

Installation

$ npm install promisefall

Usage

promiseFall(promiseFunction,arrayOfArguments);
  • promiseFunction - A function that you want arguments to iterate on that in sequential order. NOTE: supports any promise library that has promises with a then function
  • arrayOfArguments - An array which contains arrays of arguments just like: [[arg11,arg12,arg13],[arg21,arg22,arg23]]

Example

var promiseFall = require("promisefall");

var promiseFunc = function(arg1,arg2,arg3){
    return Promise.resolve(arg1+arg2+arg3);
};
var argsArray = [];

for(var i = 0; i < 5; i++) {
    argsArray.push([1,2,3]);
}

promiseFall(promiseFunc, argsArray).then(function(result) {
    console.log(result);
});

// OUTPUT:
// [6,6,6,6,6]

About

chain promise function with different arguments sequentially

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published