chunktools

1.0.6 • Public • Published

ChunkTools

ChunkTools is a lightweight and intuitive tool for deconstructing large arrays into smaller, more manageable arrays for chunk processing with or without promises.

Installation

Using npm:

npm i chunktools

Importing jsonlitedb to your Node Project:

const chunktools = require(‘chunktools’)

Usage

Chunktools features two functions:

makeChunksFromArray

Returns “chunks”/arrays of your designated size with the contents of your provided array distributed between them.

This function has two mandatory parameters:

  1. your array
  2. The size of the “chunks” you’d like to distribute your array into.

Example

let myArray = [0,1,2,3,4,5,6,7,8,9,10] 

makeChunksFromArray(myArray, 10) //Expected return: [[0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10]]`

makeChunksFromRange

Returns “chunks”/arrays of your designated size containing all the integers contained in your provided range.

This function has three mandatory parameters:

  1. From
  2. To
  3. The size of the “chunks” you’d like to distribute your array into.

Parameter 1 & 2 pertain to your range, so for example, if we want an array from 1 - 10 broken down into chunks that each contain one number, this is what it would look like:

makeChunksFromRange(1, 10, 1)

With the expected return being:

[[1],[2],[3],[4],[5],[6],[7],[8],[9],[10]]

Readme

Keywords

none

Package Sidebar

Install

npm i chunktools

Weekly Downloads

0

Version

1.0.6

License

ISC

Unpacked Size

2.18 kB

Total Files

3

Last publish

Collaborators

  • 0xinuarashi