Skip to content

A utility wrapper around es6-promise-pool that lets you process data arrays in batches

Notifications You must be signed in to change notification settings

itsTeknas/pooled-batch-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pooled-batch-processor

A utility wrapper around es6-promise-pool that lets you process data arrays in batches

Installation

npm install pooled-batch-processor --save

Usage

let pool = require('pooled-batch-processor')

let longDataArray = [
    1,
    2,
    ...
]

pool.processInPool(longDataArray, 5, 10, (batch) => {
    // This function should return a promise.

    return new Promise(resolve => {

        // Process the batch

        // each batch will have 5 items from longDataArray
        // this will be run in 10 promises at a time simultaneously

        // If split is set to 1,
        // you will get individual items in place of a array.
        resolve();
    }) 
}).then(() => {
    // All items processed
})

About

A utility wrapper around es6-promise-pool that lets you process data arrays in batches

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published