We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
my code
// config const instance = create({ objectHash(obj, index) { if (typeof obj._id !== 'undefined') { return obj._id; } if (typeof obj.id !== 'undefined') { return obj.id; } if (typeof obj.name !== 'undefined') { return obj.name; } return `$$index:${index}`; }, cloneDiffValues: true, arrays: { // default true, detect items moved inside the array // (otherwise they will be registered as remove+add) detectMove: true, // default false, the value of items moved is not included in deltas includeValueOnMove: false, }, }); const comps = [ { id: 1, style: { zIndex: 1 } }, { id: 2, style: { zIndex: 2 } }, { id: 3, style: { zIndex: 3 } }, { id: 4, style: { zIndex: 4 } }, { id: 5, style: { zIndex: 5 } }, { id: 6, style: { zIndex: 6 } }, { id: 7, style: { zIndex: 7 } }, { id: 8, style: { zIndex: 8 } }, { id: 9, style: { zIndex: 9 } }, ]; const orderedComps = [ { id: 7, style: { zIndex: 1 } }, { id: 8, style: { zIndex: 2 } }, { id: 9, style: { zIndex: 3 } }, { id: 1, style: { zIndex: 4 } }, { id: 2, style: { zIndex: 5 } }, { id: 3, style: { zIndex: 6 } }, { id: 4, style: { zIndex: 7 } }, { id: 5, style: { zIndex: 8 } }, { id: 6, style: { zIndex: 9 } }, ]; const delta = instance.diff(comps, orderedComps); const undoComps = instance.unpatch(orderedComps, delta); console.log('isEq', isEqual(undoComps, comps), undoComps)
result
isEq false [ {"id":1,"style":{"zIndex":4}}, {"id":2,"style":{"zIndex":1}}, {"id":3,"style":{"zIndex":3}}, {"id":4,"style":{"zIndex":4}}, {"id":5,"style":{"zIndex":8}}, {"id":6,"style":{"zIndex":5}}, {"id":7,"style":{"zIndex":7}}, {"id":8,"style":{"zIndex":6}}, {"id":9,"style":{"zIndex":9}} ]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
my code
result
The text was updated successfully, but these errors were encountered: