Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

chunk

v4.17.15arrow_drop_down
v4.17.15
v4.17.11
STATUS
Passing
DOWNLOADS
161
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
4 months ago
SIZE
N/A
Creates an array of elements split into groups the length of `size`. If `array` can't be split evenly, the final chunk will be the remaining elements.
2 contributors
Install chunk as a package?
Copied
npm i @bit/lodash.lodash.chunk
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
  ["a", "b", "c", "d"],
  2,
modifieddraft
chevron_left
chevron_right
chunk (
array:Array,
size:number?
) : Array

Creates an array of elements split into groups the length of size. If array can’t be split evenly, the final chunk will be the remaining elements.

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

chunk(['a', 'b', 'c', 'd'], 3)
// => [['a', 'b', 'c'], ['d']]
Arguments
array: Array

The array to process.

size: number?

The length of each chunk

Returns
Array

Returns the new array of chunks.