MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / asArray

Method asArray

packages/core/src/utils/Utils.ts:342–352  ·  view source on GitHub ↗

* Normalize the argument to always be an array.

(data?: T | readonly T[] | Iterable<T>, strict = false)

Source from the content-addressed store, hash-verified

340 * Normalize the argument to always be an array.
341 */
342 static asArray<T>(data?: T | readonly T[] | Iterable<T>, strict = false): T[] {
343 if (typeof data === 'undefined' && !strict) {
344 return [];
345 }
346
347 if (this.isIterable(data)) {
348 return Array.from(data);
349 }
350
351 return [data as T];
352 }
353
354 /**
355 * Checks if the value is iterable, but considers strings and buffers as not iterable.

Callers 15

mapIndexPropertiesMethod · 0.80
streamMethod · 0.80
findMethod · 0.80
findOneMethod · 0.80
buildQueryOptionsMethod · 0.80
_findMethod · 0.80
countByMethod · 0.80
countByMethod · 0.80
validateSqlOptionsFunction · 0.80
nativeInsertManyFunction · 0.80
buildPivotResultMapFunction · 0.80

Calls 2

isIterableMethod · 0.95
fromMethod · 0.65

Tested by

no test coverage detected