every.js

  1. import createTester from './internal/createTester';
  2. import doParallel from './internal/doParallel';
  3. import notId from './internal/notId';
  4. /**
  5. * Returns `true` if every element in `coll` satisfies an async test. If any
  6. * iteratee call returns `false`, the main `callback` is immediately called.
  7. *
  8. * @name every
  9. * @static
  10. * @memberOf module:Collections
  11. * @method
  12. * @alias all
  13. * @category Collection
  14. * @param {Array|Iterable|Object} coll - A collection to iterate over.
  15. * @param {AsyncFunction} iteratee - An async truth test to apply to each item
  16. * in the collection in parallel.
  17. * The iteratee must complete with a boolean result value.
  18. * Invoked with (item, callback).
  19. * @param {Function} [callback] - A callback which is called after all the
  20. * `iteratee` functions have finished. Result will be either `true` or `false`
  21. * depending on the values of the async tests. Invoked with (err, result).
  22. * @example
  23. *
  24. * async.every(['file1','file2','file3'], function(filePath, callback) {
  25. * fs.access(filePath, function(err) {
  26. * callback(null, !err)
  27. * });
  28. * }, function(err, result) {
  29. * // if result is true then every file exists
  30. * });
  31. */
  32. export default doParallel(createTester(notId, notId));