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

@augment-vir/common

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@augment-vir/common - npm Package Compare versions

Comparing version 13.2.3 to 13.2.4

25

dist/cjs/augments/object/object.js

@@ -5,3 +5,2 @@ "use strict";

const error_1 = require("../error");
const object_entries_1 = require("./object-entries");
function isObject(input) {

@@ -11,2 +10,6 @@ return !!input && typeof input === 'object';

exports.isObject = isObject;
const areJsonEqualFailureMessage = 'Failed to compare objects using JSON.stringify';
function baseAreJsonEqual(a, b) {
return JSON.stringify(a) === JSON.stringify(b);
}
function areJsonEqual(a, b) {

@@ -18,12 +21,20 @@ try {

if (isObject(a) && isObject(b)) {
const sortedAEntries = (0, object_entries_1.getEntriesSortedByKey)(a);
const sortedBEntries = (0, object_entries_1.getEntriesSortedByKey)(b);
return JSON.stringify(sortedAEntries) === JSON.stringify(sortedBEntries);
const areKeysEqual = baseAreJsonEqual(Object.keys(a).sort(), Object.keys(b).sort());
if (!areKeysEqual) {
return false;
}
return Object.keys(a).every((keyName) => {
return areJsonEqual(a[keyName], b[keyName]);
});
}
else {
return JSON.stringify(a) === JSON.stringify(b);
return baseAreJsonEqual(a, b);
}
}
catch (error) {
console.error(`Failed to compare objects using JSON.stringify: ${(0, error_1.extractErrorMessage)(error)}`);
catch (caught) {
const error = (0, error_1.ensureError)(caught);
if (error.message.startsWith(areJsonEqualFailureMessage)) {
throw error;
}
error.message = `${areJsonEqualFailureMessage}: ${error.message}`;
throw error;

@@ -30,0 +41,0 @@ }

@@ -1,6 +0,9 @@

import { extractErrorMessage } from '../error';
import { getEntriesSortedByKey } from './object-entries';
import { ensureError } from '../error';
export function isObject(input) {
return !!input && typeof input === 'object';
}
const areJsonEqualFailureMessage = 'Failed to compare objects using JSON.stringify';
function baseAreJsonEqual(a, b) {
return JSON.stringify(a) === JSON.stringify(b);
}
export function areJsonEqual(a, b) {

@@ -12,12 +15,20 @@ try {

if (isObject(a) && isObject(b)) {
const sortedAEntries = getEntriesSortedByKey(a);
const sortedBEntries = getEntriesSortedByKey(b);
return JSON.stringify(sortedAEntries) === JSON.stringify(sortedBEntries);
const areKeysEqual = baseAreJsonEqual(Object.keys(a).sort(), Object.keys(b).sort());
if (!areKeysEqual) {
return false;
}
return Object.keys(a).every((keyName) => {
return areJsonEqual(a[keyName], b[keyName]);
});
}
else {
return JSON.stringify(a) === JSON.stringify(b);
return baseAreJsonEqual(a, b);
}
}
catch (error) {
console.error(`Failed to compare objects using JSON.stringify: ${extractErrorMessage(error)}`);
catch (caught) {
const error = ensureError(caught);
if (error.message.startsWith(areJsonEqualFailureMessage)) {
throw error;
}
error.message = `${areJsonEqualFailureMessage}: ${error.message}`;
throw error;

@@ -24,0 +35,0 @@ }

@@ -26,2 +26,2 @@ import { ArrayElement } from './type';

export type TypedFunction<Arguments, Return> = Arguments extends readonly any[] ? number extends Arguments['length'] ? (...args: ArrayElement<Arguments>[]) => Return : (...args: Arguments) => Return : void extends Arguments ? () => Return : (arg: Arguments) => Return;
export declare function isTruthy<T>(input: T): input is NonNullable<T>;
export declare function isTruthy<T>(input: T): input is Exclude<T, undefined | null | false | 0 | '' | -0 | 0n>;
{
"name": "@augment-vir/common",
"version": "13.2.3",
"version": "13.2.4",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",

@@ -27,6 +27,6 @@ "bugs": {

"dependencies": {
"type-fest": "^3.7.2"
"type-fest": "^3.8.0"
},
"devDependencies": {
"typescript": "^5.0.3"
"typescript": "^5.0.4"
},

@@ -33,0 +33,0 @@ "publishConfig": {

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