https://github.com/reactgular/chunks
Creates an array of elements split into groups the length of size.
https://github.com/reactgular/chunks
array arrays chunk chunks javascript javascript-library typescript typescript-library
Last synced: 10 months ago
JSON representation
Creates an array of elements split into groups the length of size.
- Host: GitHub
- URL: https://github.com/reactgular/chunks
- Owner: reactgular
- License: mit
- Created: 2020-03-06T13:11:41.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-11T13:23:05.000Z (almost 6 years ago)
- Last Synced: 2024-04-24T21:02:09.213Z (over 1 year ago)
- Topics: array, arrays, chunk, chunks, javascript, javascript-library, typescript, typescript-library
- Language: TypeScript
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/reactgular/chunks)
[](https://coveralls.io/github/reactgular/chunks?branch=master)
[](https://badge.fury.io/js/%40reactgular%2Fchunks)
## What is Chunks?
Chunks is a TypeScript library that creates an array of elements split into groups the length of size. If the array can't be split evenly, the
final chunk can be optionally padded with a default value.
## Installation
To get started, install the package from npm.
```bash
npm install --save @reactgular/chunks
```
## Usage
Chunks is small, simple and easy to use.
```typescript
import {chunks} from '@reactgular/chunks';
console.log(chunks([1,2,3,4,5],2))
// => [[1,2],[3,4],[5]]
console.log(chunks([1,2,3,4,5],2,undefined))
// => [[1,2],[3,4],[5,undefined]]
```
# Getting help
You are welcome to open issues for general support questions as well as bug reports and feature requests.