Gathering detailed insights and metrics for shallow-equal-object
Gathering detailed insights and metrics for shallow-equal-object
Gathering detailed insights and metrics for shallow-equal-object
Gathering detailed insights and metrics for shallow-equal-object
npm install shallow-equal-object
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
23 Stars
18 Commits
1 Forks
3 Watching
1 Branches
1 Contributors
Updated on 04 Feb 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
66%
3,802
Compared to previous day
Last week
58.1%
21,989
Compared to previous week
Last month
32.3%
66,935
Compared to previous month
Last year
-15.5%
648,673
Compared to previous year
Shallow equality check for objects.
Install with npm:
npm install shallow-equal-object
1const { shallowEqual } = require("shallow-equal-object"); 2shallowEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // => true 3shallowEqual({ a: 1, b: 2 }, { a: 1, b: 42 }); // => false 4shallowEqual({ a: 1, b: 2 }, { }); // => false
You can pass option object as 3rd arguments.
customEqual: (a:any, b:any) => boolean
1assert.ok(shallowEqual(base, { a: 1, b: 2 }, {
2 customEqual: (a, b) => {
3 return typeof a === "number" && typeof b === "number";
4 }
5}));
6assert.equal(shallowEqual({ a: "string" }, { a: "string" }, {
7 customEqual: (a, b) => {
8 return typeof a === "number" && typeof b === "number";
9 }
10}), false);
debug: boolean
Enable debug mode if { debug: true }
Debug mode show helpful log that why that result is false
.
1it("objectA is not object", () => {
2 shallowEqual(null, {}, {
3 debug: true,
4 console: consoleMock
5 });
6 assert.strictEqual(logCalls[0], "objectA is not object.");
7});
8it("objectB is not object", () => {
9 shallowEqual({}, null, {
10 debug: true,
11 console: consoleMock
12 });
13 assert.strictEqual(logCalls[0], "objectB is not object.");
14});
15it("object key length is not same", () => {
16 shallowEqual({}, { a: 1 }, {
17 debug: true,
18 console: consoleMock
19 });
20 assert.strictEqual(logCalls[0], "object key length is not same");
21});
22it("object value is not equal", () => {
23 shallowEqual({ a: 1 }, { a: 2 }, {
24 debug: true,
25 console: consoleMock
26 });
27 assert.strictEqual(logCalls[0], "key:a is not equals between A and B.");
28});
You can pass console
object to { debug: true, console: ConsoleAPI }
See Releases page.
Install devDependencies and Run npm test
:
npm i -d && npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT © azu
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/16 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
28 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Moreis-equal-shallow
Does a shallow comparison of two objects, returning false if the keys or values differ.
fast-shallow-equal
[![][npm-badge]][npm-url] [![][travis-badge]][travis-url]
enzyme-shallow-equal
Adaptation of react-addons-shallow-compare, for independent usage
@wordpress/is-shallow-equal
Test for shallow equality between two objects or arrays.