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

@contrail/util

Package Overview
Dependencies
Maintainers
6
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrail/util - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

0

lib/index.d.ts
export * from './object-util/object-util';
export * from './string-util/string-util';

@@ -0,0 +0,0 @@ "use strict";

export declare function cloneDeep(obj: any): any;

@@ -0,0 +0,0 @@ "use strict";

1

lib/object-util/compareDeep/compareDeep.d.ts

@@ -7,1 +7,2 @@ export interface ObjectDiff {

export declare function getObjectDiffs(before: any, after: any, prefix: string): ObjectDiff[];
export declare function getObjectDiff(before: any, after: any, name: any): ObjectDiff;

39

lib/object-util/compareDeep/compareDeep.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getObjectDiffs = void 0;
exports.getObjectDiff = exports.getObjectDiffs = void 0;
function getObjectDiffs(before, after, prefix) {

@@ -21,20 +21,30 @@ const diffs = [];

commonProperties.forEach(commonProperty => {
if (typeof before[commonProperty] !== typeof after[commonProperty]) {
diffs.push(getObjectDiff(before[commonProperty], after[commonProperty], prefix + commonProperty));
const beforeVal = before[commonProperty];
const afterVal = after[commonProperty];
if (beforeVal === afterVal) {
return;
}
else if (isObject(before[commonProperty])) {
if (isDate(before[commonProperty])) {
if (!datesEqual(before[commonProperty], after[commonProperty])) {
diffs.push(getObjectDiff(before[commonProperty], after[commonProperty], prefix + commonProperty));
if (beforeVal === null || afterVal === null) {
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
return;
}
if (typeof beforeVal !== typeof afterVal) {
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
return;
}
if (isObject(beforeVal)) {
if (isDate(beforeVal)) {
if (!datesEqual(beforeVal, afterVal)) {
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
}
}
else if (Array.isArray(before[commonProperty])) {
const beforeArray = [...before[commonProperty]].sort(sortFunc);
const afterArray = [...after[commonProperty]].sort(sortFunc);
else if (Array.isArray(beforeVal)) {
const beforeArray = [...beforeVal].sort(sortFunc);
const afterArray = [...afterVal].sort(sortFunc);
if (JSON.stringify(beforeArray) !== JSON.stringify(afterArray)) {
diffs.push(getObjectDiff(before[commonProperty], after[commonProperty], prefix + commonProperty));
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
}
}
else {
const nestedObjectDiffs = getObjectDiffs(before[commonProperty], after[commonProperty], prefix + commonProperty + '.');
const nestedObjectDiffs = getObjectDiffs(beforeVal, afterVal, prefix + commonProperty + '.');
diffs.push(...nestedObjectDiffs);

@@ -44,4 +54,4 @@ }

else {
if (before[commonProperty] !== after[commonProperty]) {
diffs.push(getObjectDiff(before[commonProperty], after[commonProperty], prefix + commonProperty));
if (beforeVal !== afterVal) {
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
}

@@ -61,2 +71,3 @@ }

}
exports.getObjectDiff = getObjectDiff;
function sortFunc(x, y) {

@@ -63,0 +74,0 @@ const pre = ['string', 'number', 'bool'];

@@ -17,2 +17,10 @@ export declare const item1Assortment1: {

};
export declare const item1Assortment3: {
id: string;
stringProperty: string;
intProperty: number;
boolProperty: boolean;
dateProperty: Date;
arrayProperty: any;
};
export declare const item2Assortment1: {

@@ -19,0 +27,0 @@ id: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.item3Assortment2NestedChanges = exports.item3Assortment1 = exports.item2Assortment2DateChange = exports.item2Assortment2ArrayChange = exports.item2Assortment2ScalarChange = exports.item2Assortment1 = exports.item1Assortment2 = exports.item1Assortment1 = void 0;
exports.item3Assortment2NestedChanges = exports.item3Assortment1 = exports.item2Assortment2DateChange = exports.item2Assortment2ArrayChange = exports.item2Assortment2ScalarChange = exports.item2Assortment1 = exports.item1Assortment3 = exports.item1Assortment2 = exports.item1Assortment1 = void 0;
exports.item1Assortment1 = {

@@ -20,2 +20,10 @@ id: 'id1',

};
exports.item1Assortment3 = {
id: 'id1',
stringProperty: 'stringProperty1',
intProperty: 1,
boolProperty: false,
dateProperty: new Date('12/22/1994'),
arrayProperty: null,
};
exports.item2Assortment1 = {

@@ -22,0 +30,0 @@ id: 'id2',

export declare function isObject(item: any): boolean;

@@ -0,0 +0,0 @@ "use strict";

export declare function mergeDeep(target: any, ...sources: any[]): any;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { cloneDeep } from './cloneDeep/cloneDeep';

@@ -0,0 +0,0 @@ "use strict";

export declare class StringUtil {
static convertToHyphenCase(entityName: string, transformToLowerCase?: boolean): string;
}

@@ -0,0 +0,0 @@ "use strict";

{
"name": "@contrail/util",
"version": "1.0.12",
"version": "1.0.13",
"description": "General javascript utilities",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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