summaryrefslogtreecommitdiff
path: root/lib/detect.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/detect.js')
-rw-r--r--lib/detect.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/detect.js b/lib/detect.js
index 3e28f0e..4a6746a 100644
--- a/lib/detect.js
+++ b/lib/detect.js
@@ -1,5 +1,6 @@
import createTester from './internal/createTester';
-import doParallel from './internal/doParallel';
+import eachOf from './eachOf'
+import awaitify from './internal/awaitify'
/**
* Returns the first value in `coll` that passes an async truth test. The
@@ -26,6 +27,7 @@ import doParallel from './internal/doParallel';
* 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
* @example
*
* async.detect(['file1','file2','file3'], function(filePath, callback) {
@@ -36,4 +38,7 @@ import doParallel from './internal/doParallel';
* // result now equals the first file in the list that exists
* });
*/
-export default doParallel(createTester(bool => bool, (res, item) => item));
+function detect(coll, iteratee, callback) {
+ return createTester(bool => bool, (res, item) => item)(eachOf, coll, iteratee, callback)
+}
+export default awaitify(detect, 3)