UNPKG

@mightyplow/jslib

Version:

js helpers library

20 lines (17 loc) 662 B
/** returns a function which executes promises one after another @memberOf function @param promiseGenerators an array of functions which return a promise @return function which executes the promises */ var enqueue = function enqueue(promiseGenerators) { return function () { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return promiseGenerators.reduce(function (f, promiseGenerator) { return f instanceof Promise ? f.then(promiseGenerator) : promiseGenerator.apply(undefined, args); }); }; }; export default enqueue;