# bytesPrefixEnd

> **bytesPrefixEnd**(`prefix`): `Uint8Array`<`ArrayBufferLike`> | `undefined`

Defined in: [packages/key-encoding/src/bytes.ts:56](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/key-encoding/src/bytes.ts#L56)

The smallest byte string greater than every key that starts with `prefix`, the exclusive upper bound of a prefix range scan: a key starts with `prefix` exactly when `prefix <= key < bytesPrefixEnd(prefix)`.

Drops trailing `0xff` bytes and increments the last remaining byte, returning a new array. Returns `undefined` when `prefix` is empty or every byte is `0xff`, because then no finite bound exists and the scan runs to the end.

## Parameters

### prefix

`Uint8Array`

## Returns

`Uint8Array`<`ArrayBufferLike`> | `undefined`

## Throws

`INVALID_KEY_VALUE` when `prefix` is not a `Uint8Array`.
