source: node_modules/es-toolkit/dist/compat/predicate/isEmpty.mjs@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1011 bytes
Line 
1import { isArguments } from './isArguments.mjs';
2import { isArrayLike } from './isArrayLike.mjs';
3import { isTypedArray } from './isTypedArray.mjs';
4import { isPrototype } from '../_internal/isPrototype.mjs';
5
6function 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
33export { isEmpty };
Note: See TracBrowser for help on using the repository browser.