Function toPOJO

  • Builds a JavaScript object using the elements of arr as the keys, applying transform to the keys to get the corresponding values.

    Example

    import * as A from "flurp/array";
    import * as S from "flurp/string";

    const pojoFromKeyLength = A.toPOJO(S.length);
    pojoFromKeyLength(["x", "xx"]); // { x: 1, xx: 2 }

    Type Parameters

    • T

    Parameters

    • transform: ((k: string) => T)
        • (k: string): T
        • Parameters

          • k: string

          Returns T

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

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

        • arr: readonly string[]

        Returns {
            [k: string]: T;
        }

        • [k: string]: T