1 | import baseKeys from './_baseKeys.js';
|
2 | import getTag from './_getTag.js';
|
3 | import isArguments from './isArguments.js';
|
4 | import isArray from './isArray.js';
|
5 | import isArrayLike from './isArrayLike.js';
|
6 | import isBuffer from './isBuffer.js';
|
7 | import isPrototype from './_isPrototype.js';
|
8 | import isTypedArray from './isTypedArray.js';
|
9 |
|
10 |
|
11 | var mapTag = '[object Map]',
|
12 | setTag = '[object Set]';
|
13 |
|
14 |
|
15 | var objectProto = Object.prototype;
|
16 |
|
17 |
|
18 | var hasOwnProperty = objectProto.hasOwnProperty;
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | function isEmpty(value) {
|
54 | if (value == null) {
|
55 | return true;
|
56 | }
|
57 | if (isArrayLike(value) &&
|
58 | (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
59 | isBuffer(value) || isTypedArray(value) || isArguments(value))) {
|
60 | return !value.length;
|
61 | }
|
62 | var tag = getTag(value);
|
63 | if (tag == mapTag || tag == setTag) {
|
64 | return !value.size;
|
65 | }
|
66 | if (isPrototype(value)) {
|
67 | return !baseKeys(value).length;
|
68 | }
|
69 | for (var key in value) {
|
70 | if (hasOwnProperty.call(value, key)) {
|
71 | return false;
|
72 | }
|
73 | }
|
74 | return true;
|
75 | }
|
76 |
|
77 | export default isEmpty;
|