Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "operators/throw-if-undefined"

Index

Functions

Functions

throwIfUndefined

  • throwIfUndefined<T>(errorFn: (value: T, index: number) => any): OperatorFunction<T, Exclude<T, undefined>>
  • Throws the error built by errorFn if the current value is undefined. Performs type narrowing and removes undefined from your value type.

    example
    const input = of(value as string | undefined);
    
    const result = input.pipe(
      map(v => v) // typeof v = string | undefined
      throwIfUndefined(() => 'error'),
      map(v => v) // typeof v = string
    );

    Type parameters

    • T

    Parameters

    • errorFn: (value: T, index: number) => any

      Evaluates to the error which can be thrown.

        • (value: T, index: number): any
        • Parameters

          • value: T
          • index: number

          Returns any

    Returns OperatorFunction<T, Exclude<T, undefined>>

Generated using TypeDoc