This package help you to compare two objects. Built in typescript. Zero depedencies
console.log(deepCompare({ foo: "bar" }, { foo: "bar" })); // true
console.log(deepCompare({ foo: "bar" }, { foo: 2 })); // false
console.log(
deepCompare(
{
a: "something",
b: { a: "something", c: { arr: [1, 2, 3] } },
c: {
a: "something",
b: {
a: "something",
c: { bool: false },
d: { a: "something", b: { a: "something", c: { bool: false } } },
},
},
},
{
a: "something",
b: { a: "something", c: { arr: [1, 2, 3] } },
c: {
a: "something",
b: {
a: "something",
c: { bool: false },
d: { a: "something", b: { a: "something", c: { bool: false } } },
},
},
}
)
); // true
Using npm:
$ npm install simple-deepcompare
Using pnpm:
$ pnpm install simple-deepcompare
in Node JS:
const deepCompare = require("simple-deepcompare").deepCompare;
console.log(deepCompare({ foo: "bar" }, { foo: "bar" })); // true
in Browser:
import { deepCompare } from "simple-deepcompare";
console.log(deepCompare({ foo: "bar" }, { foo: "bar" })); // true
MIT © Azharie Muhammad