https://github.com/tylim88/array-chop
🍰 Split an array into arrays of a specific length
https://github.com/tylim88/array-chop
Last synced: about 1 month ago
JSON representation
🍰 Split an array into arrays of a specific length
- Host: GitHub
- URL: https://github.com/tylim88/array-chop
- Owner: tylim88
- License: mit
- Created: 2020-07-28T07:19:06.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T17:05:51.000Z (over 2 years ago)
- Last Synced: 2025-03-15T14:17:59.435Z (2 months ago)
- Language: TypeScript
- Size: 1.17 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Array-Chop
[](https://www.npmjs.com/package/array-chop) [](https://github.com/tylim88/array-chop/blob/master/LICENSE) [](https://github.com/tylim88/array-chop/pulls) [](<[LINK](https://github.com/tylim88/array-chop#array-chop)>)
🐤 Split an array into arrays of a specific length.
✍️ Written in ES6️⃣ and compiled to ES5️⃣.
🦺 Tested.
⛲️ Out of box typescript support.
## Installation
```bash
npm i array-chop
```## Usage
```js
import chopArray from 'array-chop'chopArray(['a', 'b', 'c', 'd', 'e', 'f'], 2)
//=> [['a', 'b'], ['c', 'd'], ['e', 'f']]chopArray(['a', 'b', 'c', 'd', 'e', 'f', 'foo'], 3)
//=> [['a', 'b', 'c'], ['d', 'e', 'f'], ['foo']]
```## Acknowledgement
This code repository is replicate of [split-array](https://www.npmjs.com/package/split-array), the core logic, test remain exactly the same. The purpose of this package is to add Typescript support (after failing to contact the original author) and rewrite it with ES6 and Jest.