UNPKG

@focuson/utils

Version:

Common utilities for the @focuson project

19 lines (18 loc) 490 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.memoise = void 0; const cacheofCache = new Map(); const memoise = (type, key) => (generator) => { var cache = cacheofCache.get(type); if (!cache) { cache = new Map(); cacheofCache.set(type, cache); } const result = cache.get(key); if (result) return result; const newT = generator(); cache.set(key, newT); return newT; }; exports.memoise = memoise;