Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • npm
  • Socket score

Version published
Maintainers
1
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

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc