UNPKG

@opra/core

Version:
28 lines (27 loc) 675 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AssetCache = void 0; class AssetCache { constructor() { this._items = new WeakMap(); } get(obj, name) { const cache = this._items.get(obj); return cache && cache[name]; } set(obj, name, asset) { let cache = this._items.get(obj); if (!cache) { cache = {}; this._items.set(obj, cache); } cache[name] = asset; } delete(obj, name) { const cache = this._items.get(obj); if (!cache) return; delete cache[name]; } } exports.AssetCache = AssetCache;