Configurable throttled Fetch API
interval
: interval between each fetch, in millisecondsmax
: number offetch
es to run in parallel
const fetcher = new Fetcher({ interval: 1000, max: 1 });
// These five calls will call sequentially since `max` is set to 1
["/", "/status/500", "/ip", "/", "/"].forEach(path => {
fetcher.fetch(`https://httpbin.org/${path}`).then(() => console.log(path, 'loaded'));
});
See test/SpecRunner.html