// npm i diff
const Diff = require('diff') // 注意不能用import
const str = Diff.diffChars('aa', 'abb')
const json = Diff.diffJson({a: 1, b: 2}, {a: 1, b: 3})
const arr = Diff.diffJson([{a: 1, b: 2}], [{a: 1, c: 3}])
console.log('str==>', str) // 输出一个数组描述从aa到abb过程
console.log('json==>', json)
console.log('arr==>', arr)
- 本文作者: MrRetro博客
- 本文链接: http://mrretro.gitee.io/retroblog/retroblog/2022/07/17/diffjs的使用/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!