• Make a decoder that can be used for decoding arrays, where every value is run through the given child decoder.

    Type Parameters

    • T

    Parameters

    • child: Decoder<T>

      Decoder for array items

    Returns Decoder<T[]>

    Decoder for an array of things

    Example

    Suppose we have a decoder for Users

    class User {}

    const user_decoder = Decode.instance(User, {
    id: Decode.field('id', Decode.integer),
    name: Decode.field('name', Decode.string),
    });

    Using Decode.many we can easily build a decoder for a list of users:

    const decoder = Decode.many(user_decoder);

    decode(decoder, [ {id: 1, name: 'Jeff'}, {id: 2, name: 'Jake'} ]);

Generated using TypeDoc