
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
Limit the number of simultaneous executions of a async function.
var fs = require('fs')
var limit = require('call-limit')
var limitedStat = limit(fs.stat, 5)
Or with promise returning functions:
var fs = Bluebird.promisifyAll(require('fs'))
var limit = require('call-limit')
var limitedStat = limit.promise(fs.statAsync, 5)
Given that:
var limit = require('call-limit')
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.
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.
This is sugar for:
class.prototype.methodName = limit(class.prototype.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).
This is sugar for:
class.prototype.methodName = limit.promise(class.prototype.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).
FAQs
Limit the number of simultaneous calls to an async function
We found that call-limit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.