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.

readme.md 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # p-each-series [![Build Status](https://travis-ci.com/sindresorhus/p-each-series.svg?branch=master)](https://travis-ci.com/github/sindresorhus/p-each-series)
  2. > Iterate over promises serially
  3. Useful as a side-effect iterator. Prefer [`p-map`](https://github.com/sindresorhus/p-map) if you don't need side-effects, as it's concurrent.
  4. ## Install
  5. ```
  6. $ npm install p-each-series
  7. ```
  8. ## Usage
  9. ```js
  10. const pEachSeries = require('p-each-series');
  11. const keywords = [
  12. getTopKeyword(), //=> Promise
  13. 'rainbow',
  14. 'pony'
  15. ];
  16. const iterator = async element => saveToDiskPromise(element);
  17. (async () => {
  18. console.log(await pEachSeries(keywords, iterator));
  19. //=> ['unicorn', 'rainbow', 'pony']
  20. })();
  21. ```
  22. ## API
  23. ### pEachSeries(input, iterator)
  24. Returns a `Promise` that is fulfilled when all promises in `input` and ones returned from `iterator` are fulfilled, or rejects if any of the promises reject. The fulfillment value is the original `input`.
  25. #### input
  26. Type: `Iterable<Promise | unknown>`
  27. Iterated over serially in the `iterator` function.
  28. #### iterator(element, index)
  29. Type: `Function`
  30. Return value is ignored unless it's `Promise`, then it's awaited before continuing with the next iteration.
  31. ### pEachSeries.stop
  32. Stop iterating through items by returning `pEachSeries.stop` from the iterator function.
  33. ```js
  34. const pEachSeries = require('p-each-series');
  35. // Logs `a` and `b`.
  36. const result = await pEachSeries(['a', 'b', 'c'], value => {
  37. console.log(value);
  38. if (value === 'b') {
  39. return pEachSeries.stop;
  40. }
  41. });
  42. console.log(result);
  43. //=> ['a', 'b', 'c']
  44. ```
  45. ## Related
  46. - [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially
  47. - [p-series](https://github.com/sindresorhus/p-series) - Run promise-returning & async functions in series
  48. - [p-pipe](https://github.com/sindresorhus/p-pipe) - Compose promise-returning & async functions into a reusable pipeline
  49. - [p-waterfall](https://github.com/sindresorhus/p-waterfall) - Run promise-returning & async functions in series, each passing its result to the next
  50. - [p-reduce](https://github.com/sindresorhus/p-reduce) - Reduce a list of values using promises into a promise for a value
  51. - [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
  52. - [More…](https://github.com/sindresorhus/promise-fun)