• It's basically the same as Decode.field, but makes it easier to define deep property paths. Instead of Decode.field('outer', Decode.field('inner', Decode.string)) you can use Decode.at(['outer', 'inner'], Decode.string)

    Type Parameters

    • T

    Parameters

    • path: string[]

      The property path to follow. The first name is the outer-most field

    • child: Decoder<T>

      The decoder to run on that field

    Returns Decoder<T>

    Example

    When you want to access the name field in an object like this

    {
    "data": {
    "outer": {
    "inner": {
    "name": "Kobe Bryant",
    },
    },
    },
    }

    you would have to chain quite a few field decoders, which is annoying.

    const decoder = Decode.field(
    'data',
    Decode.field(
    'outer',
    Decode.field(
    'inner',
    Decode.field(
    'name',
    Decode.string,
    ),
    ),
    ),
    );

    decode(decoder, raw) === 'Kobe Bryant'

    Decode.at allows us to be more concise.

    const short = Decode.at(['data', 'outer', 'inner', 'name'], Decode.string);
    decode(short, raw) === 'Kobe Bryant'

Generated using TypeDoc