Function cache

  • Caches the result of a function call by its arguments.

    Type Parameters

    • T extends Function

    Parameters

    • func: T

    Returns T

    Example

    const cached = cache(() => Math.random())
    cached() // will be called immediately
    cached() // will return the same value

Generated using TypeDoc