New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
180
decreased by-3.23%
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm install array-chunk-reader

About

Module for reading array by chunks using promise

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

let fnChunk = (allChunkValuesList) => {
    return Promise.resolve(allChunkValuesList);
}

/*
    Each chunk waits of completion all functions(fn). fnChunk is called after that.
    Then there is a pause of the specified length and the next chunk starts.
    If the function returns a promise, all functions in one chunk are called 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
    from: 0, // start position, default = 0 (you can use also .startFrom)
    to: array.length // end position, default = array.length (you can use also .readTo)
}

let arrayReader = new arrayChunkReader(array, options);

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

Api

.getCurrentChunkSize()

returns current chunk size

Keywords

FAQs

Package last updated on 22 Jan 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc