Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steadicat/mutatis
A lightweight immutability library compatible with JS built-in collections.
https://github.com/steadicat/mutatis
Last synced: 8 days ago
JSON representation
A lightweight immutability library compatible with JS built-in collections.
- Host: GitHub
- URL: https://github.com/steadicat/mutatis
- Owner: steadicat
- Created: 2015-08-23T23:45:09.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-30T03:09:25.000Z (over 8 years ago)
- Last Synced: 2024-10-29T07:51:20.060Z (17 days ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mutatis
A lightweight immutability library.
> Mutatis mutandis is a Medieval Latin phrase meaning “the necessary changes having been made” or “once the necessary changes have been made”.
Like [immutable](https://facebook.github.io/immutable-js/), but compatible with standard JS data structures, and with ~50Kb less code (minified).
Like [seamless-immutable](https://github.com/rtfeldman/seamless-immutable), but with the nice mutability helpers.
Like the [React Immutability helpers](https://facebook.github.io/react/docs/update.html), but without the weird MongoDB-inspired syntax.
## Usage
```js
import mutatis from 'mutatis';const x = mutatis({a: 12, b: [23, 56]});
mutatis.size; // 2
mutatis.a = 78; // Throwsconst y = x.set('c', {d: {e: 'string'});
// {a: 12, b: [23, 56], c: {d: {e: 'string'}}};const z = y
.setIn(['c', 'd', 'f'], 'another string')
.update('b', l => l.concat(78));
// {a: 12, b: [23, 56, 78], c: {d: {e: 'string', f: 'another string'}}};const a = mutatis([12, 34]);
a.push(56); // Throws
```