NodeFileReader
Defined in: io/node-file-reader.ts:25
A RandomAccessReader over a file on the Node/Bun/Deno filesystem.
Construction is via the async NodeFileReader.open factory rather
than new: opening the file is asynchronous, and node:fs/promises is
imported dynamically so importing @fits-js/core stays free of any
static platform dependency and works unchanged in the browser.
Example
Section titled “Example”const reader = await NodeFileReader.open("/data/image.fits");try { const header = await reader.read(0, 2880);} finally { await reader.close();}Implements
Section titled “Implements”Properties
Section titled “Properties”readonly size: number;Defined in: io/node-file-reader.ts:28
Total length in bytes, or undefined if the source size is unknown.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”close()
Section titled “close()”close(): Promise<void>;Defined in: io/node-file-reader.ts:70
Release any held resource (file handle, cache). Optional.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”read()
Section titled “read()”read(offset, length): Promise<Uint8Array<ArrayBufferLike>>;Defined in: io/node-file-reader.ts:53
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
offset |
number |
length |
number |
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
Implementation of
Section titled “Implementation of”open()
Section titled “open()”static open(path): Promise<NodeFileReader>;Defined in: io/node-file-reader.ts:31
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path |
string | URL |
Returns
Section titled “Returns”Promise<NodeFileReader>