cmprx-value
v1.0.3
Published
Compare objects by value
Downloads
3
Readme
cmprx-value - Compare objects by Value
This package perform a comparation between two objects and returns true if whole object is equal to another object or false otherwise.
Install
npm i cmprx-value
Use
You can use this package to compare two objects and it returns "true" if they are equal and "false" otherwise.
import compareValue from "cmprx-value";
let obj1 = {x: 2, y: 4, a: {b: 5, c: 6, d: {ff: 2, gg: 3}}, z: 10, i: 1};
let obj2 = {x: 2, y: 4, a: {b: 5, c: 6, d: {ff: 2, gg: 3}}, z: 10, i: 1};
console.log(compareValue(obj1, obj2)); // true
console.log(compareValue({x: 1, y: 4}, {x: 1, y: 4})); // true
console.log(compareValue(['a', 'b'], ['a', 'b'])); // true
console.log(compareValue([1, 2, 3, 4], [1, 2, 3, 5])); // false
console.log(compareValue({x: 1, y: 4, i: 1}, {x: 1, y: 4, i: 2})); // false
console.log(compareValue({x: 1, y: 4, i: 1}, {x: 1, y: 4, i: 2})); // false
Test
npm run test
Note
Change to "type": "module" en package.json