You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

immutable-splice

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-splice

Immutable splice function for arrays and strings.

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
12
-61.29%
Maintainers
1
Weekly downloads
 
Created
Source

immutable-splice

Changes the contents of an array or string by removing or replacing existing elements and/or adding new elements.

Based off the Array.prototype.splice() method—but immutable.

Usage

splice(input, start)
splice(input, start, deleteCount)
splice(input, start, deleteCount, item1, item2, ...)

Parameters

  • input the Array or String to splice.

  • start Number index at which to start changing the input.

  • deleteCount optional Number of elements in the array to remove from start.

    If deleteCount is omitted, then all the elements from start to the end of the input will be deleted.

  • item1, item2, ... optional elements to add to the input, beginning from start.

Return value

A new Array or String containing the changes made.

Examples

import splice from 'immutable-splice';

splice(['foo', 'bar', 'baz'], 1, 1);
// returns ['foo', 'baz']

splice('cool', 1, 2, '0', 'O');
// returns 'c0Ol'

Keywords

add

FAQs

Package last updated on 14 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.