Options
All
  • Public
  • Public/Protected
  • All
Menu

Module function/once

Index

References

Functions

References

Renames and re-exports once

Functions

  • once<F>(fn: F): F
  • Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be called once, no matter how many times the returned function is invoked. The first value calculated is returned in subsequent invocations.

    example
     var addOneOnce = once(x => x + 1);
    addOneOnce(10); //=> 11
    addOneOnce(addOneOnce(50)); //=> 11

    Type parameters

    Parameters

    • fn: F

      The function to wrap in a call-only-once wrapper.

    Returns F

    The wrapped function.

Generated using TypeDoc