@heliosgraphics/utils
Advanced tools
Comparing version 5.3.9 to 5.3.10
import { describe, it, expect } from "vitest" | ||
import { compareObjects } from './objects' | ||
import { compareObjects } from "./objects" | ||
describe('compareObjects', () => { | ||
it('should return true for identical objects', () => { | ||
describe("compareObjects", () => { | ||
it("should return true for identical objects", () => { | ||
const obj1 = { a: 1, b: 2 } | ||
@@ -11,3 +11,3 @@ const obj2 = { a: 1, b: 2 } | ||
it('should return false for different objects', () => { | ||
it("should return false for different objects", () => { | ||
const obj1 = { a: 1, b: 2 } | ||
@@ -18,3 +18,3 @@ const obj2 = { a: 2, b: 3 } | ||
it('should handle null and undefined', () => { | ||
it("should handle null and undefined", () => { | ||
const obj1 = { a: 1, b: 2 } | ||
@@ -26,3 +26,3 @@ expect(compareObjects(obj1, null as unknown as any)).toBeFalsy() | ||
it('should not depend on property order', () => { | ||
it("should not depend on property order", () => { | ||
const obj1 = { a: 1, b: 2 } | ||
@@ -29,0 +29,0 @@ const obj2 = { b: 2, a: 1 } |
const _orderObjectProperties = (obj: any): unknown | object => { | ||
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return obj | ||
if (!obj || typeof obj !== "object" || Array.isArray(obj)) return obj | ||
return Object.keys(obj).sort().reduce((acc: any, key: any) => { | ||
acc[key] = _orderObjectProperties(obj[key] as any) | ||
return Object.keys(obj) | ||
.sort() | ||
.reduce((acc: any, key: any) => { | ||
acc[key] = _orderObjectProperties(obj[key] as any) | ||
return acc | ||
}, {}) | ||
return acc | ||
}, {}) | ||
} | ||
@@ -10,0 +12,0 @@ |
{ | ||
"name": "@heliosgraphics/utils", | ||
"version": "5.3.9", | ||
"version": "5.3.10", | ||
"type": "module", | ||
@@ -8,10 +8,9 @@ "author": "03b8 <03b8@helios.graphics>", | ||
"private": false, | ||
"description": "Universal Javascript helpers", | ||
"description": "Universal Javascript Helpers", | ||
"main": "index.ts", | ||
"engines": { | ||
"npm": ">=10.2.4", | ||
"node": ">=20.11.1" | ||
"node": ">=20.15.0" | ||
}, | ||
"dependencies": { | ||
"xss": "latest" | ||
"xss": "1.0.15" | ||
}, | ||
@@ -18,0 +17,0 @@ "devDependencies": { |
440
19903
Updatedxss@1.0.15