1.0.0 • Published 2 years ago

jsmp-infra-volodymyr-smoliar-array-chunker v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

array-chunker

Array chunker is a small module that creates an array of elements split into groups the length of size. If array can't be split evently, the final chunk will be the remaining elements.

Arguments

array (Array): The array to process. size=1: The length of each chunk

Returns

(Array): Returns the new array of chunks.

Example

chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]

chunk(['a', 'b', 'c', 'd'], 3);
// => [['a', 'b', 'c'], ['d']]