source: node_modules/es-toolkit/dist/compat/predicate/isEmpty.js@ 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: 1.1 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const isArguments = require('./isArguments.js');
6const isArrayLike = require('./isArrayLike.js');
7const isTypedArray = require('./isTypedArray.js');
8const isPrototype = require('../_internal/isPrototype.js');
9
10function isEmpty(value) {
11 if (value == null) {
12 return true;
13 }
14 if (isArrayLike.isArrayLike(value)) {
15 if (typeof value.splice !== 'function' &&
16 typeof value !== 'string' &&
17 (typeof Buffer === 'undefined' || !Buffer.isBuffer(value)) &&
18 !isTypedArray.isTypedArray(value) &&
19 !isArguments.isArguments(value)) {
20 return false;
21 }
22 return value.length === 0;
23 }
24 if (typeof value === 'object') {
25 if (value instanceof Map || value instanceof Set) {
26 return value.size === 0;
27 }
28 const keys = Object.keys(value);
29 if (isPrototype.isPrototype(value)) {
30 return keys.filter(x => x !== 'constructor').length === 0;
31 }
32 return keys.length === 0;
33 }
34 return true;
35}
36
37exports.isEmpty = isEmpty;
Note: See TracBrowser for help on using the repository browser.