🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@rainbowatcher/js-utils

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rainbowatcher/js-utils - npm Package Compare versions

Comparing version
0.0.7
to
0.0.8
+27
-0
dist/index.cjs

@@ -24,2 +24,28 @@ 'use strict';

}
function isDeepEquals(first, second, keys) {
if (!first || !second) {
return first === second;
}
if (typeof first !== "object" || typeof second !== "object") {
return first === second;
}
if (Array.isArray(first) && Array.isArray(second)) {
if (first.length !== second.length) {
return false;
} else {
return first.every((item, index) => isDeepEquals(item, second[index]));
}
}
const keys1 = keys ?? Object.keys(first);
const keys2 = keys ?? Object.keys(second);
if (keys1.length !== keys2.length) {
return false;
}
for (const key of keys1) {
if (!keys2.includes(key) || !isDeepEquals(first[key], second[key])) {
return false;
}
}
return true;
}

@@ -58,2 +84,3 @@ function isString(obj) {

exports.isAsyncFunction = isAsyncFunction;
exports.isDeepEquals = isDeepEquals;
exports.isUndefined = isUndefined;
+2
-1

@@ -40,3 +40,4 @@ declare function isEmpty$1<T>(arrayLike: ArrayLike<T> | undefined): boolean;

declare function isAsyncFunction(fn?: (...args: any) => any): boolean;
declare function isDeepEquals(first: any, second: any, keys?: string[]): boolean;
export { lists as Lists, str as Strings, isAsyncFunction, isUndefined };
export { lists as Lists, str as Strings, isAsyncFunction, isDeepEquals, isUndefined };

@@ -22,2 +22,28 @@ function isEmpty$1(arrayLike) {

}
function isDeepEquals(first, second, keys) {
if (!first || !second) {
return first === second;
}
if (typeof first !== "object" || typeof second !== "object") {
return first === second;
}
if (Array.isArray(first) && Array.isArray(second)) {
if (first.length !== second.length) {
return false;
} else {
return first.every((item, index) => isDeepEquals(item, second[index]));
}
}
const keys1 = keys ?? Object.keys(first);
const keys2 = keys ?? Object.keys(second);
if (keys1.length !== keys2.length) {
return false;
}
for (const key of keys1) {
if (!keys2.includes(key) || !isDeepEquals(first[key], second[key])) {
return false;
}
}
return true;
}

@@ -53,2 +79,2 @@ function isString(obj) {

export { lists as Lists, str as Strings, isAsyncFunction, isUndefined };
export { lists as Lists, str as Strings, isAsyncFunction, isDeepEquals, isUndefined };
{
"name": "@rainbowatcher/js-utils",
"version": "0.0.7",
"version": "0.0.8",
"description": "Opinionated collection of common JavaScript / TypeScript utils by @rainbowatcher",

@@ -35,12 +35,12 @@ "author": "rainbowatcher <rainbow-w@qq.com>",

"@commitlint/types": "^17.4.4",
"@rainbowatcher/eslint-config-json": "^0.2.4",
"@rainbowatcher/eslint-config-ts": "^0.2.4",
"changelogen": "^0.5.3",
"commitlint": "^17.6.6",
"eslint": "^8.43.0",
"lint-staged": "^13.2.2",
"simple-git-hooks": "^2.8.1",
"typescript": "^5.1.3",
"@rainbowatcher/eslint-config-json": "^0.3.0",
"@rainbowatcher/eslint-config-ts": "^0.3.0",
"changelogen": "^0.5.4",
"commitlint": "^17.6.7",
"eslint": "^8.45.0",
"lint-staged": "^13.2.3",
"simple-git-hooks": "^2.9.0",
"typescript": "^5.1.6",
"unbuild": "^1.2.1",
"vitest": "^0.32.2"
"vitest": "^0.33.0"
},

@@ -47,0 +47,0 @@ "simple-git-hooks": {