array-chop
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Array-Chop

npm GitHub PRs Welcome tylim88

🐤 Split an array into arrays of a specific length.

✍️ Written in ES6️⃣ and compiled to ES5️⃣.

🦺 Tested.

⛲️ Out of box typescript support.

Installation

npm i array-chop

Usage

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, 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.

Package Sidebar

Install

npm i array-chop

Weekly Downloads

284

Version

1.0.1

License

MIT

Unpacked Size

6.89 kB

Total Files

6

Last publish

Collaborators

  • tylim