1.0.0 • Published 4 years ago

twig-education v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Array Grouper

Array Grouper splits a given array of numbers into N smaller arrays where the length of the array and N are both positive integers.

Installation

Clone this repository and run the following script via the command line from within the repo.

npm i

Test

From within the repo run the following scripts to run or watch tests.

run

npm run test

watch

npm run watch test

Usage

In order to use this array grouper, simply import the ArrayGrouper class and call groupArrayElements as shown below.

import { ArrayGrouper } from "../relative-path";
let arrayGrouper = new ArrayGrouper();

var result = arrayGrouper.groupArrayElements([1, 2, 3, 4, 5], 3);
//result = [1, 2],[3, 4],[5]