Function: writeWideInt()
ts
function writeWideInt(
cursor,
value,
size
): void;Defined in: cursor/writeWideInt.ts:27
Writes a signed integer field of 4 or 8 bytes from a number or a bigint.
Use this function for a field that is 64 bits in one version of its box. A number of 8 bytes loses precision outside the safe integer range. The function writes a bigint with the exact value. For a bigint of 8 bytes, it needs the setBigInt64 method of DataView.
Parameters
cursor
The cursor to write to. The function moves the cursor past the field.
value
number | bigint
The value to write.
size
4 | 8
The size of the field in bytes.
Returns
void
Throws
RangeError if value is a bigint that does not fit in size bytes. The cursor does not move.
Throws
RangeError if value is a number that is not an integer of the field range. The cursor does not move.
Example
ts
const cursor = createIsoBoxWriteCursor()
writeUint8(cursor, 1) // version
writeUint24(cursor, 0x000201) // flags
writeUint32(cursor, 7)
const bytes = cursor.bytes.subarray(0, cursor.pos) // 01 00 02 01 00 00 00 07