UNPKG

@opra/core

Version:
22 lines (21 loc) 508 B
export class AssetCache { _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]; } }