UNPKG
@amxdev/is-empty
Version:
latest (1.0.0)
1.0.0
Utility to check if a value is empty (null, undefined, string, array, or object)
@amxdev/is-empty
/
src
/
index.ts
15 lines
(11 loc)
•
295 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// src/index.ts
export
function
isEmpty
(
value
:
any
):
boolean
{
if
(value ==
null
)
return
true
;
if
(
typeof
value ===
"string"
||
Array
.
isArray
(value)) {
return
value.
length
===
0
; }
if
(
typeof
value ===
"object"
) {
return
Object
.
keys
(value).
length
===
0
; }
return
false
; }