list-diff
list-diff copied to clipboard
有case跑不过
var diff = require("list-diff2")
var oldList = [{id: "a"}, {id: "b"}, {id: "c"}, {id: "d"}, {id: "e"}]
var newList = [{id: "b"}, {id: "f"}, {id: "c"}, {id: "d"}, {id: "1"}]
var moves = diff(oldList, newList, "id")
console.log(JSON.stringify(moves))
打印结果如下
{"moves":[{"index":0,"type":0},{"index":3,"type":0},{"index":1,"item":{"id":"f"},"type":1},{"index":4,"item":{"id":"1"},"type":1}],"children":[null,{"id":"b"},{"id":"c"},{"id":"d"},null]}
{'index':3, type: 0}这块应该是{'index':4, type: 0}