UNPKG

@wordpress/core-data

Version:
22 lines (21 loc) 537 B
// packages/core-data/src/utils/with-weak-map-cache.js function withWeakMapCache(fn) { const cache = /* @__PURE__ */ new WeakMap(); return (key) => { let value; if (cache.has(key)) { value = cache.get(key); } else { value = fn(key); if (key !== null && typeof key === "object") { cache.set(key, value); } } return value; }; } var with_weak_map_cache_default = withWeakMapCache; export { with_weak_map_cache_default as default }; //# sourceMappingURL=with-weak-map-cache.js.map