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

chunk

v4.17.11arrow_drop_down
v4.17.11
STATUS
Passing
DOWNLOADS
39
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
8 months ago
SIZE
2 KB
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.
1 contributor
Use chunk in your project ?
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
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';
revert changes
reload
toggle layout
maximize
chunk(["a", "b", "c", "d"], 2);
modifieddraft
chevron_left
chevron_right
chunk (
array:Array,
size:number?,
null-null
) : 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

null-null

{Object} [guard] Enables use as an iteratee for methods like _.map.

Returns
Array

Returns the new array of chunks.