@opra/core
Version:
Opra schema package
22 lines (21 loc) • 508 B
JavaScript
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];
}
}