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.

series.js 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = series;
  6. var _parallel2 = require('./internal/parallel');
  7. var _parallel3 = _interopRequireDefault(_parallel2);
  8. var _eachOfSeries = require('./eachOfSeries');
  9. var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. /**
  12. * Run the functions in the `tasks` collection in series, each one running once
  13. * the previous function has completed. If any functions in the series pass an
  14. * error to its callback, no more functions are run, and `callback` is
  15. * immediately called with the value of the error. Otherwise, `callback`
  16. * receives an array of results when `tasks` have completed.
  17. *
  18. * It is also possible to use an object instead of an array. Each property will
  19. * be run as a function, and the results will be passed to the final `callback`
  20. * as an object instead of an array. This can be a more readable way of handling
  21. * results from {@link async.series}.
  22. *
  23. * **Note** that while many implementations preserve the order of object
  24. * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
  25. * explicitly states that
  26. *
  27. * > The mechanics and order of enumerating the properties is not specified.
  28. *
  29. * So if you rely on the order in which your series of functions are executed,
  30. * and want this to work on all platforms, consider using an array.
  31. *
  32. * @name series
  33. * @static
  34. * @memberOf module:ControlFlow
  35. * @method
  36. * @category Control Flow
  37. * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing
  38. * [async functions]{@link AsyncFunction} to run in series.
  39. * Each 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. This function gets a results array (or object)
  42. * containing all the result arguments passed to the `task` callbacks. Invoked
  43. * with (err, result).
  44. * @return {Promise} a promise, if no callback is passed
  45. * @example
  46. * async.series([
  47. * function(callback) {
  48. * // do some stuff ...
  49. * callback(null, 'one');
  50. * },
  51. * function(callback) {
  52. * // do some more stuff ...
  53. * callback(null, 'two');
  54. * }
  55. * ],
  56. * // optional callback
  57. * function(err, results) {
  58. * // results is now equal to ['one', 'two']
  59. * });
  60. *
  61. * async.series({
  62. * one: function(callback) {
  63. * setTimeout(function() {
  64. * callback(null, 1);
  65. * }, 200);
  66. * },
  67. * two: function(callback){
  68. * setTimeout(function() {
  69. * callback(null, 2);
  70. * }, 100);
  71. * }
  72. * }, function(err, results) {
  73. * // results is now equal to: {one: 1, two: 2}
  74. * });
  75. */
  76. function series(tasks, callback) {
  77. return (0, _parallel3.default)(_eachOfSeries2.default, tasks, callback);
  78. }
  79. module.exports = exports['default'];