3 Object.defineProperty(exports, "__esModule", {
6 exports.default = series;
8 var _parallel = require('./internal/parallel');
10 var _parallel2 = _interopRequireDefault(_parallel);
12 var _eachOfSeries = require('./eachOfSeries');
14 var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
16 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19 * Run the functions in the `tasks` collection in series, each one running once
20 * the previous function has completed. If any functions in the series pass an
21 * error to its callback, no more functions are run, and `callback` is
22 * immediately called with the value of the error. Otherwise, `callback`
23 * receives an array of results when `tasks` have completed.
25 * It is also possible to use an object instead of an array. Each property will
26 * be run as a function, and the results will be passed to the final `callback`
27 * as an object instead of an array. This can be a more readable way of handling
28 * results from {@link async.series}.
30 * **Note** that while many implementations preserve the order of object
31 * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
32 * explicitly states that
34 * > The mechanics and order of enumerating the properties is not specified.
36 * So if you rely on the order in which your series of functions are executed,
37 * and want this to work on all platforms, consider using an array.
41 * @memberOf module:ControlFlow
43 * @category Control Flow
44 * @param {Array|Iterable|Object} tasks - A collection containing functions to run, each
45 * function is passed a `callback(err, result)` it must call on completion with
46 * an error `err` (which can be `null`) and an optional `result` value.
47 * @param {Function} [callback] - An optional callback to run once all the
48 * functions have completed. This function gets a results array (or object)
49 * containing all the result arguments passed to the `task` callbacks. Invoked
53 * function(callback) {
54 * // do some stuff ...
55 * callback(null, 'one');
57 * function(callback) {
58 * // do some more stuff ...
59 * callback(null, 'two');
62 * // optional callback
63 * function(err, results) {
64 * // results is now equal to ['one', 'two']
68 * one: function(callback) {
69 * setTimeout(function() {
73 * two: function(callback){
74 * setTimeout(function() {
78 * }, function(err, results) {
79 * // results is now equal to: {one: 1, two: 2}
82 function series(tasks, callback) {
83 (0, _parallel2.default)(_eachOfSeries2.default, tasks, callback);
85 module.exports = exports['default'];