* Processes the provided runtime. * @param {RuntimeSpec} runtime the runtimes * @param {(value: R | undefined) => R} fn function to update the value
(runtime, fn)
| 608 | * @param {(value: R | undefined) => R} fn function to update the value |
| 609 | */ |
| 610 | update(runtime, fn) { |
| 611 | switch (this._mode) { |
| 612 | case 0: |
| 613 | throw new Error("runtime passed to update must exist"); |
| 614 | case 1: { |
| 615 | if (runtimeEqual(this._singleRuntime, runtime)) { |
| 616 | this._singleValue = fn(this._singleValue); |
| 617 | break; |
| 618 | } |
| 619 | const newValue = fn(undefined); |
| 620 | if (newValue !== undefined) { |
| 621 | this._mode = 2; |
| 622 | this._map = new Map(); |
| 623 | this._map.set( |
| 624 | getRuntimeKey(this._singleRuntime), |
| 625 | /** @type {R} */ |
| 626 | (this._singleValue) |
| 627 | ); |
| 628 | this._singleRuntime = undefined; |
| 629 | this._singleValue = undefined; |
| 630 | this._map.set(getRuntimeKey(runtime), newValue); |
| 631 | } |
| 632 | break; |
| 633 | } |
| 634 | default: { |
| 635 | const key = getRuntimeKey(runtime); |
| 636 | const oldValue = |
| 637 | /** @type {RuntimeSpecMapInnerMap<R>} */ |
| 638 | (this._map).get(key); |
| 639 | const newValue = fn(oldValue); |
| 640 | if (newValue !== oldValue) { |
| 641 | /** @type {RuntimeSpecMapInnerMap<R>} */ |
| 642 | (this._map).set(key, newValue); |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | keys() { |
| 649 | switch (this._mode) { |
nothing calls this directly
no test coverage detected