You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Justine Kate Catid Miras 5ef3abc3c3 this is from the organization of my bootcamp repo which is mine that i did not notice i was not pushing it to my main repo, thats why i added this here and took me long cause i have no idea how to do this thanks to my curiosity i was able to identify or solve this problem. 10 months ago
..
LICENSE this is from the organization of my bootcamp repo which is mine that i did not notice i was not pushing it to my main repo, thats why i added this here and took me long cause i have no idea how to do this thanks to my curiosity i was able to identify or solve this problem. 10 months ago
README.md this is from the organization of my bootcamp repo which is mine that i did not notice i was not pushing it to my main repo, thats why i added this here and took me long cause i have no idea how to do this thanks to my curiosity i was able to identify or solve this problem. 10 months ago
index.d.ts this is from the organization of my bootcamp repo which is mine that i did not notice i was not pushing it to my main repo, thats why i added this here and took me long cause i have no idea how to do this thanks to my curiosity i was able to identify or solve this problem. 10 months ago
index.js this is from the organization of my bootcamp repo which is mine that i did not notice i was not pushing it to my main repo, thats why i added this here and took me long cause i have no idea how to do this thanks to my curiosity i was able to identify or solve this problem. 10 months ago
index.js.flow this is from the organization of my bootcamp repo which is mine that i did not notice i was not pushing it to my main repo, thats why i added this here and took me long cause i have no idea how to do this thanks to my curiosity i was able to identify or solve this problem. 10 months ago
package.json this is from the organization of my bootcamp repo which is mine that i did not notice i was not pushing it to my main repo, thats why i added this here and took me long cause i have no idea how to do this thanks to my curiosity i was able to identify or solve this problem. 10 months ago

README.md

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 Coverage Status Dependency Status NPM version Greenkeeper badge

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);
// 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:

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

License

MIT