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

Method reduce

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

* Maps the collection items based on your provided mapper function to a single object.

(cb: (obj: R, item: T, index: number) => R, initial = {} as R)

Source from the content-addressed store, hash-verified

811 * Maps the collection items based on your provided mapper function to a single object.
812 */
813 reduce<R>(cb: (obj: R, item: T, index: number) => R, initial = {} as R): R {
814 this.checkInitialized();
815 let index = 0;
816
817 for (const item of this.#items) {
818 initial = cb(initial, item, index++);
819 }
820
821 return initial;
822 }
823
824 /**
825 * Maps the collection items to a dictionary, indexed by the key you specify.

Callers 15

indexByMethod · 0.95
createIndexesMethod · 0.80
createUniqueIndexesMethod · 0.80
createPropertyIndexesMethod · 0.80
_findMethod · 0.80
getEnumDefinitionsMethod · 0.80
getAllEnumDefinitionsMethod · 0.80
getColumnsMethod · 0.80
getForeignKeysMethod · 0.80
processMethod · 0.80
unwrapMethod · 0.80

Calls 1

checkInitializedMethod · 0.95

Tested by 3

statsMethod · 0.64
statsMethod · 0.64
getConfigurationMethod · 0.64