Function set

  • Example

    import * as P from "flurp/pojo";

    const setX = P.set("x", 5);
    setX({x: 3}); // {x: 5}
    setX({y: 3}); // {x: 5, y: 3}

    const setXIfExists = P.set("x", 5, false);
    setXIfExists({y: 3}); // {y: 3}

    Type Parameters

    • T extends Readonly<Record<string, unknown>>

    Parameters

    • key: string
    • newVal: T[keyof T]
    • createIfNotFound: boolean = true

    Returns ((obj: T) => T)

      • (obj: T): T
      • Parameters

        • obj: T

        Returns T