Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

forEach.js 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _eachOf = require('./eachOf');
  6. var _eachOf2 = _interopRequireDefault(_eachOf);
  7. var _withoutIndex = require('./internal/withoutIndex');
  8. var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
  9. var _wrapAsync = require('./internal/wrapAsync');
  10. var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
  11. var _awaitify = require('./internal/awaitify');
  12. var _awaitify2 = _interopRequireDefault(_awaitify);
  13. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14. /**
  15. * Applies the function `iteratee` to each item in `coll`, in parallel.
  16. * The `iteratee` is called with an item from the list, and a callback for when
  17. * it has finished. If the `iteratee` passes an error to its `callback`, the
  18. * main `callback` (for the `each` function) is immediately called with the
  19. * error.
  20. *
  21. * Note, that since this function applies `iteratee` to each item in parallel,
  22. * there is no guarantee that the iteratee functions will complete in order.
  23. *
  24. * @name each
  25. * @static
  26. * @memberOf module:Collections
  27. * @method
  28. * @alias forEach
  29. * @category Collection
  30. * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
  31. * @param {AsyncFunction} iteratee - An async function to apply to
  32. * each item in `coll`. Invoked with (item, callback).
  33. * The array index is not passed to the iteratee.
  34. * If you need the index, use `eachOf`.
  35. * @param {Function} [callback] - A callback which is called when all
  36. * `iteratee` functions have finished, or an error occurs. Invoked with (err).
  37. * @returns {Promise} a promise, if a callback is omitted
  38. * @example
  39. *
  40. * // assuming openFiles is an array of file names and saveFile is a function
  41. * // to save the modified contents of that file:
  42. *
  43. * async.each(openFiles, saveFile, function(err){
  44. * // if any of the saves produced an error, err would equal that error
  45. * });
  46. *
  47. * // assuming openFiles is an array of file names
  48. * async.each(openFiles, function(file, callback) {
  49. *
  50. * // Perform operation on file here.
  51. * console.log('Processing file ' + file);
  52. *
  53. * if( file.length > 32 ) {
  54. * console.log('This file name is too long');
  55. * callback('File name too long');
  56. * } else {
  57. * // Do work to process file here
  58. * console.log('File processed');
  59. * callback();
  60. * }
  61. * }, function(err) {
  62. * // if any of the file processing produced an error, err would equal that error
  63. * if( err ) {
  64. * // One of the iterations produced an error.
  65. * // All processing will now stop.
  66. * console.log('A file failed to process');
  67. * } else {
  68. * console.log('All files have been processed successfully');
  69. * }
  70. * });
  71. */
  72. function eachLimit(coll, iteratee, callback) {
  73. return (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
  74. }
  75. exports.default = (0, _awaitify2.default)(eachLimit, 3);
  76. module.exports = exports['default'];