Package Exports
- microdiff
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (microdiff) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Microdiff
Microdiff is a tiny (currently <1kb), fast, zero dependency object and array comparison library. It is significantly faster than most other deep comparison libraries, and has full TypeScript support.
Get started
First, install Microdiff
npm i microdiff
Then, simply import it and run it on two objects.
import diff from "microdiff";
const obj1 = {
originalProperty: true,
};
const obj2 = {
originalProperty: true,
newProperty: "new",
};
console.log(diff(obj1, obj2));
// [{type: "CREATE", path: ["newProperty"], value: "new"}]
There are three different types of changes. CREATE
, REMOVE
, and CHANGE
. The path
property gives a path to the property in the new object (or the old object in the case of REMOVE
). Each element in the array is a key to the next property a level deeper until you get to the property changed. The value
property exists in types CREATE
and CHANGE
, and it contains the value of the property added/changed.