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

immutable

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable

Immutable Data Collections

  • 3.7.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21M
increased by9.5%
Maintainers
1
Weekly downloads
 
Created

What is immutable?

The immutable npm package provides persistent immutable data structures that do not change once created, enabling advanced memoization, change detection, and functional programming techniques. It offers a variety of data structures such as List, Map, Set, and Record.

What are immutable's main functionalities?

Persistent Immutable List

Create and manipulate immutable lists, where modifications return new lists without altering the original.

const { List } = require('immutable');
const list1 = List([1, 2, 3]);
const list2 = list1.push(4);
console.log(list1.size); // 3
console.log(list2.size); // 4

Persistent Immutable Map

Create and manipulate immutable maps, with key-value pairs. Changes produce new maps without changing the original.

const { Map } = require('immutable');
const map1 = Map({ a: 1, b: 2, c: 3 });
const map2 = map1.set('b', 50);
console.log(map1.get('b')); // 2
console.log(map2.get('b')); // 50

Persistent Immutable Set

Create and manipulate immutable sets, which are collections of unique values. Adding existing values does not change the set.

const { Set } = require('immutable');
const set1 = Set([1, 2, 3]);
const set2 = set1.add(3).add(4);
console.log(set1.has(3)); // true
console.log(set2.has(4)); // true

Record Factory

Define 'Record' factories to create immutable records with default values and specific shapes.

const { Record } = require('immutable');
const Person = Record({ name: null, age: null });
const person1 = new Person({ name: 'Alice', age: 30 });
const person2 = person1.set('name', 'Bob');
console.log(person1.name); // Alice
console.log(person2.name); // Bob

Other packages similar to immutable

Keywords

FAQs

Package last updated on 16 Dec 2015

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