Skip to content

encodeBytesKey(value): Uint8Array

Defined in: packages/key-encoding/src/scalars.ts:186

Encode a byte string so that compareBytes orders the keys as the byte strings themselves, and so the key is self-delimiting: it can be followed by more key bytes without changing the order.

Writes each 0x00 as 0x00 0xff and ends with 0x00 0x00. A byte string that is a prefix of another therefore sorts first, exactly as under compareBytes. Costs value.byteLength + 2 bytes plus one per 0x00.

Uint8Array

Uint8Array

INVALID_KEY_VALUE when value is not a Uint8Array.