BinaryReader (advanced)
BinaryReader is the low-level byte-stream reader used internally by the
parser. It is exported for advanced use cases such as building custom EFLR
processors or inspecting raw record bodies.
import { BinaryReader } from '@geoharkat/dlis-parser';
const r = new BinaryReader(myUint8Array);
const origin = r.uvari();
const name = r.ident();
Constructor
- new BinaryReader(source[, start[, end]])
- Arguments:
source (
ArrayBuffer|Uint8Array) – The raw byte data to read from.start (
number) – Byte offset to begin reading at (default0).end (
number) – Exclusive end offset (default: length ofsource).
Position
- BinaryReader.pos
Current read position relative to
start. Writable — you can seek by assigning a new value.- Type:
number
- BinaryReader.rem
Remaining bytes from the current position to
end.- Type:
number
- BinaryReader.eof()
- Returns:
truewhen the read position has reachedend.- Return type:
boolean
- BinaryReader.peek()
Return the next byte without advancing the position, or
-1at EOF.- Return type:
number
Primitive readers
All multi-byte integers and floats are big-endian per the RP66 V1 specification.
Method |
Returns |
Description |
|---|---|---|
|
number |
1-byte unsigned integer |
|
number |
2-byte unsigned integer (big-endian) |
|
number |
4-byte unsigned integer (big-endian) |
|
number |
1-byte signed integer |
|
number |
2-byte signed integer (big-endian) |
|
number |
4-byte signed integer (big-endian) |
|
number |
4-byte IEEE 754 float (big-endian) |
|
number |
8-byte IEEE 754 double (big-endian) |
|
void |
Advance position by |
|
Uint8Array |
Return zero-copy view of next |
|
string |
Decode next |
RP66 V1 structured types
- BinaryReader.fshort()
Read a 16-bit RP66 short float (not IEEE half-float).
- Return type:
number
- BinaryReader.isingl()
Read a 4-byte IBM base-16 single-precision float.
- Return type:
number
- BinaryReader.vsingl()
Read a 4-byte VAX F-float (word-swapped pairs).
- Return type:
number
- BinaryReader.uvari()
Read a variable-length unsigned integer: 1 byte if
b0 < 0x80, 2 bytes ifb0 & 0xC0 == 0x80, otherwise 4 bytes.- Return type:
number
- BinaryReader.ident()
Read a 1-byte length-prefixed ASCII string (max 255 bytes).
- Return type:
string
- BinaryReader.asciiStr()
Read a 4-byte length-prefixed ASCII string. Automatically falls back to
ident()when the 4-byte length field is unreasonably large (> 65536), which handles vendors that write IDENT-encoded strings with ASCII repcodes.- Return type:
string
- BinaryReader.obname()
Read an OBNAME triplet
{ origin, copy, name }. Auto-detects the standard 2-byte copy field and the Baker Hughes 1-byte variant.- Return type:
OBName
- BinaryReader.objref()
Read an OBJREF:
{ type: string, name: OBName }.- Return type:
object
- BinaryReader.dtime()
Read an 8-byte RP66 V1 date-time value.
- Return type:
Date
- BinaryReader.val(rc)
Dispatch to the correct reader for representation code
rc. Covers all 27 RP66 V1 codes. ThrowsErrorfor unknown codes.- Arguments:
rc (
number) – Representation code (use theRCenum).
- Return type:
number | string | boolean | Date | OBName | object