Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/component/in-groups-of

Split an array into groups of N
https://github.com/component/in-groups-of

Last synced: 13 days ago
JSON representation

Split an array into groups of N

Awesome Lists containing this project

README

        

# in-groups-of

Return an array of arrays in groups of N

## Installation

```
$ component install component/in-groups-of
```

## Example

```js
var nums = [1,2,3,4,5,6,7,8,9,10];

inGroupsOf(nums, 5)
// => [[1,2,3,4,5], [6,7,8,9,10]]

inGroupsOf(nums, 4)
// => [[1,2,3,4], [5,6,7,8], [9,10]]

inGroupsOf(nums, 2)
//=> [[1,2], [3,4], [5,6], [7,8], [9,10]]
```

# License

MIT