# serializePriorityQueue

> **serializePriorityQueue**<`K`, `V`>(`queue`, `keyCodec`, `valueCodec`, `options?`): `Uint8Array`

Defined in: [packages/heap/src/serialization/binary.ts:221](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/heap/src/serialization/binary.ts#L221)

Serialize a priority queue into parallel key and value runs in exact internal entry order. The key order remains outside the artifact.

## Type Parameters

### K

`K`

### V

`V`

## Parameters

### queue

[`PriorityQueue`](/reference/knotkit/heap/type-aliases/priorityqueue/)<`K`, `V`>

### keyCodec

[`ElementCodec`](/reference/knotkit/wire/interfaces/elementcodec/)<`K`>

### valueCodec

[`ElementCodec`](/reference/knotkit/wire/interfaces/elementcodec/)<`V`>

### options?

[`SerializeHeapOptions`](/reference/knotkit/heap/wire/interfaces/serializeheapoptions/)

## Returns

`Uint8Array`

## Throws

With `FOREIGN_STRUCTURE`, `MISSING_ELEMENT_CODEC`, `INVALID_CODEC_RESULT`, `NON_INJECTIVE_CODEC`, or `SERIALIZATION_LIMIT_EXCEEDED` when the input cannot be represented.
