@cityjson/flatcitybuf
    Preparing search index...

    Class FileRangeReader

    RangeReader over a node:fs file handle -- the source used by CLI and server consumers reading a local file, and what fromFile builds.

    Owns an open file descriptor for its whole lifetime, because later queries seek back into the header and the indices; call close() (or FcbReader.close, or await using) to release it. Node's own open/stat/read errors are never surfaced raw: they are wrapped as FcbError with code IoError, so a caller of this package only ever has to catch FcbError.

    Unbuffered: a sequential scan costs two pread syscalls per feature. Wrap it in a BufferedRangeReader if that matters.

    Implements

    Index
    • Returns Promise<void>

    • Resolves to EXACTLY length bytes starting at offset, or rejects with an FcbError. Never returns a short buffer, and never clamps a range that crosses the end of the resource. The returned array MAY be a view into a buffer the reader reuses on its next call, so a caller that needs the bytes to outlive the next read must copy them.

      Parameters

      • offset: number
      • length: number
      • Optionalopts: ReadOpts

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • The resource's total byte length. Synchronous by contract: every source learns its size when it opens (a stat, blob.size, or a Content-Range at open time), so the reader's layout arithmetic never has to await.

      Returns number

    • Opens the file and stats it up front so size() can stay synchronous for the reader's whole lifetime, matching every other RangeReader. Node's own open/stat errors (ENOENT, EACCES, ...) are never surfaced raw -- callers of this package should only ever have to catch FcbError.

      Parameters

      • path: string

      Returns Promise<FileRangeReader>