1.0.0 • Published 5 years ago

@ngard/tiny-chunk v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

tiny-chunk

source bundle size build status license

A minimal-weight utility similar to lodash.chunk. For when every byte counts! The only difference is that tiny-chunk has a minimum chunk size of 1 instead of 0.

lodash.chunk bundle size tiny-chunk bundle size

Syntax

chunk(/* array [, chunkSize] */)

Parameters

array - An array to chunk chunkSize - optional A positive numerical value that designates the size of the chunks to be created. Non-numeric values will default to 1. Non-integer values will round down to the nearest integer.

Return

An array of elements split into groups the length of chunkSize. If the array can't be split evenly, the final chunk will be the remaining elements.

Example

import { chunk } from '@ngard/tiny-chunk';

const value = chunk([1, 2, 3, 4, 5], 2);
// value is [[1, 2], [3, 4], [5]]