evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility that fetches HTTP resources while simultaneously streaming bodies to callers and persisting cached copies. Integrity and size metadata must be available even when listeners subscribe after streaming begins.
cachePath; the returned metadata reports the HTTP status and cache location once streaming completes. @testintegrity and size listeners after data has started flowing still receives the final integrity digest and total byte count when the stream finishes. @testpreferCache: true reads from the cache even if the network source is unavailable, still streaming the cached body to the destination and emitting cache metadata plus integrity/size events. @test/**
* Streams an HTTP resource to the provided writable stream while persisting a cached copy.
* Returns an EventEmitter that buffers integrity/size payloads for listeners added mid-stream,
* plus metadata about the response and cache interaction.
*/
export interface StreamResult {
status: number;
headers: Record<string, string>;
bytes: number;
integrity?: string;
cache: {
path: string;
hit: boolean;
};
events: import('node:events').EventEmitter;
}
export interface StreamOptions {
cachePath: string;
preferCache?: boolean;
expectedIntegrity?: string;
signal?: AbortSignal;
}
export function streamWithCache(
url: string,
destination: NodeJS.WritableStream,
options: StreamOptions
): Promise<StreamResult>;Provides HTTP fetching with caching and integrity-aware streaming pipelines.