Function: writeWideUint()
function writeWideUint(
cursor,
value,
size
): void;Defined in: cursor/writeWideUint.ts:27
Writes an unsigned 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 above 2^53 - 1. For the number 2^64, the function writes all bits set. A read of a field with all bits set returns that number. The function writes a bigint with the exact value. For a bigint of 8 bytes, it needs the setBigUint64 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 is negative or does not fit in size bytes. The cursor does not move.
Throws
RangeError if value is a number that is not an integer from 0 to 2^32 - 1 for 4 bytes, or from 0 to 2^64 for 8 bytes. The cursor does not move.
Example
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