Skip to content

使用 Array.slice 结果出现问题 #15

@LiChangyi

Description

@LiChangyi

参考一下代码:

import { produce } from 'limu';

let data2 = {
  history: Array.from({ length: 10 }).map(() => ({
    list: Array.from({ length: 10000 }).map((_, i) => ({
      id: i,
    })),
  })),
}

const start = Date.now();
const newData = produce(data2, draft => {
  draft.history = draft.history.slice(1);
})
console.log('slice', Date.now() - start, 'ms', newData);

输出:
slice 1 ms { history: [ ] }

输出保留了 proxy 状态,导致后续使用数据时出现问题。

出问题版本:
^4.1.1

在 3.13.2 版本中未出现问题,但是在 3.13.2 中对于大对象有性能问题,上述脚本耗时: 1220 ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions