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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # p-map [![Build Status](https://travis-ci.org/sindresorhus/p-map.svg?branch=master)](https://travis-ci.org/sindresorhus/p-map)
  2. > Map over promises concurrently
  3. Useful when you need to run promise-returning & async functions multiple times with different inputs concurrently.
  4. ## Install
  5. ```
  6. $ npm install p-map
  7. ```
  8. ## Usage
  9. ```js
  10. const pMap = require('p-map');
  11. const got = require('got');
  12. const sites = [
  13. getWebsiteFromUsername('https://sindresorhus'), //=> Promise
  14. 'https://ava.li',
  15. 'https://github.com'
  16. ];
  17. (async () => {
  18. const mapper = async site => {
  19. const {requestUrl} = await got.head(site);
  20. return requestUrl;
  21. };
  22. const result = await pMap(sites, mapper, {concurrency: 2});
  23. console.log(result);
  24. //=> ['https://sindresorhus.com/', 'https://ava.li/', 'https://github.com/']
  25. })();
  26. ```
  27. ## API
  28. ### pMap(input, mapper, options?)
  29. Returns a `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
  30. #### input
  31. Type: `Iterable<Promise | unknown>`
  32. Iterated over concurrently in the `mapper` function.
  33. #### mapper(element, index)
  34. Type: `Function`
  35. Expected to return a `Promise` or value.
  36. #### options
  37. Type: `object`
  38. ##### concurrency
  39. Type: `number`<br>
  40. Default: `Infinity`<br>
  41. Minimum: `1`
  42. Number of concurrently pending promises returned by `mapper`.
  43. ##### stopOnError
  44. Type: `boolean`<br>
  45. Default: `true`
  46. When set to `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [aggregated error](https://github.com/sindresorhus/aggregate-error) containing all the errors from the rejected promises.
  47. ## Related
  48. - [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
  49. - [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
  50. - [p-times](https://github.com/sindresorhus/p-times) - Run promise-returning & async functions a specific number of times concurrently
  51. - [p-props](https://github.com/sindresorhus/p-props) - Like `Promise.all()` but for `Map` and `Object`
  52. - [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially
  53. - [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control
  54. - [More…](https://github.com/sindresorhus/promise-fun)
  55. ---
  56. <div align="center">
  57. <b>
  58. <a href="https://tidelift.com/subscription/pkg/npm-p-map?utm_source=npm-p-map&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
  59. </b>
  60. <br>
  61. <sub>
  62. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  63. </sub>
  64. </div>