throat

WebJar for throat

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

throat
Last Version

Last Version

4.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

throat
WebJar for throat
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/ForbesLindesay/throat

Download throat

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/throat/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>throat</artifactId>
    <version>4.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/throat/
implementation 'org.webjars.npm:throat:4.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/throat/
implementation ("org.webjars.npm:throat:4.1.0")
'org.webjars.npm:throat:jar:4.1.0'
<dependency org="org.webjars.npm" name="throat" rev="4.1.0">
  <artifact name="throat" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='throat', version='4.1.0')
)
libraryDependencies += "org.webjars.npm" % "throat" % "4.1.0"
[org.webjars.npm/throat "4.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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

Versions

Version
4.1.0
2.0.2