any.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _createTester = require('./internal/createTester');
  6. var _createTester2 = _interopRequireDefault(_createTester);
  7. var _doParallel = require('./internal/doParallel');
  8. var _doParallel2 = _interopRequireDefault(_doParallel);
  9. var _identity = require('lodash/identity');
  10. var _identity2 = _interopRequireDefault(_identity);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. /**
  13. * Returns `true` if at least one element in the `coll` satisfies an async test.
  14. * If any iteratee call returns `true`, the main `callback` is immediately
  15. * called.
  16. *
  17. * @name some
  18. * @static
  19. * @memberOf module:Collections
  20. * @method
  21. * @alias any
  22. * @category Collection
  23. * @param {Array|Iterable|Object} coll - A collection to iterate over.
  24. * @param {AsyncFunction} iteratee - An async truth test to apply to each item
  25. * in the collections in parallel.
  26. * The iteratee should complete with a boolean `result` value.
  27. * Invoked with (item, callback).
  28. * @param {Function} [callback] - A callback which is called as soon as any
  29. * iteratee returns `true`, or after all the iteratee functions have finished.
  30. * Result will be either `true` or `false` depending on the values of the async
  31. * tests. Invoked with (err, result).
  32. * @example
  33. *
  34. * async.some(['file1','file2','file3'], function(filePath, callback) {
  35. * fs.access(filePath, function(err) {
  36. * callback(null, !err)
  37. * });
  38. * }, function(err, result) {
  39. * // if result is true then at least one of the files exists
  40. * });
  41. */
  42. exports.default = (0, _doParallel2.default)((0, _createTester2.default)(Boolean, _identity2.default));
  43. module.exports = exports['default'];