summaryrefslogtreecommitdiff
path: root/lib/each.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/each.js')
-rw-r--r--lib/each.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/each.js b/lib/each.js
index dc856ac..7f6e689 100644
--- a/lib/each.js
+++ b/lib/each.js
@@ -1,6 +1,7 @@
import eachOf from './eachOf';
import withoutIndex from './internal/withoutIndex';
import wrapAsync from './internal/wrapAsync'
+import awaitify from './internal/awaitify'
/**
* Applies the function `iteratee` to each item in `coll`, in parallel.
@@ -25,6 +26,7 @@ import wrapAsync from './internal/wrapAsync'
* If you need the index, use `eachOf`.
* @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
*
* // assuming openFiles is an array of file names and saveFile is a function
@@ -59,6 +61,8 @@ import wrapAsync from './internal/wrapAsync'
* }
* });
*/
-export default function eachLimit(coll, iteratee, callback) {
- eachOf(coll, withoutIndex(wrapAsync(iteratee)), callback);
+function eachLimit(coll, iteratee, callback) {
+ return eachOf(coll, withoutIndex(wrapAsync(iteratee)), callback);
}
+
+export default awaitify(eachLimit, 3)