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.

index.d.ts 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. declare namespace pMap {
  2. interface Options {
  3. /**
  4. Number of concurrently pending promises returned by `mapper`.
  5. @default Infinity
  6. */
  7. readonly concurrency?: number;
  8. /**
  9. 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.
  10. @default true
  11. */
  12. readonly stopOnError?: boolean;
  13. }
  14. /**
  15. Function which is called for every item in `input`. Expected to return a `Promise` or value.
  16. @param element - Iterated element.
  17. @param index - Index of the element in the source array.
  18. */
  19. type Mapper<Element = any, NewElement = any> = (
  20. element: Element,
  21. index: number
  22. ) => NewElement | Promise<NewElement>;
  23. }
  24. /**
  25. @param input - Iterated over concurrently in the `mapper` function.
  26. @param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
  27. @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.
  28. @example
  29. ```
  30. import pMap = require('p-map');
  31. import got = require('got');
  32. const sites = [
  33. getWebsiteFromUsername('https://sindresorhus'), //=> Promise
  34. 'https://ava.li',
  35. 'https://github.com'
  36. ];
  37. (async () => {
  38. const mapper = async site => {
  39. const {requestUrl} = await got.head(site);
  40. return requestUrl;
  41. };
  42. const result = await pMap(sites, mapper, {concurrency: 2});
  43. console.log(result);
  44. //=> ['https://sindresorhus.com/', 'https://ava.li/', 'https://github.com/']
  45. })();
  46. ```
  47. */
  48. declare function pMap<Element, NewElement>(
  49. input: Iterable<Element>,
  50. mapper: pMap.Mapper<Element, NewElement>,
  51. options?: pMap.Options
  52. ): Promise<NewElement[]>;
  53. export = pMap;