| 508 | thisArg: This, |
| 509 | ): NewValue[]; |
| 510 | public map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue, thisArg?: unknown): NewValue[] { |
| 511 | if (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`); |
| 512 | if (thisArg !== undefined) fn = fn.bind(thisArg); |
| 513 | const iter = this.entries(); |
| 514 | return Array.from({ length: this.size }, (): NewValue => { |
| 515 | const [key, value] = iter.next().value!; |
| 516 | return fn(value, key, this); |
| 517 | }); |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Maps each item to another value into a collection. Identical in behavior to |