Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "dispatch"

Index

Functions

Functions

dispatch

  • dispatch(...funcs: Function[]): Function
  • Iterates through the functions and calls them with given the parameters and returns the first non-empty result.

    Example:

    const f = dispatch(
        (value) => { return value > 5 ? 'Value is greater than 5.' : undefined },
        (value) => { return value === 5 ? 'Value is 5.' : undefined },
        (value) => { return value < 5 ? 'Value is less than 5.' : undefined }
    );
    
    console.log(f(2));  // Value is less then 5.
    

    Parameters

    • Rest ...funcs: Function[]

    Returns Function

Generated using TypeDoc