Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

immutable-lib

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-lib

Immutable helpers for arrays

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Immutable Array Helper

A JavaScript Library for immutable array helpers

How to use

import { copy } from "immutable-lib";

const a = [1, 2, 3];
const b = copy(a);

console.log(b); // [1, 2, 3]

Functions

copy()

Copies an array to a new variable.

import { copy } from "immutable-lib";

const a = [1, 2, 3];
const b = copy(a);

console.log(b); // [1, 2, 3]

del()

Creates a new array minus given array item.

import { del } from "immutable-lib";

const a = [1, 2, 3];
const b = del(a, 1);

console.log(b); // [1, 3]

pop()

Removes the last item from the array.

import { del } from "immutable-lib";

const a = [1, 2, 3];
const b = pop(a);

console.log(b); // [1, 2]

push()

Adds a new item at the end of an array.

import { push } from "immutable-lib";

const a = [1, 2, 3];
const b = push(a, 4);

console.log(b); // [1, 2, 3, 4]

reverse()

Reverses the order of an array.

import { reverse } from "immutable-lib";

const a = [1, 2, 3];
const b = reverse(a);

console.log(b); // [3, 2, 1]

shift()

Removes an item from the beginning of an array.

import { shift } from "immutable-lib";

const a = [1, 2, 3];
const b = shift(a);

console.log(b); // [2, 3]

sort()

Sorts an array.

import { sort } from "immutable-lib";

const a = [1, 2, 3];
const b = sort(a, (x, y) => y - x);

console.log(b); // [3, 2, 1]

splice()

Modifies the contents of an array.

import { splice } from "immutable-lib";

const a = [1, 2, 3];
const b = splice(a, 2, 2, [7, 8]);

console.log(b); // [1, 2, [7, 8], 5, 6]

unshift()

Adds an item from the beginning of an array.

import { sort } from "immutable-lib";

const a = [1, 2, 3];
const b = unshift(a, 4);

console.log(b); // [4, 1, 2, 3]

Keywords

FAQs

Package last updated on 04 Nov 2019

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