or run

npx @tessl/cli init
Log in

Version

Files

docs

index-management.mdindex.mdlisting.mdreading.mdremoval.mdutilities.mdverification.mdwriting.md
tile.json

task.mdevals/scenario-1/

Cache Stream Reader

Provide a small module that streams cached content by key while surfacing metadata, integrity, and size information without loading the entire payload into memory.

Capabilities

Streams cached data with descriptive callbacks

  • Given an existing cache path and key plus callbacks, returns a readable stream; each callback (when provided) fires once as soon as metadata, size, or integrity become available; streamed bytes match what is stored. @test

Rejects missing entries

  • Attempting to stream a key that is not present fails with a not-found style error before delivering any data. @test

Enforces expected integrity when provided

  • If an expected integrity is supplied and it differs from the stored integrity, the stream ends with an integrity failure and does not deliver the cached bytes. @test

Implementation

@generates

API

export interface StreamCallbacks {
  onMetadata?: (info: { key: string; integrity: string; size: number; metadata?: any }) => void;
  onIntegrity?: (integrity: string) => void;
  onSize?: (size: number) => void;
}

export interface StreamOptions extends StreamCallbacks {
  cachePath: string;
  key: string;
  expectedIntegrity?: string;
}

export function streamCachedContent(options: StreamOptions): import('stream').Readable;

Dependencies { .dependencies }

cacache { .dependency }

Provides streaming cache reads that surface metadata, integrity, and size information.