diff options
Diffstat (limited to 'lib/detectLimit.js')
-rw-r--r-- | lib/detectLimit.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/detectLimit.js b/lib/detectLimit.js index a0f9d89..7630d6d 100644 --- a/lib/detectLimit.js +++ b/lib/detectLimit.js @@ -1,5 +1,6 @@ import createTester from './internal/createTester'; -import doParallelLimit from './internal/doParallelLimit'; +import eachOfLimit from './internal/eachOfLimit' +import awaitify from './internal/awaitify' /** * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a @@ -22,5 +23,9 @@ import doParallelLimit from './internal/doParallelLimit'; * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with * (err, result). + * @returns a Promise if no callback is passed */ -export default doParallelLimit(createTester(bool => bool, (res, item) => item)); +function detectLimit(coll, limit, iteratee, callback) { + return createTester(bool => bool, (res, item) => item)(eachOfLimit(limit), coll, iteratee, callback) +} +export default awaitify(detectLimit, 4) |