MCPcopy
hub / github.com/yume-chan/ya-webadb / wrapReadable

Method wrapReadable

libraries/stream-extra/src/duplex.ts:70–91  ·  view source on GitHub ↗
(
        readable: ReadableStream<R>,
        strategy?: QueuingStrategy<R>,
    )

Source from the content-addressed store, hash-verified

68 }
69
70 wrapReadable(
71 readable: ReadableStream<R>,
72 strategy?: QueuingStrategy<R>,
73 ): WrapReadableStream<R> {
74 return new WrapReadableStream<R>(
75 {
76 start: (controller) => {
77 this.#readableControllers.push(controller);
78 return readable;
79 },
80 cancel: async () => {
81 // cancel means the local peer wants to close the connection.
82 await this.close();
83 },
84 close: async () => {
85 // stream end means the remote peer closed the connection first.
86 await this.dispose();
87 },
88 },
89 strategy,
90 );
91 }
92
93 createWritable(stream: WritableStream<W>): WritableStream<W> {
94 const writer = stream.getWriter();

Callers 2

constructorMethod · 0.95
duplex.spec.tsFile · 0.80

Calls 3

closeMethod · 0.95
disposeMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected