UNPKG

1.71 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _reject2 = require('./internal/reject');
8
9var _reject3 = _interopRequireDefault(_reject2);
10
11var _eachOf = require('./eachOf');
12
13var _eachOf2 = _interopRequireDefault(_eachOf);
14
15var _awaitify = require('./internal/awaitify');
16
17var _awaitify2 = _interopRequireDefault(_awaitify);
18
19function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21/**
22 * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
23 *
24 * @name reject
25 * @static
26 * @memberOf module:Collections
27 * @method
28 * @see [async.filter]{@link module:Collections.filter}
29 * @category Collection
30 * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
31 * @param {Function} iteratee - An async truth test to apply to each item in
32 * `coll`.
33 * The should complete with a boolean value as its `result`.
34 * Invoked with (item, callback).
35 * @param {Function} [callback] - A callback which is called after all the
36 * `iteratee` functions have finished. Invoked with (err, results).
37 * @returns {Promise} a promise, if no callback is passed
38 * @example
39 *
40 * async.reject(['file1','file2','file3'], function(filePath, callback) {
41 * fs.access(filePath, function(err) {
42 * callback(null, !err)
43 * });
44 * }, function(err, results) {
45 * // results now equals an array of missing files
46 * createFiles(results);
47 * });
48 */
49function reject(coll, iteratee, callback) {
50 return (0, _reject3.default)(_eachOf2.default, coll, iteratee, callback);
51}
52exports.default = (0, _awaitify2.default)(reject, 3);
53module.exports = exports['default'];
\No newline at end of file