# decodeWith

Decodes a raw response with the decoder registered as `name`, the way the
feed, detail and identify functions do, so a host that reads a response of
its own gets the same typed refusal.

This is a function exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import { decodeWith } from "@mapcairn/core";
 
function decodeWith(decoders: DecoderRegistry, name: string, raw: unknown, fields: FieldMap, prepare?: (raw: unknown) => unknown): LayerFeature[];
```

## Parameters

- `decoders` (`DecoderRegistry`)
- `name` (`string`)
- `raw` (`unknown`)
- `fields` (`FieldMap`)
- `prepare?` (`(raw: unknown) => unknown`): Reshapes `raw` for the decoder. It runs inside the same
   guard as the decoder, so a response that breaks it is refused too. It
   leaves `raw` as it is by default.

## Returns

`LayerFeature[]`

## Throws

- `LayerError` `invalid` when no decoder has that name, or when
   `prepare` or the decoder throws.

## See also

- [`DecoderRegistry`](https://docs.mapcairn.com/api/core/DecoderRegistry.md)
- [`FieldMap`](https://docs.mapcairn.com/api/core/FieldMap.md)
- [`LayerFeature`](https://docs.mapcairn.com/api/core/LayerFeature.md)

Source: [packages/core/src/layers/decoders.ts:139](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/layers/decoders.ts#L139)
