Skip to main content

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​

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​

Source: packages/core/src/layers/decoders.ts:139