@f/splice
v1.0.0
Published
Immutable splice
Downloads
127
Readme
splice
Immutable splice.
Installation
$ npm install @f/splice
Usage
var splice = require('@f/splice')
splice([1, 2, 3], 1, 1) // -> [1, 3]
splice([1, 2, 3], 1, 1, 5), // -> [1, 5, 3]
splice([1, 2, 3], 0, 1, 5), // -> [5, 2, 3]
API
splice(arr, idx, deleteCount, ...items)
arr
- The array you want to spliceidx
- The position in the array to begin removing/inserting itemsdeleteCount
- The number of items to remove at positionidx
...items
- Optional list of items to insert at positionidx
Returns: A new array with the desired changes.
License
MIT