UNPKG

451 BJavaScriptView Raw
1
2/**
3 * Expose `isEmpty`.
4 */
5
6module.exports = isEmpty;
7
8
9/**
10 * Has.
11 */
12
13var has = Object.prototype.hasOwnProperty;
14
15
16/**
17 * Test whether a value is "empty".
18 *
19 * @param {Mixed} val
20 * @return {Boolean}
21 */
22
23function 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