just-split
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

just-split

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-split
yarn add just-split

Splits array into groups of n items each

import split from 'just-split';

split([]); // []
split([1, 2, 3, 4, 5]); // [[1, 2, 3, 4, 5]]
split([1, 2, 3, 4, 5, 6, 7, 8, 9], 3); // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
split([1, 2, 3, 4, 5, 6, 7, 8, 9], '3'); // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
split(['a', 'b', 'c', 'd', 'e'], 2); // [['a', 'b'], ['c', 'd'], ['e']]
split([1, 2, 3, 4, 5, 6, 7, 8], 3); // [[1, 2, 3], [4, 5, 6], [7, 8]]

/just-split/

    Package Sidebar

    Install

    npm i just-split

    Weekly Downloads

    6,003

    Version

    3.2.0

    License

    MIT

    Unpacked Size

    6.33 kB

    Total Files

    9

    Last publish

    Collaborators

    • angus-c