MCPcopy
hub / github.com/emberjs/ember.js / isEmpty

Function isEmpty

packages/@ember/utils/lib/is_empty.ts:38–63  ·  view source on GitHub ↗
(obj: unknown)

Source from the content-addressed store, hash-verified

36 @public
37*/
38export default function isEmpty(obj: unknown): boolean {
39 if (obj === null || obj === undefined) {
40 return true;
41 }
42
43 if (!hasUnknownProperty(obj) && typeof (obj as HasSize).size === 'number') {
44 return !(obj as HasSize).size;
45 }
46
47 if (typeof obj === 'object') {
48 let size = get(obj, 'size');
49 if (typeof size === 'number') {
50 return !size;
51 }
52 let length = get(obj, 'length');
53 if (typeof length === 'number') {
54 return !length;
55 }
56 }
57
58 if (typeof (obj as HasLength).length === 'number' && typeof obj !== 'function') {
59 return !(obj as HasLength).length;
60 }
61
62 return false;
63}
64
65interface HasSize {
66 size: number;

Callers 6

is-empty.test.tsFile · 0.90
emptyFunction · 0.90
notEmptyFunction · 0.90
utils-tests.tsFile · 0.90
isBlankFunction · 0.70
['@test isEmpty']Method · 0.50

Calls 2

hasUnknownPropertyFunction · 0.90
getFunction · 0.90

Tested by

no test coverage detected