Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/component/in-groups-of
- Owner: component
- Created: 2012-09-11T00:32:35.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-10-09T23:30:58.000Z (about 11 years ago)
- Last Synced: 2024-05-08T17:11:27.314Z (8 months ago)
- Language: JavaScript
- Size: 108 KB
- Stars: 5
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
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