• A bus factory that allows a key and a value bus to be wrapped in a HashMap.

    Example

    import * as io from "@prelude-io/core";
    import { HashMap } from "prelude-ts";

    const hashMapBus = io.HashMap(io.string, io.number);

    // => IORight with HashMap containing foo => 2, bar => 4
    console.log(
    hashMapBus.deserialize([
    ["foo", 2],
    ["bar", 4],
    ])
    );

    // => IORight with HashMap containing foo => 2, bar => 4
    console.log(
    io.objectEntries.chain(hashMapBus).deserialize({
    foo: 2,
    bar: 4,
    })
    );

    // => IORight with [["foo", 2], ["bar", 4]]
    {
    const input = HashMap.empty().put("foo", 2).put("bar", 4);
    console.log(hashMapBus.serialize(input));
    }

    // => IOLeft rejecting due to mismatched type in value
    console.log(
    hashMapBus.deserialize([
    ["foo", false],
    ["bar", 4],
    ])
    );

    Type Parameters

    • VI

      Value bus output

    • KI extends WithEquality

      Key bus input

    • VO

      Value bus output

    • KO extends WithEquality

      Key bus output

    Parameters

    • keyInnerBus: Bus<KI, KO>

      The bus to validate keys

    • valueInnerBus: Bus<VI, VO>

      The bus to validate keys

    • name: string = ...

      The name of the new Bus. Defaults to "HashMap(keyBusName, valueBusName)"

    Returns Bus<[KI, VI][], HashMap<KO, VO>>

Generated using TypeDoc