immutadot
A JavaScript library to deal with nested immutable structures.
set({ english: { greeting: 'Hi' } }, 'english.greeting', 'Hello')
// → { english: { greeting: 'Hello' } }
push({ i18n: { languages: ['English', 'French'] } }, 'i18n.languages', 'German', 'Spanish')
// → { i18n: { languages: ['English', 'French', 'German', 'Spanish'] } }
immutadot gives you a short and meaningful syntax to apply operations on immutable structures.
Installation
immutadot is available on npm repository.
using yarn:
$ yarn add immutadot
using npm:
$ npm install immutadot
Usage
ES modules:
import { set } from 'immutadot'
CommonJS:
const { set } = require('immutadot')
Try it
const { set } = require('immutadot')
const animals = { weasels: { lutraLutra: { commonNames: ['eurasian otter'], }, }, }
const newAnimals = set(animals, 'weasels.lutraLutra.name', 'Lutrinae')
Getting started
A fast overview of immutadot's features is available in the Getting started guide.