|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1011 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | import { isArguments } from './isArguments.mjs';
|
|---|
| 2 | import { isArrayLike } from './isArrayLike.mjs';
|
|---|
| 3 | import { isTypedArray } from './isTypedArray.mjs';
|
|---|
| 4 | import { isPrototype } from '../_internal/isPrototype.mjs';
|
|---|
| 5 |
|
|---|
| 6 | function isEmpty(value) {
|
|---|
| 7 | if (value == null) {
|
|---|
| 8 | return true;
|
|---|
| 9 | }
|
|---|
| 10 | if (isArrayLike(value)) {
|
|---|
| 11 | if (typeof value.splice !== 'function' &&
|
|---|
| 12 | typeof value !== 'string' &&
|
|---|
| 13 | (typeof Buffer === 'undefined' || !Buffer.isBuffer(value)) &&
|
|---|
| 14 | !isTypedArray(value) &&
|
|---|
| 15 | !isArguments(value)) {
|
|---|
| 16 | return false;
|
|---|
| 17 | }
|
|---|
| 18 | return value.length === 0;
|
|---|
| 19 | }
|
|---|
| 20 | if (typeof value === 'object') {
|
|---|
| 21 | if (value instanceof Map || value instanceof Set) {
|
|---|
| 22 | return value.size === 0;
|
|---|
| 23 | }
|
|---|
| 24 | const keys = Object.keys(value);
|
|---|
| 25 | if (isPrototype(value)) {
|
|---|
| 26 | return keys.filter(x => x !== 'constructor').length === 0;
|
|---|
| 27 | }
|
|---|
| 28 | return keys.length === 0;
|
|---|
| 29 | }
|
|---|
| 30 | return true;
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | export { isEmpty };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.