Options
All
  • Public
  • Public/Protected
  • All
Menu

Module function/memoize/strictSingle

Index

References

Functions

References

Renames and re-exports strictSingle

Functions

  • strictSingle<T>(fn: T): T
  • Memoize functions with single argument of non-primitive argument. Uses Map instance for cache, because it's keys can be non-primitive. Use it when strict equality (===) for cache lookup is enough. It suitable for functions with single argument of primitive type too.

    example
    const addFlag = obj => ({...obj, flag: true });
    const memoize = memoizeStrictSingle(addFlag));
    const test = {test: 1};
    memoize(test); // from addFlag call
    memoize({test: 1}); // from addFlag call
    memoize(test); // from cache

    Type parameters

    • T: Function

    Parameters

    • fn: T

    Returns T

Generated using TypeDoc