# encodeInjectiveElements

> **encodeInjectiveElements**<`Value`>(`values`, `codec`, `options?`): `Uint8Array`

Defined in: [packages/wire/src/element-codec.ts:59](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/wire/src/element-codec.ts#L59)

Encode values as one contiguous codec run, proving the codec injective over them.

Two positions may share an encoding only when `equals` reports them equal, so a structure whose round trip depends on distinct bytes per stored value fails before an artifact is emitted rather than after it is restored.

## Type Parameters

### Value

`Value`

## Parameters

### values

readonly `Value`\[]

### codec

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

### options?

[`InjectiveElementOptions`](/reference/knotkit/wire/interfaces/injectiveelementoptions/)<`Value`>

## Returns

`Uint8Array`

## Throws

With `INVALID_CODEC_RESULT` when a codec throws or returns a non-`Uint8Array`, `NON_INJECTIVE_CODEC` when it emits no bytes or repeats bytes across distinct values, and `INVALID_ARGUMENT` when the run exceeds a representable length.

## Throws

A package error thrown directly by a caller-supplied codec.
