Options
All
  • Public
  • Public/Protected
  • All
Menu

Module function/memoize/weak

Index

References

Functions

References

Renames and re-exports weak

Functions

  • weak<T>(fn: T): T
  • Simple memoization using WeakMap. Only suitable for functions with single argument of non-primitive type.

    example
    const addFlag = obj => ({...obj, flag: true });
    const memoize = memoizeWeak(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