deno.land / x / rambda@v9.1.1 / source / isEmpty.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { type } from './type.js'
export function isEmpty(input){ const inputType = type(input) if ([ 'Undefined', 'NaN', 'Number', 'Null' ].includes(inputType)) return false if (!input) return true
if (type(input.isEmpty) === 'Function') { return input.isEmpty(); } else if (input.isEmpty) { return !!input.isEmpty; }

if (inputType === 'Object'){ return Object.keys(input).length === 0 }
if (inputType === 'Array'){ return input.length === 0 }
return false}
rambda

Version Info

Tagged at
2 months ago