source: trip-planner-front/node_modules/async/find.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.2 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _identity = require('lodash/identity');
8
9var _identity2 = _interopRequireDefault(_identity);
10
11var _createTester = require('./internal/createTester');
12
13var _createTester2 = _interopRequireDefault(_createTester);
14
15var _doParallel = require('./internal/doParallel');
16
17var _doParallel2 = _interopRequireDefault(_doParallel);
18
19var _findGetResult = require('./internal/findGetResult');
20
21var _findGetResult2 = _interopRequireDefault(_findGetResult);
22
23function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
25/**
26 * Returns the first value in `coll` that passes an async truth test. The
27 * `iteratee` is applied in parallel, meaning the first iteratee to return
28 * `true` will fire the detect `callback` with that result. That means the
29 * result might not be the first item in the original `coll` (in terms of order)
30 * that passes the test.
31
32 * If order within the original `coll` is important, then look at
33 * [`detectSeries`]{@link module:Collections.detectSeries}.
34 *
35 * @name detect
36 * @static
37 * @memberOf module:Collections
38 * @method
39 * @alias find
40 * @category Collections
41 * @param {Array|Iterable|Object} coll - A collection to iterate over.
42 * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
43 * The iteratee must complete with a boolean value as its result.
44 * Invoked with (item, callback).
45 * @param {Function} [callback] - A callback which is called as soon as any
46 * iteratee returns `true`, or after all the `iteratee` functions have finished.
47 * Result will be the first item in the array that passes the truth test
48 * (iteratee) or the value `undefined` if none passed. Invoked with
49 * (err, result).
50 * @example
51 *
52 * async.detect(['file1','file2','file3'], function(filePath, callback) {
53 * fs.access(filePath, function(err) {
54 * callback(null, !err)
55 * });
56 * }, function(err, result) {
57 * // result now equals the first file in the list that exists
58 * });
59 */
60exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default));
61module.exports = exports['default'];
Note: See TracBrowser for help on using the repository browser.