npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

limit-calls

1.0.0

@mmalecki

npmRepoSnykSocket
Downloads:99
$ npm install limit-calls
DailyWeeklyMonthlyYearly

limit-calls

Build Status

Limit number of parallel calls to an asynchronous function.

Installation

npm install limit-calls

Usage

var limit = require('limit-calls');

function limitMe(arg, cb) {
  // There will only ever be 2 parallel calls to this function
  console.log(arg);
  setTimeout(cb, 100);
}

var f = limit(limitMe, 2);

f('Hello world');
f('Hello world');
f('Hello world');
f('Hello world');

// Execution of this script will take around 200 ms.