1 | import isNil from './is-nil';
|
2 | import isArrayLike from './is-array-like';
|
3 | import getType from './get-type';
|
4 | import isPrototype from './is-prototype';
|
5 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
6 | function isEmpty(value) {
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | if (isNil(value)) {
|
17 | return true;
|
18 | }
|
19 | if (isArrayLike(value)) {
|
20 | return !value.length;
|
21 | }
|
22 | var type = getType(value);
|
23 | if (type === 'Map' || type === 'Set') {
|
24 | return !value.size;
|
25 | }
|
26 | if (isPrototype(value)) {
|
27 | return !Object.keys(value).length;
|
28 | }
|
29 | for (var key in value) {
|
30 | if (hasOwnProperty.call(value, key)) {
|
31 | return false;
|
32 | }
|
33 | }
|
34 | return true;
|
35 | }
|
36 | export default isEmpty;
|
37 |
|
\ | No newline at end of file |