• Parse a JSON string, or return the fallback if it fails to parse.

    Type Parameters

    • R

    Parameters

    • fallback: R

    Returns ((x) => R)

      • (x): R
      • Parameters

        • x: string

        Returns R

    See

    parse

    Example

    parseOr(['fallback'])('["Good","JSON"]')
    // => ['Good', 'JSON']

    parseOr(['fallback'])('[Bad, JSON]')
    // => ['fallback']

Generated using TypeDoc