Function unwrapOr

  • Returns the value if it's not null or undefined, or returns the default value

    Type Parameters

    • T

    Parameters

    • value: undefined | null | T

      Target value

    • defaultValue: T

    Returns T

    Unchanged value if it's not null or undefined or the default value

    const foo: Partial<Record<string, string>> = { bar: 'baz' };

    unwrapOr(foo.bar, 'qux'); // returns 'baz'
    unwrapOr(foo.bat, 'qux'); // returns 'qux'

Generated using TypeDoc