Function fromSpec

  • Builds an object from a spec object whose values are transformations of the argument

    Example

    import * as P from "flurp/pojo";
    import * as A from "flurp/array";

    const ends = P.fromSpec({
    first: A.first,
    last: A.last,
    });

    ends([3, 4, 5, 6]); // { first: 3, last: 6 }

    Type Parameters

    • T

    Parameters

    • spec: Record<string, ((x: T) => unknown)>

    Returns ((x: T) => {
        [k: string]: T;
    })

      • (x: T): {
            [k: string]: T;
        }
      • Parameters

        • x: T

        Returns {
            [k: string]: T;
        }

        • [k: string]: T