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

Function isArray

packages/@ember/array/index.ts:168–198  ·  view source on GitHub ↗
(obj: unknown)

Source from the content-addressed store, hash-verified

166 @public
167*/
168export function isArray(obj: unknown): obj is ArrayLike<unknown> | EmberArray<unknown> {
169 if (DEBUG && typeof obj === 'object' && obj !== null) {
170 // SAFETY: Property read checks are safe if it's an object
171 let possibleProxyContent = (obj as any)[PROXY_CONTENT];
172 if (possibleProxyContent !== undefined) {
173 obj = possibleProxyContent;
174 }
175 }
176
177 // SAFETY: Property read checks are safe if it's an object
178 if (!obj || (obj as any).setInterval) {
179 return false;
180 }
181
182 if (Array.isArray(obj) || EmberArray.detect(obj)) {
183 return true;
184 }
185
186 let type = typeOf(obj);
187 if ('array' === type) {
188 return true;
189 }
190
191 // SAFETY: Property read checks are safe if it's an object
192 let length = (obj as any).length;
193 if (typeof length === 'number' && length === length && 'object' === type) {
194 return true;
195 }
196
197 return false;
198}
199
200/*
201 This allows us to define computed properties that are not enumerable.

Calls 2

typeOfFunction · 0.90
detectMethod · 0.45

Tested by

no test coverage detected