1.2.1 • Published 10 months ago

chunkjs v1.2.1

Weekly downloads
7
License
MIT
Repository
github
Last release
10 months ago

ChunkJS

ChunkJS is a minimal library that splits arrays into smaller chunks or batches.

Installation

npm install chunkjs

or using Yarn

yarn add chunkjs

Usage

ChunkJS is comprised of two functions: createChunks and createBatches:

createChunks(array, numberOfChunks);

createBatches(array, numberOfElementsPerBatch);

Examples

To split an array into an n number of chunks (default size is 2):

const { createChunks } = require("chunkjs");

createChunks([ 1, 2, 3, 4, 5, 6 ], 2);
// returns [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]

To split an array into batches with n number of elements (default size is 2):

const { createBatches } = require("chunkjs");

createBatches([ 1, 2, 3, 4, 5, 6 ], 2);
// returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
1.2.1

10 months ago

1.2.0

3 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago