| 717 | // stubs is transferred from the inputs to the outputs, hence if the output is disposed, the |
| 718 | // inputs should not be. (In case of exception, nothing is disposed, though.) |
| 719 | public static fromArray(array: RpcPayload[]): RpcPayload { |
| 720 | let hooks: StubHook[] = []; |
| 721 | let promises: LocatedPromise[] = []; |
| 722 | |
| 723 | let resultArray: unknown[] = []; |
| 724 | |
| 725 | for (let payload of array) { |
| 726 | payload.ensureDeepCopied(); |
| 727 | for (let hook of payload.hooks!) { |
| 728 | hooks.push(hook); |
| 729 | } |
| 730 | for (let promise of payload.promises!) { |
| 731 | if (promise.parent === payload) { |
| 732 | // This promise is the root of the source payload. We need to reparent it to its proper |
| 733 | // location in the result array. |
| 734 | promise = { |
| 735 | parent: resultArray, |
| 736 | property: resultArray.length, |
| 737 | promise: promise.promise |
| 738 | }; |
| 739 | } |
| 740 | promises.push(promise); |
| 741 | } |
| 742 | resultArray.push(payload.value); |
| 743 | } |
| 744 | |
| 745 | return new RpcPayload(resultArray, "owned", hooks, promises); |
| 746 | } |
| 747 | |
| 748 | // Create a payload from a value parsed off the wire using Evaluator.evaluate(). |
| 749 | // |