Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

utilsac

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utilsac - npm Package Compare versions

Comparing version 12.2.2 to 12.2.5

88

deep.js

@@ -191,3 +191,3 @@ export {

* Determines whether two objects are equal. Works on nested structures.
* Work with all primitive types like Number, String, Big Int.
* Works with all primitive types like Number, String, Big Int.
* It also works when nested structure contains object and array

@@ -203,3 +203,7 @@ * @param {Object} a can be either an object or array

if (Array.isArray(a) && Array.isArray(b)) {
if (Array.isArray(a)) {
if (!Array.isArray(b)) {
return false;
}
if (a.length !== b.length) {

@@ -213,2 +217,7 @@ return false;

}
if (a.constructor !== b.constructor) {
return false;
}
if (isObject(a) && isObject(b)) {

@@ -228,21 +237,5 @@ const keysA = Object.keys(a);

const isObject = x => {
return typeof x === `object` && x !== null;
};
const validateArray = (a,b) => {
if (a === null && b === null) {
return false;
}
if (a.length !== b.length) {
return false;
}
return a.every((value, index) => {
return deepEqualAdded(value, b[index]);
});
};
/**
* Determines whether two objects are equal. Works on nested structures.
* Work with all primitive types like Number, String, Big Int.
* Works with all primitive types like Number, String, Big Int.
* It also Object, Array, Date and Regex

@@ -259,17 +252,31 @@ * It also works when nested structure contains object and array

if (a instanceof Date && b instanceof Date) {
return deepEqualAdded(a.getTime(), b.getTime());
if (a instanceof Date) {
if (!(b instanceof Date)) {
return false;
}
return (a.getTime() === b.getTime());
}
if (a instanceof RegExp && b instanceof RegExp) {
return new RegExp(a).toString() === new RegExp(b).toString();
if (a instanceof RegExp) {
if (!(b instanceof RegExp)) {
return false;
}
return String(a) === String(b);
}
if (Array.isArray(a) && Array.isArray(b)) {
if (Array.isArray(a)) {
if (!Array.isArray(b)) {
return false;
}
return validateArray(a, b);
}
if ((a instanceof Uint8Array && b instanceof Uint8Array)
|| (a instanceof Uint16Array && b instanceof Uint16Array)
|| (a instanceof Set && b instanceof Set)) {
if ((a instanceof Uint8Array) ||
(a instanceof Uint16Array) ||
(a instanceof Set)) {
if (!(b instanceof a.constructor)) {
return false;
}
const arr1 = Array.from(a);

@@ -280,10 +287,12 @@ const arr2 = Array.from(b);

if (a instanceof Map && b instanceof Map) {
const keysA = a.keys();
const keysB = b.keys();
if (a instanceof Map) {
if (!(b instanceof Map)) {
return false;
}
if (keysA.length !== keysB.length) {
if (a.size !== b.size) {
return false;
}
const keysA = a.keys();
for (const key of keysA) {

@@ -297,2 +306,6 @@ if (!b.has(key) || !deepEqualAdded(a.get(key), b.get(key))) {

if (a.constructor !== b.constructor) {
return false;
}
if (isObject(a) && isObject(b)) {

@@ -312,1 +325,14 @@ const keysA = Object.keys(a);

};
const isObject = x => {
return typeof x === `object` && x !== null;
};
const validateArray = (a,b) => {
if (a.length !== b.length) {
return false;
}
return a.every((value, index) => {
return deepEqualAdded(value, b[index]);
});
};

@@ -0,0 +0,0 @@ Creative Commons Legal Code

{
"name": "utilsac",
"version": "12.2.2",
"version": "12.2.5",
"description": "Utility functions",

@@ -5,0 +5,0 @@ "type": "module",

@@ -11,4 +11,5 @@ export {

const stringFromArrayBuffer = function (arrayBuffer, encoding = `utf-8`) {
return (new TextDecoder(encoding)).decode(arrayBuffer);
const textDecoder = new TextDecoder();
const stringFromArrayBuffer = function (arrayBuffer) {
return textDecoder.decode(arrayBuffer);
};

@@ -15,0 +16,0 @@

@@ -229,5 +229,5 @@ export {

const textEncoder = new TextEncoder();
const bytesLengthFromString = string => {
const textEncoder = new TextEncoder();
return textEncoder.encode(string).length;
};
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc