Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kavalcante/array-into-subarrays
A non destructive and simple function that divide an array into multiples subarrays
https://github.com/kavalcante/array-into-subarrays
function functional-programming javascript nodejs npm
Last synced: 6 days ago
JSON representation
A non destructive and simple function that divide an array into multiples subarrays
- Host: GitHub
- URL: https://github.com/kavalcante/array-into-subarrays
- Owner: kavalcante
- License: mit
- Created: 2017-04-20T03:21:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-03T20:42:41.000Z (almost 7 years ago)
- Last Synced: 2024-10-11T19:52:50.791Z (about 1 month ago)
- Topics: function, functional-programming, javascript, nodejs, npm
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Array into Subarrays
[![Build Status](https://travis-ci.org/kavalcante/array-into-subarrays.svg?branch=master)](https://travis-ci.org/kavalcante/array-into-subarrays)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/kavalcante/array-into-subarrays/master/LICENSE)
[![npm version](https://badge.fury.io/js/array-into-subarrays.svg)](https://badge.fury.io/js/array-into-subarrays)Insert a array list and receive a new list (non destructive) with groups of elements (subarrays).
### Installing
```
$ npm install array-into-subarrays --save
```### Usage
```js
import arrayIntoSubarrays from 'array-into-subarrays';
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9] // could be any data, and how much indexes do you want.
arrayIntoSubarrays(array, 4) // => [[1, 2, 3, 4], [5, 6, 7, 8], [9]];
// you can invoke the function in any part of your code, because is a non destructive function
```
## Attributes
| Option | Default | Type | Description |
| :------------ | :------------ | :----- | :--------- |
| __array__ | no default value | array | Array that will be divided. |
| __limit__ | 4 | number | Length of subarrays. |## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
## Acknowledgments
* [copy from Stack Overflow answear](http://stackoverflow.com/questions/11318680/split-array-into-chunks-of-n-length)