This diff object would then allow you to mutate the base object to the target object.
$ npm install diff-immutability-helper --save
;const base =a: 1 2 b: 1 4 5 6b: 'test'c: 'prev';const target =a: 1 2 b: 2 4 6b: 'test 2'd: 'new';const change = ;
will give a result of:
const change =a:$splice: 4 1 2 1 b: 2b: $set: 'test 2'$$merge:d: 'new'
thus, we can then do:
;; // to match target
- Array diffing uses LCS
- Only CommonJS format (for node.js) is provided. This is to minimize library size when you bundle with your application.
diff-immutability-helper is MIT licensed