mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 01:39:21 +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";
|
||||
|
||||
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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue