1.0.2 • Published 8 years ago

qbatcher v1.0.2

Weekly downloads
8
License
MIT
Repository
github
Last release
8 years ago

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);
    });
1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago