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.

parallel.js 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = parallel;
  6. var _eachOf = require('./eachOf');
  7. var _eachOf2 = _interopRequireDefault(_eachOf);
  8. var _parallel2 = require('./internal/parallel');
  9. var _parallel3 = _interopRequireDefault(_parallel2);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. /**
  12. * Run the `tasks` collection of functions in parallel, without waiting until
  13. * the previous function has completed. If any of the functions pass an error to
  14. * its callback, the main `callback` is immediately called with the value of the
  15. * error. Once the `tasks` have completed, the results are passed to the final
  16. * `callback` as an array.
  17. *
  18. * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
  19. * parallel execution of code. If your tasks do not use any timers or perform
  20. * any I/O, they will actually be executed in series. Any synchronous setup
  21. * sections for each task will happen one after the other. JavaScript remains
  22. * single-threaded.
  23. *
  24. * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the
  25. * execution of other tasks when a task fails.
  26. *
  27. * It is also possible to use an object instead of an array. Each property will
  28. * be run as a function and the results will be passed to the final `callback`
  29. * as an object instead of an array. This can be a more readable way of handling
  30. * results from {@link async.parallel}.
  31. *
  32. * @name parallel
  33. * @static
  34. * @memberOf module:ControlFlow
  35. * @method
  36. * @category Control Flow
  37. * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of
  38. * [async functions]{@link AsyncFunction} to run.
  39. * Each async function can complete with any number of optional `result` values.
  40. * @param {Function} [callback] - An optional callback to run once all the
  41. * functions have completed successfully. This function gets a results array
  42. * (or object) containing all the result arguments passed to the task callbacks.
  43. * Invoked with (err, results).
  44. * @returns {Promise} a promise, if a callback is not passed
  45. *
  46. * @example
  47. * async.parallel([
  48. * function(callback) {
  49. * setTimeout(function() {
  50. * callback(null, 'one');
  51. * }, 200);
  52. * },
  53. * function(callback) {
  54. * setTimeout(function() {
  55. * callback(null, 'two');
  56. * }, 100);
  57. * }
  58. * ],
  59. * // optional callback
  60. * function(err, results) {
  61. * // the results array will equal ['one','two'] even though
  62. * // the second function had a shorter timeout.
  63. * });
  64. *
  65. * // an example using an object instead of an array
  66. * async.parallel({
  67. * one: function(callback) {
  68. * setTimeout(function() {
  69. * callback(null, 1);
  70. * }, 200);
  71. * },
  72. * two: function(callback) {
  73. * setTimeout(function() {
  74. * callback(null, 2);
  75. * }, 100);
  76. * }
  77. * }, function(err, results) {
  78. * // results is now equals to: {one: 1, two: 2}
  79. * });
  80. */
  81. function parallel(tasks, callback) {
  82. return (0, _parallel3.default)(_eachOf2.default, tasks, callback);
  83. }
  84. module.exports = exports['default'];