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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # throat
  2. Throttle the parallelism of an asynchronous, promise returning, function / functions. This has special utility when you set the concurrency to `1`. That way you get a mutually exclusive lock.
  3. [Professionally supported throat is now available](https://tidelift.com/subscription/pkg/npm-throat?utm_source=npm-throat&utm_medium=referral&utm_campaign=readme)
  4. [![Build Status](https://img.shields.io/github/workflow/status/ForbesLindesay/throat/Test/master?style=for-the-badge)](https://github.com/ForbesLindesay/throat/actions?query=workflow%3ATest+branch%3Amaster)
  5. [![Coveralls github branch](https://img.shields.io/coveralls/github/ForbesLindesay/throat/master?color=brightgreen&style=for-the-badge)](https://coveralls.io/github/ForbesLindesay/throat)
  6. [![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen?style=for-the-badge)](https://rollingversions.com/ForbesLindesay/throat)
  7. [![NPM version](https://img.shields.io/npm/v/throat?style=for-the-badge)](https://www.npmjs.com/package/throat)
  8. ## Installation
  9. npm install throat
  10. ## API
  11. ### throat(concurrency)
  12. This returns a function that acts a bit like a lock (exactly as a lock if concurrency is 1).
  13. Example, only 2 of the following functions will execute at any one time:
  14. ```js
  15. const throat = require('throat')(2);
  16. const resA = throat(async () => { /* async stuff... */ });
  17. const resB = throat(async () => { /* async stuff... */ });
  18. const resC = throat(async () => { /* async stuff... */ });
  19. const resD = throat(async () => { /* async stuff... */ });
  20. const resE = throat(async () => { /* async stuff... */ });
  21. ```
  22. ### throat(concurrency, worker)
  23. This returns a function that is an exact copy of `worker` except that it will only execute up to `concurrency` times in parallel before further requests are queued:
  24. ```js
  25. const throat = require('throat');
  26. const input = ['fileA.txt', 'fileB.txt', 'fileC.txt', 'fileD.txt'];
  27. const data = Promise.all(
  28. input.map(throat(2, (fileName) => readFile(fileName)))
  29. );
  30. ```
  31. Only 2 files will be read at a time, sometimes limiting parallelism in this way can improve scalability.
  32. ## Security contact information
  33. To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
  34. ## License
  35. MIT