1
0
mirror of https://github.com/dzeiocom/libs.git synced 2025-06-06 08:19:53 +00:00

fix: handle arrays with empty elements

Signed-off-by: Avior <f.bouillon@aptatio.com>
This commit is contained in:
Florian Bouillon 2023-02-22 16:31:52 +01:00
parent 91e44c4033
commit a1304e7349
Signed by: Florian Bouillon
GPG Key ID: E05B3A94178D3A7C
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,6 @@
/// <reference types="jest" />
import { objectSize, objectMap, objectSort, objectEqual, objectKeys, objectSet, objectLoop, objectClone, objectValues, objectClean, isObject, objectOmit } from '../src/ObjectUtil'
import { isObject, objectClean, objectClone, objectEqual, objectKeys, objectLoop, objectMap, objectOmit, objectSet, objectSize, objectSort, objectValues } from '../src/ObjectUtil'
describe('Throw if parameter is not an object', () => {
it('should works', () => {
@ -271,6 +271,9 @@ describe('Object Equal Test', () => {
a: [10, {b: 'c'}], d: '1', e: 2, f: true, g: null, h: undefined
})).toBe(true)
})
it('should handle arrays with empty elements', () => {
expect(objectEqual([,true], [,true])).toBe(true)
})
})
describe('Object Clean Tests', () => {

View File

@ -200,7 +200,7 @@ export function objectEqual(first: BasicObject, second: BasicObject): boolean {
return false
}
const res = objectLoop(first, (item, key) => {
if (!(key in second)) {
if (!(key in second) && key in first) {
return false
}
const item2 = second[key]