mirror of
https://github.com/azure/login.git
synced 2026-03-15 09:20:56 -04:00
* Bump lodash from 4.17.15 to 4.17.19 (#52) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com> * Bump @actions/core from 1.1.3 to 1.2.6 (#60) Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.1.3 to 1.2.6. - [Release notes](https://github.com/actions/toolkit/releases) - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com> * updating node_nodules * updated package-lock Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
60 lines
2.5 KiB
Markdown
60 lines
2.5 KiB
Markdown
# 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.
|
|
|
|
[Professionally supported throat is now available](https://tidelift.com/subscription/pkg/npm-throat?utm_source=npm-throat&utm_medium=referral&utm_campaign=readme)
|
|
|
|
[](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/)
|
|
|
|
## 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.
|
|
|
|
## Security contact information
|
|
|
|
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
|
|
|
## License
|
|
|
|
MIT
|