mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 09:49:24 +02:00
feat(stream): support async handler in InspectStream
This commit is contained in:
parent
3b71612b31
commit
ae42638b8b
1 changed files with 4 additions and 3 deletions
|
@ -1,13 +1,14 @@
|
||||||
|
import type { MaybePromiseLike } from "@yume-chan/async";
|
||||||
import { TransformStream } from "./stream.js";
|
import { TransformStream } from "./stream.js";
|
||||||
|
|
||||||
export class InspectStream<T> extends TransformStream<T, T> {
|
export class InspectStream<T> extends TransformStream<T, T> {
|
||||||
constructor(
|
constructor(
|
||||||
write: (value: T) => void,
|
write: (value: T) => MaybePromiseLike<undefined>,
|
||||||
extras?: { close: () => void; cancel: () => void },
|
extras?: { close: () => void; cancel: () => void },
|
||||||
) {
|
) {
|
||||||
super({
|
super({
|
||||||
transform(chunk, controller) {
|
async transform(chunk, controller) {
|
||||||
write(chunk);
|
await write(chunk);
|
||||||
controller.enqueue(chunk);
|
controller.enqueue(chunk);
|
||||||
},
|
},
|
||||||
flush() {
|
flush() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue