Function ifIsPOJO

  • Applies pojoTransform if the argument is a "Plain Old JavaScript Object", and otherTransform if it is not.

    Remarks

    A "Plain Old JavaScript Object) is not anything that broadly derives from the Object type. It excludes arrays, null, and other entities not of the "curly brace" type.

    Example

    import * as G from "flurp/guard";
    import * as P from "flurp/pojo";
    import * as L from "flurp/logic";

    const xOrFalse = G.ifIsPOJO(P.getOr("x"), L.FALSE);
    xOrFalse({x: 5}); // 5
    xOrFalse([5]); // false

    Type Parameters

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

    • U

    • V

    Parameters

    • pojoTransform: ((x: T) => V)
        • (x: T): V
        • Parameters

          • x: T

          Returns V

    • otherTransform: ((x: U) => V)
        • (x: U): V
        • Parameters

          • x: U

          Returns V

    Returns ((x: unknown) => V)

      • (x: unknown): V
      • Parameters

        • x: unknown

        Returns V