UNPKG

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