Options
All
  • Public
  • Public/Protected
  • All
Menu

Module once

Index

References

Functions Function

References

Renames and re-exports once

Function Functions

  • once<T>(func: T): T
  • Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. The func is invoked with the this binding and arguments of the created function.

    since

    5.15.0

    example
    const initialize = once(createApplication)
    initialize()
    initialize()
    // => `createApplication` is invoked once

    Type Parameters

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

    Parameters

    • func: T

      The function to restrict.

    Returns T

    Returns the new restricted function.