call-limit

WebJar for call-limit

License

License

ISC
Categories

Categories

Github Development Tools Version Controls
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

github-com-iarna-call-limit
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

call-limit
WebJar for call-limit
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/iarna/call-limit

Download github-com-iarna-call-limit

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/github-com-iarna-call-limit/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>github-com-iarna-call-limit</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-iarna-call-limit/
implementation 'org.webjars.npm:github-com-iarna-call-limit:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-iarna-call-limit/
implementation ("org.webjars.npm:github-com-iarna-call-limit:1.1.0")
'org.webjars.npm:github-com-iarna-call-limit:jar:1.1.0'
<dependency org="org.webjars.npm" name="github-com-iarna-call-limit" rev="1.1.0">
  <artifact name="github-com-iarna-call-limit" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='github-com-iarna-call-limit', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "github-com-iarna-call-limit" % "1.1.0"
[org.webjars.npm/github-com-iarna-call-limit "1.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.

call-limit

Limit the number of simultaneous executions of a async function.

const fs = require('fs')
const limit = require('call-limit')
const limitedStat = limit(fs.stat, 5)

Or with promise returning functions:

const fs = Bluebird.promisifyAll(require('fs'))
const limit = require('call-limit')
const limitedStat = limit.promise(fs.statAsync, 5)

USAGE:

Given that:

const limit = require('call-limit')

limit(func, maxRunning) → limitedFunc

The returned function will execute up to maxRunning calls of func at once. Beyond that they get queued and called when the previous call completes.

func must accept a callback as the final argument and must call it when it completes, or call-limit won't know to dequeue the next thing to run.

By contrast, callers to limitedFunc do NOT have to pass in a callback, but if they do they'll be called when func calls its callback.

limit.promise(func, maxRunning) → limitedFunc

The returned function will execute up to maxRunning calls of func at once. Beyond that they get queued and called when the previous call completes.

func must return a promise.

limitedFunc will return a promise that resolves with the promise returned from the call to func.

limit.method(class, methodName, maxRunning)

This is sugar for:

class.prototype.methodName = limit(class.prototype.methodName, maxRunning)

limit.method(object, methodName, maxRunning)

This is sugar for:

object.methodName = limit(object.methodName, maxRunning)

For example limit.promise.method(fs, 'stat', 5) is the same as fs.stat = limit.promise(fs.stat, 5).

limit.promise.method(class, methodName, maxRunning)

This is sugar for:

class.prototype.methodName = limit.promise(class.prototype.methodName, maxRunning)

limit.promise.method(object, methodName, maxRunning)

This is sugar for:

object.methodName = limit.promise(object.methodName, maxRunning)

For example limit.promise.method(fs, 'statAsync', 5) is the same as fs.statAsync = limit.promise(fs.statAsync, 5).

Versions

Version
1.1.0