0.1.15 • Published 3 years ago

array-chunk-reader v0.1.15

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

Install

npm install array-chunk-reader

About

Module for reading an array by chunks using a promise

Example

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

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

// Function to handle each item
const fn = value => Promise.resolve(value);

// Function to handle a chunk
const fnChunk = allChunkValuesList => Promise.resolve(allChunkValuesList);

const options = {
  size: 100,         // chunk size, default = Math.floor(Math.sqrt(array.length))
  timeout: 10,       // timeout after each chunk, default = 1
  log: true,         // to log the process, default = true
  from: 0,           // start position, default = 0
  to: array.length   // end position, default = array.length
}

const arrayReader = new arrayChunkReader(array, options);
arrayReader.start(fn, fnChunk).then(() => 'the end');

Api

.getCurrentChunkSize()

returns the current chunk size

.stop()

cancel all next chunks after the current

0.1.15

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago