Skip to content

Commit

Permalink
fix: isEmpty returning incorrect value
Browse files Browse the repository at this point in the history
  • Loading branch information
heathcliff-hu committed Sep 11, 2024
1 parent 72201ac commit 83e8ed5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tests/typed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ describe('typed module', () => {
assert.isTrue(_.isEmpty(0))
assert.isTrue(_.isEmpty(true))
assert.isTrue(_.isEmpty([]))
assert.isTrue(_.isEmpty(0n))
assert.isTrue(_.isEmpty(false))
assert.isTrue(_.isEmpty({}))
assert.isTrue(_.isEmpty(''))
Expand All @@ -371,6 +372,7 @@ describe('typed module', () => {
assert.isFalse(_.isEmpty(new Date()))
assert.isFalse(_.isEmpty(new Date('2022-09-01T02:19:55.976Z')))
assert.isFalse(_.isEmpty(22))
assert.isFalse(_.isEmpty(1n))
assert.isFalse(_.isEmpty(new Person()))
assert.isFalse(_.isEmpty({ name: 'x' }))
assert.isFalse(_.isEmpty('abc'))
Expand Down
1 change: 1 addition & 0 deletions src/typed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const isEmpty = (value: any) => {
if (value === true || value === false) return true
if (value === null || value === undefined) return true
if (isNumber(value)) return value === 0
if (isBigInt(value)) return value === 0n
if (isDate(value)) return isNaN(value.getTime())
if (isFunction(value)) return false
if (isSymbol(value)) return false
Expand Down

0 comments on commit 83e8ed5

Please sign in to comment.