gradum-kit - v0.1.0
    Preparing search index...

    Function callOnce

    • Function

      callOnce

      Type Parameters

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

        The type of the wrapped function.

      Parameters

      • fn: Type

        The function to wrap.

      Returns Type

      A function with the same signature as fn, whose body runs at most once.

      Wrap a function so its body runs only on the first call. Later calls skip the body and return the first call's result.

      const init = callOnce(function () { ... });
      const out = init();