fix(streams): tighten stream typings and guard optional runtime paths for duplex and wrapper utilities

This commit is contained in:
2026-04-30 12:04:51 +00:00
parent f78469a299
commit fccd0f86ad
19 changed files with 1687 additions and 4247 deletions
+4 -4
View File
@@ -7,11 +7,11 @@ export interface IStreamTools {
}
export interface IStreamWriteFunction<T, rT> {
(chunkArg: T, toolsArg: IStreamTools): Promise<rT>;
(chunkArg: T, toolsArg: IStreamTools): Promise<rT | void | null | undefined>;
}
export interface IStreamFinalFunction<rT> {
(toolsArg: IStreamTools): Promise<rT>;
(toolsArg: IStreamTools): Promise<rT | void | null | undefined>;
}
export interface ISmartDuplexOptions<TInput, TOutput> extends DuplexOptions {
@@ -92,7 +92,7 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
}
// INSTANCE
private backpressuredArray: plugins.lik.BackpressuredArray<TOutput>;
private backpressuredArray: plugins.lik.BackpressuredArray<TOutput | null>;
public options: ISmartDuplexOptions<TInput, TOutput>;
private _consumerWantsData = false;
private _readFunctionRunning = false;
@@ -114,7 +114,7 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
)
);
this.options = safeOptions;
this.backpressuredArray = new plugins.lik.BackpressuredArray<TOutput>(
this.backpressuredArray = new plugins.lik.BackpressuredArray<TOutput | null>(
this.options.highWaterMark || 1
);
}