1 |
|
2 | /**
|
3 | * Expose `isEmpty`.
|
4 | */
|
5 |
|
6 | module.exports = isEmpty;
|
7 |
|
8 |
|
9 | /**
|
10 | * Has.
|
11 | */
|
12 |
|
13 | var has = Object.prototype.hasOwnProperty;
|
14 |
|
15 |
|
16 | /**
|
17 | * Test whether a value is "empty".
|
18 | *
|
19 | * @param {Mixed} val
|
20 | * @return {Boolean}
|
21 | */
|
22 |
|
23 | function isEmpty (val) {
|
24 | if (null == val) return true;
|
25 | if ('number' == typeof val) return 0 === val;
|
26 | if (undefined !== val.length) return 0 === val.length;
|
27 | for (var key in val) if (has.call(val, key)) return false;
|
28 | return true;
|
29 | } |
\ | No newline at end of file |