Class: FlydriveSpoolReader
Defined in: src/batteries/storage/flydrive/index.ts:105
Reads a flydrive-backed file as a @nhtio/adk!SpoolReader.
Remarks
Constructor is not async — but the first method call awaits a private readiness promise that fetches the object's metadata (and in eager mode, its contents). Subsequent calls reuse the cached state. This keeps construction call sites synchronous while still doing real I/O lazily.
Implementations of @nhtio/adk!SpoolReader.line, @nhtio/adk!SpoolReader.byteLength, and @nhtio/adk!SpoolReader.lineCount all return promises. The SpoolReader contract supports both sync and async return; consumers of SpooledArtifact handle either.
Implements
Constructors
Constructor
new FlydriveSpoolReader(
disk: Disk,
key: string,
opts?: FlydriveSpoolReaderOptions): FlydriveSpoolReader;Defined in: src/batteries/storage/flydrive/index.ts:111
Parameters
| Parameter | Type |
|---|---|
disk | Disk |
key | string |
opts | FlydriveSpoolReaderOptions |
Returns
FlydriveSpoolReader
Methods
byteLength()
byteLength(): Promise<number>;Defined in: src/batteries/storage/flydrive/index.ts:131
Returns the total number of bytes in the underlying data.
Returns
Promise<number>
The byte length of the underlying data.
Remarks
Used for reporting and token-estimation purposes. Byte length is distinct from character length for multi-byte encodings.
Implementation of
describe()
describe(): ReaderDescriptor;Defined in: src/batteries/storage/flydrive/index.ts:171
Optionally emit a serialisable ReaderDescriptor so a @nhtio/adk!SpooledArtifact backed by this reader can round-trip through encode()/decode() as a handle.
Returns
A tagged, serialisable handle, or undefined/absent when the reader cannot describe itself.
Remarks
Synchronous by contract — the encoder's [ENCODE_METHOD]() is synchronous and cannot await. The descriptor describes where the bytes live (a spool key, or an inlined string for in-memory readers) — never the live binding (Disk, OPFS root), which the matching resolver re-injects on decode. A reader that omits this method is treated as non-describable: line/text reads still work at runtime, the SpooledArtifact simply cannot be serialised, and encoding it throws @nhtio/adk!E_READER_NOT_DESCRIBABLE.
Implementation of
line()
line(index: number): Promise<string | undefined>;Defined in: src/batteries/storage/flydrive/index.ts:124
Returns the line at the given 0-based index, or undefined when out of range.
Parameters
| Parameter | Type | Description |
|---|---|---|
index | number | 0-based line index. |
Returns
Promise<string | undefined>
The raw line string (without trailing newline), or undefined.
Implementation of
lineCount()
lineCount(): Promise<number>;Defined in: src/batteries/storage/flydrive/index.ts:136
Returns the total number of lines in the underlying data.
Returns
Promise<number>
The total line count.
Remarks
Required so consumers know when to stop iterating; the line count must remain stable for the lifetime of the reader.
Implementation of
readAll()
readAll(): Promise<string>;Defined in: src/batteries/storage/flydrive/index.ts:150
Returns the full underlying content as a single decoded string, byte-faithful to the source.
Returns
Promise<string>
Remarks
In eager mode the content is already cached at construction-time load and this method is effectively a property access. In streaming mode there is no cache: the file is re-streamed and concatenated on every call. Use @nhtio/adk!SpooledArtifact.asString judiciously on large streaming-mode artifacts.