1.0.9 • Published 6 years ago
pareach v1.0.9
parEach - a tiny function that "parallelizes" work for NodeJS
How to install:
npm install pareachHow to use:
const parEach = require('pareach');
await parEach(work, args[, options]);work- an async function that accepts the args providedargs- an array of arguments to call theworkfunction (if you pass more than one then use a nested array[['foo', 'bar'], ...])options- a configuration objectconcurrencyLimit- which is5by default, controls concurrency per threadparallel- process work with multiple threads
Example of parallel processing
await parEach(work, args, { concurrencyLimit: 10, parallel: true });This was will spawn a thread for every logical CPU and split the work.
Performance
Sequential took 155.45 seconds
Batched took 16.04 seconds
Parallelized took 3.55 secondsThis was made for the article:
Kicking Node into high gear for data processing or how to hire 100 cats to catch a mouse