Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ximing/fast-data-diff
小程序高性能setData diff算法
https://github.com/ximing/fast-data-diff
Last synced: 14 days ago
JSON representation
小程序高性能setData diff算法
- Host: GitHub
- URL: https://github.com/ximing/fast-data-diff
- Owner: ximing
- Created: 2020-03-16T08:23:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-25T09:09:42.000Z (10 months ago)
- Last Synced: 2024-04-26T19:48:08.372Z (6 months ago)
- Language: TypeScript
- Size: 244 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![build workflow](https://github.com/ximing/fast-data-diff/actions/workflows/build.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/ximing/fast-data-diff/badge.svg?branch=master)](https://coveralls.io/github/ximing/fast-data-diff?branch=master)
![NPM](https://img.shields.io/npm/l/fast-data-diff?style=flat-square)
![npm bundle size](https://img.shields.io/bundlephobia/min/fast-data-diff?style=flat-square)### 使用
```javascript
import { diff } from 'fast-data-diff';
this.setData(diff(newobj, oldobj));
```### diff 算法设计思路
- 深度优先遍历
- 只对同层节点进行对比
- 使用数据路径方式实现局部更新
- 尽可能减少不必要的 diff 对比### TODO
- [ ] 支持 immer 快速更改 data
- [ ] 支持 observer 流形式监听