Function singleshot

Creates a function that is only executed once, and then memoizes and returns the result.

  • Type Parameters

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

      The type of the function to be executed once.

    Parameters

    • run: T

      The function to be executed once.

    Returns T & IClearable

    • The executed function with additional "clear" method to reset the execution state.