UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

17 lines (16 loc) 426 B
/** * Simple memoize function. It takes a function and a resolver function to generate a * cache key */ export function memoize(func, resolver) { const cache = new Map(); return function (...args) { const key = resolver(...args); if (cache.has(key)) { return cache.get(key); } const result = func(...args); cache.set(key, result); return result; }; }