mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 21:14:45 +00:00
.
This commit is contained in:
parent
beb1329f9f
commit
2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
55
node_modules/throat/README.md
generated
vendored
Normal file
55
node_modules/throat/README.md
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
# throat
|
||||
|
||||
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.
|
||||
|
||||
[](https://travis-ci.org/ForbesLindesay/throat)
|
||||
[](https://coveralls.io/r/ForbesLindesay/throat?branch=master)
|
||||
[](https://david-dm.org/ForbesLindesay/throat)
|
||||
[](https://www.npmjs.com/package/throat)
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
[](https://saucelabs.com/u/throat)
|
||||
|
||||
## Installation
|
||||
|
||||
npm install throat
|
||||
|
||||
## API
|
||||
|
||||
### throat(concurrency)
|
||||
|
||||
This returns a function that acts a bit like a lock (exactly as a lock if concurrency is 1).
|
||||
|
||||
Example, only 2 of the following functions will execute at any one time:
|
||||
|
||||
```js
|
||||
const throat = require('throat')(2);
|
||||
// alternatively provide your own promise implementation
|
||||
const throat = require('throat')(require('promise'))(2);
|
||||
const promise = Promise.resolve();
|
||||
|
||||
const resA = throat(() => /* async stuff... */ promise);
|
||||
const resB = throat(() => /* async stuff... */ promise);
|
||||
const resC = throat(() => /* async stuff... */ promise);
|
||||
const resD = throat(() => /* async stuff... */ promise);
|
||||
const resE = throat(() => /* async stuff... */ promise);
|
||||
```
|
||||
|
||||
### throat(concurrency, worker)
|
||||
|
||||
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:
|
||||
|
||||
```js
|
||||
const throat = require('throat');
|
||||
// alternatively provide your own promise implementation
|
||||
const throat = require('throat')(require('promise'));
|
||||
|
||||
const input = ['fileA.txt', 'fileB.txt', 'fileC.txt', 'fileD.txt'];
|
||||
const data = Promise.all(input.map(throat(2, fileName => readFile(fileName))));
|
||||
```
|
||||
|
||||
Only 2 files will be read at a time, sometimes limiting parallelism in this way can improve scalability.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
Loading…
Add table
Add a link
Reference in a new issue