1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _filter2 = require('./internal/filter');
|
8 |
|
9 | var _filter3 = _interopRequireDefault(_filter2);
|
10 |
|
11 | var _eachOf = require('./eachOf');
|
12 |
|
13 | var _eachOf2 = _interopRequireDefault(_eachOf);
|
14 |
|
15 | var _awaitify = require('./internal/awaitify');
|
16 |
|
17 | var _awaitify2 = _interopRequireDefault(_awaitify);
|
18 |
|
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20 |
|
21 | /**
|
22 | * Returns a new array of all the values in `coll` which pass an async truth
|
23 | * test. This operation is performed in parallel, but the results array will be
|
24 | * in the same order as the original.
|
25 | *
|
26 | * @name filter
|
27 | * @static
|
28 | * @memberOf module:Collections
|
29 | * @method
|
30 | * @alias select
|
31 | * @category Collection
|
32 | * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
33 | * @param {Function} iteratee - A truth test to apply to each item in `coll`.
|
34 | * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
|
35 | * with a boolean argument once it has completed. Invoked with (item, callback).
|
36 | * @param {Function} [callback] - A callback which is called after all the
|
37 | * `iteratee` functions have finished. Invoked with (err, results).
|
38 | * @returns {Promise} a promise, if no callback provided
|
39 | * @example
|
40 | *
|
41 | * async.filter(['file1','file2','file3'], function(filePath, callback) {
|
42 | * fs.access(filePath, function(err) {
|
43 | * callback(null, !err)
|
44 | * });
|
45 | * }, function(err, results) {
|
46 | * // results now equals an array of the existing files
|
47 | * });
|
48 | */
|
49 | function filter(coll, iteratee, callback) {
|
50 | return (0, _filter3.default)(_eachOf2.default, coll, iteratee, callback);
|
51 | }
|
52 | exports.default = (0, _awaitify2.default)(filter, 3);
|
53 | module.exports = exports['default']; |
\ | No newline at end of file |