# commonPrefixLength

> **commonPrefixLength**(`left`, `right`): `number`

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

Count the leading bytes `left` and `right` share, from `0` through `min(left.byteLength, right.byteLength)`.

Runs in O(result) and, like [compareBytes](/reference/knotkit/key-encoding/functions/comparebytes/), does not validate its arguments.

## Parameters

### left

`Uint8Array`

### right

`Uint8Array`

## Returns

`number`
