UNPKG

@opra/core

Version:
24 lines (23 loc) 543 B
export 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]; } }