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:
parent
91e44c4033
commit
a1304e7349
@ -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', () => {
|
||||
|
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user