* 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)
| 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. |