UNPKG

1.11 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var is_nil_1 = require("./is-nil");
4var is_array_like_1 = require("./is-array-like");
5var get_type_1 = require("./get-type");
6var is_prototype_1 = require("./is-prototype");
7var hasOwnProperty = Object.prototype.hasOwnProperty;
8function isEmpty(value) {
9 /**
10 * isEmpty(null) => true
11 * isEmpty() => true
12 * isEmpty(true) => true
13 * isEmpty(1) => true
14 * isEmpty([1, 2, 3]) => false
15 * isEmpty('abc') => false
16 * isEmpty({ a: 1 }) => false
17 */
18 if (is_nil_1.default(value)) {
19 return true;
20 }
21 if (is_array_like_1.default(value)) {
22 return !value.length;
23 }
24 var type = get_type_1.default(value);
25 if (type === 'Map' || type === 'Set') {
26 return !value.size;
27 }
28 if (is_prototype_1.default(value)) {
29 return !Object.keys(value).length;
30 }
31 for (var key in value) {
32 if (hasOwnProperty.call(value, key)) {
33 return false;
34 }
35 }
36 return true;
37}
38exports.default = isEmpty;
39//# sourceMappingURL=is-empty.js.map
\No newline at end of file