Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "operators/throw-if-null"

Index

Functions

Functions

throwIfNull

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

    example
    const input = of(value as string | null);
    
    const result = input.pipe(
      map(v => v) // typeof v = string | null
      throwIfNull(() => '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, null>>

Generated using TypeDoc