feat(stream): support async handler in InspectStream

This commit is contained in:
Simon Chan 2025-08-28 16:36:24 +08:00
parent 3b71612b31
commit ae42638b8b
No known key found for this signature in database
GPG key ID: A8B69F750B9BCEDD

View file

@ -1,13 +1,14 @@
import type { MaybePromiseLike } from "@yume-chan/async";
import { TransformStream } from "./stream.js";
export class InspectStream<T> extends TransformStream<T, T> {
constructor(
write: (value: T) => void,
write: (value: T) => MaybePromiseLike<undefined>,
extras?: { close: () => void; cancel: () => void },
) {
super({
transform(chunk, controller) {
write(chunk);
async transform(chunk, controller) {
await write(chunk);
controller.enqueue(chunk);
},
flush() {