@nishin/node-file-reader
v0.8.0
Published
Read various data types from a Node.JS file handle in a streamlined way
Downloads
337
Maintainers
Readme
Asynchronous binary reader for Node.JS
Read various data types from a file handle in a streamlined way
The NodeFileReader
class implements file handle access on top of the AsyncReader
class and is suitable to read very large files as the file is only partially loaded into memory while traversing it. The API layer is almost identical to the BinaryReader
class, only that most methods return promises instead.
For details on supported data types consult the @nishin/reader readme.
Usage
import fs from 'node:fs/promises';
import { NodeFileReader, DataType } from '@nishin/node-file-reader';
const reader = new NodeFileReader(await fs.open('/path/to/large/file'), ByteOrder.BigEndian, { bufferSize: 8192 });
const data = await reader.next(DataType.Uint8);
await reader.close();