blob: 0ef6914da47a9cb2611f8072cd36030ee304dbbf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
'use strict';
import isArray from 'lodash/isArray';
import each from 'lodash/each';
import noop from 'lodash/noop';
import once from 'lodash/once';
export default function race(tasks, cb) {
cb = once(cb || noop);
if (!isArray(tasks)) return cb(new TypeError('First argument to race must be an array of functions'));
if (!tasks.length) return cb();
each(tasks, function (task) {
task(cb);
});
}
|