node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »



If you're looking for a promise-based alternative to this module check out wyt.

Trickle limits function executions based on time. It lets you define the number of executions per a certain amount of milliseconds.

This is particularly useful to obey an API provider's rate limit, for example.


Note: trickle is called "timetrickle" on npm because someone has occupied the name before I had a chance.

npm install timetrickle --save

or manually add it to your package.json


var trickle = require('timetrickle');
    start =;
// Helper function to show the time difference
function since (time) { return Math.round((time - start) / 1000) + 's'; }
// Limit once per second
var limit = trickle(1, 1000);
limit(function () {
    console.log('I am doing an API call here', since(;
limit(function () {
    console.log('I am doing another API call here', since(;
limit(function () {
    console.log('I am doing an API call here again', since(;

Will output:

I am doing an API call here 0s
I am doing an API call here again 1s
I am doing another API call here 2s