@f/splice

1.0.0 • Public • Published

splice

Build status Git tag NPM version Code style

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 splice
  • idx - The position in the array to begin removing/inserting items
  • deleteCount - The number of items to remove at position idx
  • ...items - Optional list of items to insert at position idx

Returns: A new array with the desired changes.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @f/splice

Weekly Downloads

36

Version

1.0.0

License

MIT

Last publish

Collaborators

  • f