1.0.3 • Published 3 years ago

@franciscomcg/chunklify v1.0.3

Weekly downloads
9
License
ISC
Repository
github
Last release
3 years ago

@franciscomcg/chunklify 🍰

An utility function that returns an array in chunks

version size

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:

  1. Clone the repository
git clone https://github.com/FranciscoMCG/chunklify.git
  1. Access the project folder
cd chunklify
  1. Install dependencies
npm install
  1. To run tests use the following script
npm run test