smartstream/ts/smartstream.classes.passthrough.ts
2023-11-02 00:30:15 +01:00

19 lines
512 B
TypeScript

import * as plugins from './smartstream.plugins.js';
export class PassThrough extends plugins.stream.Duplex {
constructor(options?: plugins.stream.DuplexOptions) {
super(options);
}
_read(size: number): void {
// No-op: Data written will be automatically available for reading.
}
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
if (this.push(chunk, encoding)) {
callback();
} else {
this.once('drain', callback);
}
}
}