Function create_map_factory

  • Parameters

    • implementation: any

    Returns ((__namedParameters?) => any)

      • (__namedParameters?): any
      • Parameters

        • __namedParameters: {
              m: any;
              s: any;
          } = {}
          • m: any
          • s: any

        Returns any

    Deprecated

    m is for dependency on another map s is for dependency on services (essentially everything else for the time being) l is for local dependency on the map itself, for recursion or private methods inp is for the input

    Private methods should begin with an underscore for the sake of convention. Private method access is not currently forbidden, because I'm too lazy right now.

    Example

    import { switch_enum } from "./switch_enum.js";

    export const create_adder = create_map_factory(async ({ m, s, l, inp }) => {
    return switch_enum(inp, {
    _sum: (numbers) => {
    return numbers.reduce((a, b) => a + b, 0);
    },

    add: ([a, b]) => {
    _sum([a, b]);
    },
    });
    });

    let adder = create_adder();

    // verbose usage:
    await adder(enm.add([5, 6]));

    // concise usage:
    await adder.add([5, 6]);

Generated using TypeDoc