@f/splice

Immutable splice

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/splice
101.0.06 years ago6 years agoMinified + gzip package size for @f/splice in KB

Readme

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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.