1.0.3 • Published 2 years ago

cmprx-value v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago