Options
All
  • Public
  • Public/Protected
  • All
Menu

Module before

Index

References

Functions Function

References

Renames and re-exports before

Function Functions

  • before<T>(n: number, func: T): T
  • Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times. Subsequent calls to the created function return the result of the last func invocation.

    since

    5.5.0

    example
    jQuery(element).on('click', before(5, addContactToList))
    // => Allows adding up to 4 contacts to the list.

    Type parameters

    • T: (...args: any[]) => any

    Parameters

    • n: number

      The number of calls at which func is no longer invoked.

    • func: T

      The function to restrict.

    Returns T

    Returns the new restricted function.