q-ratelimit

Rate limiting (throttling) implementation for Q

Usage no npm install needed!

<script type="module">
  import qRatelimit from 'https://cdn.skypack.dev/q-ratelimit';
</script>

README

q-ratelimit

NPM Version NPM Downloads Build Status Coverage Status Dependency Status devDependency Status

Rate limiting (throttling) implementation for Q promises on Node.js

Install: npm install q-ratelimit

Limit frequency of promise fulfilling:

var throttle = require('q-ratelimit')(2000); /* rateInMilliseconds */

var startTime = Date.now();

for (var i = 0; i < 10; i++) {
    throttle().then(function() { console.log(Date.now() - startTime); }).done();
}

// example output:
// 11
// 2007
// 4007
// 6008
// 8011
// 10014
// 12016
// 14018
// 16020
// 18022

License

MIT