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

Method map

packages/core/src/entity/Collection.ts:798–808  ·  view source on GitHub ↗

* Maps the collection items based on your provided mapper function.

(mapper: (item: T, index: number) => R)

Source from the content-addressed store, hash-verified

796 * Maps the collection items based on your provided mapper function.
797 */
798 map<R>(mapper: (item: T, index: number) => R): R[] {
799 this.checkInitialized();
800 const items: R[] = [];
801 let index = 0;
802
803 for (const item of this.#items) {
804 items.push(mapper(item, index++));
805 }
806
807 return items;
808 }
809
810 /**
811 * Maps the collection items based on your provided mapper function to a single object.

Callers 15

toArrayMethod · 0.95
isExcludedMethod · 0.45
isPartiallyLoadedMethod · 0.45
processPropertyMethod · 0.45
processCollectionMethod · 0.45
processPropertyMethod · 0.45
processCollectionMethod · 0.45
serializeFunction · 0.45
convertToJSValueMethod · 0.45
getPkGetterMethod · 0.45

Calls 2

checkInitializedMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected