UNPKG

@pilotlab/lux-tools

Version:

A luxurious user experience framework, developed by your friends at Pilot.

24 lines 816 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const result_1 = require("@pilotlab/result"); class Cache { constructor() { this._cache = new Map(); } get(key, isCache = false) { let result = new result_1.Result(); if (this._cache.has(key)) result.resolve(this._cache.get(key)); else this.p_createNew(key, result, isCache).then((obj) => { if (isCache) this._cache.set(key, obj); }); return result; } preLoad(key) { return this.get(key, true); } release(key) { this._cache.delete(key); } releaseAll() { this._cache.clear(); } p_createNew(key, result, isCache) { return result.resolve(null); } } exports.Cache = Cache; exports.default = Cache; //# sourceMappingURL=cache.js.map