Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "operators/throw-if"

Index

Functions

Functions

throwIf

  • throwIf<T>(conditionFn: (value: T, index: number) => boolean, errorFn: (value: T, index: number) => any): (Anonymous function)
  • Throws the error built by errorFn if conditionFn evaluates to be truthy.

    example
    const input = cold('   ft', { f: false, t: true });
    const expected = cold('f#', { f: false }, 'error');
    
    const result = input.pipe(
      // will throw 'error' for values === true
      throwIf(
        (val) => val
        () => error
      )
    );

    Type parameters

    • T

    Parameters

    • conditionFn: (value: T, index: number) => boolean

      Determines if an error should be thrown.

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

          • value: T
          • index: number

          Returns boolean

    • 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 (Anonymous function)

Generated using TypeDoc