Options
All
  • Public
  • Public/Protected
  • All
Menu

@tsfun/tap — Reference

Index

Interfaces

Functions

Functions

tap

  • tap<Value>(value: Value, ...fns: SideEffect<Value>[]): Value
  • Insert a side-effect into function pipeline

    Example:

    const result = pass(value)
      .to(tap, value => console.log('begin', value))
      .to(inc)
      .to(tap, value => console.log('after inc', value))
      .to(double)
      .to(tap, value => console.log('after double', value))
      .to(square)
      .to(tap, value => console.log('after square', value))
      .get()

    Type parameters

    • Value

    Parameters

    • value: Value

      Value from pipeline

    • Rest ...fns: SideEffect<Value>[]

      Side effect functions

    Returns Value

    value

tapper

  • Insert a side-effect into function pipeline. This is used in situation where tap is not suited, such as map

    Example:

    const myResult = pass(result)
      .to(tap, result => console.log('result before onOk/onErr', result))
      .to(map, tapper(value => console.log('value before onOk', value)))
      .to(mapErr, tapper(error => console.log('error before onErr', error)))
      .to(map, onOk)
      .to(map, tapper(value => console.log('value after onOk', value)))
      .to(mapErr, onErr)
      .to(mapErr, tapper(error => console.log('error after onErr', error)))
      .get()

    Type parameters

    • Value

    Parameters

    • Rest ...fns: SideEffect<Value>[]

      Side effect functions

    Returns Tapper<Value>

    A side-effect function that can be inserted into a pipeline

Generated using TypeDoc