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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # p-limit [![Build Status](https://travis-ci.org/sindresorhus/p-limit.svg?branch=master)](https://travis-ci.org/sindresorhus/p-limit)
  2. > Run multiple promise-returning & async functions with limited concurrency
  3. ## Install
  4. ```
  5. $ npm install p-limit
  6. ```
  7. ## Usage
  8. ```js
  9. const pLimit = require('p-limit');
  10. const limit = pLimit(1);
  11. const input = [
  12. limit(() => fetchSomething('foo')),
  13. limit(() => fetchSomething('bar')),
  14. limit(() => doSomething())
  15. ];
  16. (async () => {
  17. // Only one promise is run at once
  18. const result = await Promise.all(input);
  19. console.log(result);
  20. })();
  21. ```
  22. ## API
  23. ### pLimit(concurrency)
  24. Returns a `limit` function.
  25. #### concurrency
  26. Type: `number`\
  27. Minimum: `1`\
  28. Default: `Infinity`
  29. Concurrency limit.
  30. ### limit(fn, ...args)
  31. Returns the promise returned by calling `fn(...args)`.
  32. #### fn
  33. Type: `Function`
  34. Promise-returning/async function.
  35. #### args
  36. Any arguments to pass through to `fn`.
  37. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions.
  38. ### limit.activeCount
  39. The number of promises that are currently running.
  40. ### limit.pendingCount
  41. The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
  42. ### limit.clearQueue()
  43. Discard pending promises that are waiting to run.
  44. This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
  45. Note: This does not cancel promises that are already running.
  46. ## FAQ
  47. ### How is this different from the [`p-queue`](https://github.com/sindresorhus/p-queue) package?
  48. This package is only about limiting the number of concurrent executions, while `p-queue` is a fully featured queue implementation with lots of different options, introspection, and ability to pause the queue.
  49. ## Related
  50. - [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control
  51. - [p-throttle](https://github.com/sindresorhus/p-throttle) - Throttle promise-returning & async functions
  52. - [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions
  53. - [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
  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-limit?utm_source=npm-p-limit&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>