https://github.com/cdrani/arr-chunk
chunk arrays with option of removing any that do not conform to the size you want
https://github.com/cdrani/arr-chunk
Last synced: 5 months ago
JSON representation
chunk arrays with option of removing any that do not conform to the size you want
- Host: GitHub
- URL: https://github.com/cdrani/arr-chunk
- Owner: cdrani
- License: mit
- Created: 2017-12-26T06:33:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T23:03:12.000Z (over 3 years ago)
- Last Synced: 2025-09-22T14:52:57.838Z (9 months ago)
- Language: JavaScript
- Size: 455 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# arr-chunk [](https://travis-ci.org/cdrani/arr-chunk)
## install
> npm install arr-chunk
or
> yarn add arr-chunk
## usage
> chunk(arr, size = 2, clear = false)
**arr :: Array** : An array. Required.
**size :: Int** : Size of the array chunks. Default is 2.
**clear :: Boolean** : If **true**, chunks with less elements than the specified size are *removed*. Default is **false**.
**defaults**
```js
const chunk = require('arr-chunk')
const arr = [111, 89, 13, 678, 78]
const chunked = chunk(arr)
// chunked -> [[111, 89], [13, 678], [78]]
```
**options**
```js
const chunk = require('arr-chunk')
const arr = [111, 89, 13, 678, 98, 123, 324, 56, 23, 987]
const chunked = chunk(arr, 4, true)
// chunked -> [[111, 89, 13, 678], [98, 123, 324, 56]]
```
## license
mit © | cdrani