every.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 _notId = require('./internal/notId');
  10. var _notId2 = _interopRequireDefault(_notId);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. /**
  13. * Returns `true` if every element in `coll` satisfies an async test. If any
  14. * iteratee call returns `false`, the main `callback` is immediately called.
  15. *
  16. * @name every
  17. * @static
  18. * @memberOf module:Collections
  19. * @method
  20. * @alias all
  21. * @category Collection
  22. * @param {Array|Iterable|Object} coll - A collection to iterate over.
  23. * @param {AsyncFunction} iteratee - An async truth test to apply to each item
  24. * in the collection in parallel.
  25. * The iteratee must complete with a boolean result value.
  26. * Invoked with (item, callback).
  27. * @param {Function} [callback] - A callback which is called after all the
  28. * `iteratee` functions have finished. Result will be either `true` or `false`
  29. * depending on the values of the async tests. Invoked with (err, result).
  30. * @example
  31. *
  32. * async.every(['file1','file2','file3'], function(filePath, callback) {
  33. * fs.access(filePath, function(err) {
  34. * callback(null, !err)
  35. * });
  36. * }, function(err, result) {
  37. * // if result is true then every file exists
  38. * });
  39. */
  40. exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
  41. module.exports = exports['default'];