(stream: ReadableStream, parent: object | undefined,
dupStubs: boolean = true)
| 908 | |
| 909 | // Get the StubHook representing the given ReadableStream found inside this payload. |
| 910 | public getHookForReadableStream(stream: ReadableStream, parent: object | undefined, |
| 911 | dupStubs: boolean = true): StubHook { |
| 912 | if (this.source === "params") { |
| 913 | return streamImpl.createReadableStreamHook(stream); |
| 914 | } else if (this.source === "return") { |
| 915 | let hook = this.rpcTargets?.get(stream); |
| 916 | if (hook) { |
| 917 | if (dupStubs) { |
| 918 | return hook.dup(); |
| 919 | } else { |
| 920 | this.rpcTargets?.delete(stream); |
| 921 | return hook; |
| 922 | } |
| 923 | } else { |
| 924 | hook = streamImpl.createReadableStreamHook(stream); |
| 925 | if (dupStubs) { |
| 926 | if (!this.rpcTargets) { |
| 927 | this.rpcTargets = new Map; |
| 928 | } |
| 929 | this.rpcTargets.set(stream, hook); |
| 930 | return hook.dup(); |
| 931 | } else { |
| 932 | return hook; |
| 933 | } |
| 934 | } |
| 935 | } else { |
| 936 | throw new Error("owned payload shouldn't contain raw ReadableStreams"); |
| 937 | } |
| 938 | } |
| 939 | |
| 940 | private deepCopy( |
| 941 | value: unknown, oldParent: object | undefined, property: string | number, parent: object, |
no test coverage detected