pseries
pseries is a JavaScript micro-library for easily executing asynchronous functions in series. You pass in an array of promise-returning functions and it executes them in series then returns a promise.
Installation
npm install pseries
(if using version 1.x.x, requires --harmony_generators
flag to be set)
Benefits
- Execute a list of functions in order
- Execute one after the other
- One final response outlet (an array of responses)
- One single outlet for handling errors
- Completely asynchronous and non-blocking
Example using ES2015
var myFuncs = // an example array of promise-returning functions //run this function first { ; } //then run this function... { ; } ; // pass that array into pseries and let it do the work ;
Examples
var myFuncs = // an example array of promise-returning functions { //run this function first return { ; }; } { //then run this function... return { ; }; } ; // pass that array into pseries and let it do the work ;
or
;
You can also nest pseries calls.
;
This is much cleaner than the following, traditional way of handling asynchronous functions.
// Don't do this!!! var { ;};
License
Apache License Version 2.0
Copyright (c) 2016 by Ryan Burgett.