tnfe / limu

High performance immutable lib alternative to immer with the same api, based on shallow copy on read and mark modified on write mechanism.
https://tnfe.github.io/limu
MIT License
220 stars 14 forks source link

【bug】内部重赋值引用,finish后数据有丢失 #8

Closed fantasticsoul closed 1 year ago

fantasticsoul commented 1 year ago

代码如下( 可访问 https://tnfe.github.io/limu/ 打开console复制并回车运行 )

// const { createDraft, finishDraft } = immer; // immer 结果ok
const { createDraft, finishDraft } = limu; // limu 结果不正常

const base = {
    list: [ {name:1}, {name:2} ],
    map: {},
};
const draft = createDraft(base, { onOperate: console.log });
const map = {};
draft.list.forEach(item=>{
    map[item.name] = item;
});
draft.map = map;
const final = finishDraft(draft);

console.log('base', base);
console.log('final', final);

limu 结果: image

immer 结果: image

fantasticsoul commented 1 year ago

已修复,见版本 3.7.0