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

3.2.0 • Public • Published

just-insert

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-insert
yarn add just-insert

Inserts a sub-array into an array starting at the given index. Returns a copy

import insert from 'just-insert';

insert([1, 2, 5, 6], ['a', 'c', 'e'], 2); // [1, 2, 'a', 'c', 'e', 5, 6]
insert([1, 2, 5, 6], 'a', 2); // [1, 2, 'a', 5, 6]
insert([1, 2, 5, 6], ['a', 'c', 'e'], 0); // ['a', 'c', 'e', 1, 2, 5, 6]
insert([1, 2, 5, 6], ['a', 'c', 'e']); // ['a', 'c', 'e', 1, 2, 5, 6]

Package Sidebar

Install

npm i just-insert

Weekly Downloads

79

Version

3.2.0

License

MIT

Unpacked Size

5.92 kB

Total Files

9

Last publish

Collaborators

  • angus-c