diff options
Diffstat (limited to 'lib/eachOf.js')
| -rw-r--r-- | lib/eachOf.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/eachOf.js b/lib/eachOf.js index 070204b..f3bda13 100644 --- a/lib/eachOf.js +++ b/lib/eachOf.js @@ -6,6 +6,7 @@ import noop from './internal/noop'; import once from './internal/once'; import onlyOnce from './internal/onlyOnce'; import wrapAsync from './internal/wrapAsync'; +import awaitify from './internal/awaitify' // eachOf implementation optimized for array-likes function eachOfArrayLike(coll, iteratee, callback) { @@ -56,6 +57,7 @@ var eachOfGeneric = doLimit(eachOfLimit, Infinity); * Invoked with (item, key, callback). * @param {Function} [callback] - A callback which is called when all * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted * @example * * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; @@ -77,7 +79,7 @@ var eachOfGeneric = doLimit(eachOfLimit, Infinity); * doSomethingWith(configs); * }); */ -export default function(coll, iteratee, callback) { +export default awaitify((coll, iteratee, callback) => { var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; eachOfImplementation(coll, wrapAsync(iteratee), callback); -} +}, 3) |
