limu
更快更好用的不可变数据js库

默认不冻结,大多数场景下都要比immer快3到5倍或更多


更强的隐藏式代理机制,让用户像查看原生数据一样查看草稿数据任意节点

默认支持Map、Set,兼容immer大部分接口,gzip后4.3kb

12import * as limu from 'limu';3// ---------------- 以下代码可复制到console运行(window全局已绑定limu对象)----------------45const { produce } = limu;6const baseState = {7 a: 1,8 b: [ 1, 2, 3 ],9 c: {10 c1: { n: 1 },11 c2: { m: 2 },12 }13};14const nextState = produce(baseState, (draft)=>{15 draft.a = 2;16 draft.b['2'] = 100;17});1819console.log(nextState === baseState); // false20console.log(nextState.a === baseState.a); // false21console.log(nextState.b === baseState.b); // false22console.log(nextState.c === baseState.c); // true2324// Currying call25const producer = produce((draft)=>{26 draft.a = 2;27 draft.b['2'] = 100;28});29const nextState = producer(baseState);30