1.0.3 • Published 3 years ago
@franciscomcg/chunklify v1.0.3
@franciscomcg/chunklify 🍰
An utility function that returns an array in chunks
Table of Contents
About the project
Chunklify is a JavaScript utility function that returns an array in chunks of a given size
Installation
You should install this package in your devDependecies via npm or yarn:
npm i --save-dev @franciscomcg/chunklify
or
yarn add -D @franciscomcg/chunklify
Usage
Import chunklify to your project
import chunklify from '@franciscomcg/chunklify';
or
const chunklify = require('@franciscomcg/chunklify');
Call the function with an array and the size of the chunks
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
const chunked = chunklify(arr, 5);
// [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11]]
Local development
For local development, please follow the below steps:
- Clone the repository
git clone https://github.com/FranciscoMCG/chunklify.git
- Access the project folder
cd chunklify
- Install dependencies
npm install
- To run tests use the following script
npm run test