🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

array-chunk-reader

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-chunk-reader

Module for read array by chunks with promise

0.0.4
Source
npm
Version published
Weekly downloads
187
6.86%
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm install array-chunk-reader

About

Module for read array by chunks with promise
You can shuffle big array by segments.

Example

const arrayChunkReader = require("array-chunk-reader");
let array = [];

for(let i = 0; i < 1000000; i++) {
    array.push("element" + i);
}

let fn = (value) => {
    return Promise.resolve(value); 
}

/* 
    Each chunk will wait until all functions(fn) are finished. 
    Only then will a pause of the specified length and the next segment to be launched. 
    If the function returns a promise, all functions in one chunk will be executed in parallel.    
*/

let options = {
    size: 100, // chunk size, default = parseInt(Math.sqrt(array.length)) 
    timeout: 10, // timeout after each chunk, default = 1 
    log: true // show all process information on log, default = true 
    startFrom: 0 // start position, default = 0
    readTo: array.length // end position, default = array.length
}

let arrayReader = new ArrayChunkReader(array, options);

return arrayReader.start(fn).then(() => {
    // finish
});

Keywords

chunk

FAQs

Package last updated on 01 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts