(stream: WritableStream, parent: object | undefined,
dupStubs: boolean = true)
| 873 | |
| 874 | // Get the StubHook representing the given WritableStream found inside this payload. |
| 875 | public getHookForWritableStream(stream: WritableStream, parent: object | undefined, |
| 876 | dupStubs: boolean = true): StubHook { |
| 877 | if (this.source === "params") { |
| 878 | // For params, we always create a new hook. WritableStreams don't have a dup() method, |
| 879 | // and it wouldn't really make sense anyway since we're locking the stream by calling |
| 880 | // getWriter(). |
| 881 | return streamImpl.createWritableStreamHook(stream); |
| 882 | } else if (this.source === "return") { |
| 883 | // Similar logic to getHookForRpcTarget(). |
| 884 | let hook = this.rpcTargets?.get(stream); |
| 885 | if (hook) { |
| 886 | if (dupStubs) { |
| 887 | return hook.dup(); |
| 888 | } else { |
| 889 | this.rpcTargets?.delete(stream); |
| 890 | return hook; |
| 891 | } |
| 892 | } else { |
| 893 | hook = streamImpl.createWritableStreamHook(stream); |
| 894 | if (dupStubs) { |
| 895 | if (!this.rpcTargets) { |
| 896 | this.rpcTargets = new Map; |
| 897 | } |
| 898 | this.rpcTargets.set(stream, hook); |
| 899 | return hook.dup(); |
| 900 | } else { |
| 901 | return hook; |
| 902 | } |
| 903 | } |
| 904 | } else { |
| 905 | throw new Error("owned payload shouldn't contain raw WritableStreams"); |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | // Get the StubHook representing the given ReadableStream found inside this payload. |
| 910 | public getHookForReadableStream(stream: ReadableStream, parent: object | undefined, |
no test coverage detected