promise-one-at-a-time

Run a series of functions that return promises, one at a time

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
promise-one-at-a-time
001.0.18 years ago8 years agoMinified + gzip package size for promise-one-at-a-time in KB

Readme

Build Status npm version
promise-one-at-a-time
Run promise-creating functions one at a time.

Install

npm install promise-one-at-a-time --save

Use

Pass in an array of functions that return promises. They will be ran one at a time and the last value will be returned.
var oneAtATime = require("promise-one-at-a-time");

var fns = [
  function(){
    return new Promise(function(resolve){
      resolve();
    });
  },
  function(){
    return new Promise(function(resolve){
      resolve("works");
    });
  }
];

oneAtATime(fns).then(function(val){
  // val === "works"
});

License

BSD 2 Clause