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

3.2.0 • Public • Published

just-split-at

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-at
yarn add just-split-at

Splits an array into two at a given position

import splitAt from 'just-split-at';

splitAt([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4, 5]]
splitAt([{a: 1}, {b: 1}, {c: 1}], -1); // [[{a: 1}, {b: 1}], [{c: 1}]]
splitAt([], 2); // [[], []]
splitAt(null, 1); // throws
splitAt(undefined, 1); // throws

Package Sidebar

Install

npm i just-split-at

Weekly Downloads

6

Version

3.2.0

License

MIT

Unpacked Size

4.78 kB

Total Files

9

Last publish

Collaborators

  • angus-c