diff options
Diffstat (limited to 'build-es/waterfall.js')
-rw-r--r-- | build-es/waterfall.js | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/build-es/waterfall.js b/build-es/waterfall.js deleted file mode 100644 index c629bcf..0000000 --- a/build-es/waterfall.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -import isArray from 'lodash-es/isArray'; -import noop from 'lodash-es/noop'; -import once from 'lodash-es/once'; -import rest from 'lodash-es/rest'; - -import ensureAsync from './ensureAsync'; -import iterator from './iterator'; - -export default function(tasks, cb) { - cb = once(cb || noop); - if (!isArray(tasks)) return cb(new Error('First argument to waterfall must be an array of functions')); - if (!tasks.length) return cb(); - - function wrapIterator(iterator) { - return rest(function(err, args) { - if (err) { - cb.apply(null, [err].concat(args)); - } else { - var next = iterator.next(); - if (next) { - args.push(wrapIterator(next)); - } else { - args.push(cb); - } - ensureAsync(iterator).apply(null, args); - } - }); - } - wrapIterator(iterator(tasks))(); -} |