Throttle a collection of promise returning functions
Installations
npm install throat
Developer
ForbesLindesay
Developer Guide
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
No
Node Version
12.22.12
NPM Version
6.14.16
Statistics
484 Stars
63 Commits
40 Forks
4 Watching
79 Branches
9 Contributors
Updated on 25 Sept 2024
Bundle Size
1.99 kB
Minified
780.00 B
Minified + Gzipped
Languages
JavaScript (95.52%)
TypeScript (4.48%)
Total Downloads
Cumulative downloads
Total Downloads
3,490,532,546
Last day
-2.5%
3,136,042
Compared to previous day
Last week
5.4%
17,771,639
Compared to previous week
Last month
38.1%
64,339,316
Compared to previous month
Last year
-15.4%
620,301,932
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
8
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
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:
1const throat = require('throat')(2); 2 3const resA = throat(async () => { 4 /* async stuff... */ 5}); 6const resB = throat(async () => { 7 /* async stuff... */ 8}); 9const resC = throat(async () => { 10 /* async stuff... */ 11}); 12const resD = throat(async () => { 13 /* async stuff... */ 14}); 15const resE = throat(async () => { 16 /* async stuff... */ 17});
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:
1const throat = require('throat'); 2 3const input = ['fileA.txt', 'fileB.txt', 'fileC.txt', 'fileD.txt']; 4const data = Promise.all( 5 input.map(throat(2, (fileName) => readFile(fileName))) 6);
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. Tidelift will coordinate the fix and disclosure.
License
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 4/22 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/rollingversions.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rollingversions.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/ForbesLindesay/throat/rollingversions.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rollingversions.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/ForbesLindesay/throat/rollingversions.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rollingversions.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/ForbesLindesay/throat/rollingversions.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rollingversions.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/ForbesLindesay/throat/rollingversions.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/ForbesLindesay/throat/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/ForbesLindesay/throat/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/ForbesLindesay/throat/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/ForbesLindesay/throat/test.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/rollingversions.yml:21
- Warn: npmCommand not pinned by hash: .github/workflows/rollingversions.yml:33
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:25
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 0 out of 3 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 20 are checked with a SAST tool
Score
4.6
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More