slowloris

Events rate limiter and bulk processor

Usage no npm install needed!

<script type="module">
  import slowloris from 'https://cdn.skypack.dev/slowloris';
</script>

README

Slow Loris

Slow Loris is a small library to queue events and bulk process them in a specified interval

How to use

var Limiter = require("slowloris").Limiter;

var startTime = new Date().getTime(),
    counter = 0;

var l = new Limiter(500, function (d) {
    var now = new Date().getTime();
    console.log((now - startTime) + ": [" + d.queue.length + "] " + d.last);
    startTime = now;
});

var inter = setInterval(function () {
    l.event(counter);
    counter += 1;
    if (counter > 1200) {
        clearInterval(inter);
    }
}, 10);