qbatcher

1.0.2 • Public • Published

Build Status

QBatcher

Batch promises and/or limit them by time intervals.

Suited for issueing request to rate limited APIS (e.g 50 requests/ 10 secconds)

Installation

npm install qbatcher

Api

QBatcher.run(array: Collection, i => promise: Iteratee, int: batchSize, int: intervalLimit (milliseconds) )

Keep in mind that the interval limit should be milliseconds

The Promise: Iteratee will be called for each element in the Collection.

Use:

var QBatcher = require('qbatcher');
 
QBatcher.run([ 1, 2, 3, 4, 5], function (payload) {
 
        return new Promise(function(resolve) {
            setTimeout(function() { resolve(payload * 100) }, 100);
        });
 
    }, 2, 5000)
    .then(function (results) {
        console.log(results);
    });

Package Sidebar

Install

npm i qbatcher

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • maephisto