lightweight and very fast package for mutating POJO


(Linq2js) #1

Hello you guys, let me introduce about new immutable js lib, it called immhelper

This is lightweight and very fast package for mutating POJO

Benchmarks (Fastest to Slowest)
Normal
Object.assign: Total elapsed = 107 ms (read) + 2578 ms (write) = 2685 ms
immhelper: Total elapsed = 74 ms (read) + 3283 ms (write) = 3357 ms
immutable-assign: Total elapsed = 88 ms (read) + 3970 ms (write) = 4058 ms
immer: Total elapsed = 71 ms (read) + 6883 ms (write) = 6954 ms
seamless-immutable: Total elapsed = 88 ms (read) + 50166 ms (write) = 50254 ms
immutability-helper: Total elapsed = 80 ms (read) + 64408 ms (write) = 64488 ms

1.3x Slower than Object.assign
1.1x Faster than immutable-assign
2x Faster than immer
16x Faster than seamless-immutable
19x Faster than immutability-helper

Syntaxes
It supports many coding styles
const obj = { a: { b: { c: [] } } };

  1. Basic syntax, using object tree as specs
    update(obj, { ‘a.b.c’: [‘push’, 10] });

  2. Using selector and modifier
    updatePath(obj, [x => x.a.b.c, ‘push’, 10]);

  3. Simplest
    updatePath(obj, x => x.a.b.c.push(10));

Please leave comment if you feel interest