MCPcopy Index your code
hub / github.com/ForbesLindesay/throat

github.com/ForbesLindesay/throat @6.0.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 6.0.2 ↗ · + Follow
21 symbols 39 edges 6 files 0 documented · 0% 5 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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

Build Status Coveralls github branch Rolling Versions NPM version

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:

const throat = require('throat')(2);

const resA = throat(async () => {
  /* async stuff... */
});
const resB = throat(async () => {
  /* async stuff... */
});
const resC = throat(async () => {
  /* async stuff... */
});
const resD = throat(async () => {
  /* async stuff... */
});
const resE = throat(async () => {
  /* async stuff... */
});

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:

const throat = require('throat');

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. Tidelift will coordinate the fix and disclosure.

License

MIT

Core symbols most depended-on inside this repo

job
called by 10
test/index.js
myOuterFunction
called by 7
test/index.js
worker
called by 6
test/index.js
throatInternal
called by 2
index.js
run
called by 2
index.js
release
called by 2
index.js
supportsAsyncStackTraces
called by 2
test/index.js
onReject
called by 1
index.js

Shape

Function 21

Languages

TypeScript100%

Modules by API surface

test/index.js11 symbols
index.js10 symbols

For agents

$ claude mcp add throat \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page