typescript-cacheable
Version:
An in-memory caching (memoization) decorator for Typescript
25 lines • 1 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.CacheRegistryProvider = void 0;
const Errors_1 = require("../Errors");
const GlobalCacheRegistry_1 = require("./GlobalCacheRegistry");
const LocalCacheRegistry_1 = require("./LocalCacheRegistry");
function assertNever(scope) {
throw new Errors_1.UnrecognizedScopeError(`No storage factory for scope: ${scope}`);
}
class CacheRegistryProvider {
static forScope(scope) {
switch (scope) {
case 'GLOBAL':
return CacheRegistryProvider.global;
case 'LOCAL_STORAGE':
return CacheRegistryProvider.local;
default:
return assertNever(scope);
}
}
}
exports.CacheRegistryProvider = CacheRegistryProvider;
CacheRegistryProvider.global = new GlobalCacheRegistry_1.GlobalCacheRegistry();
CacheRegistryProvider.local = new LocalCacheRegistry_1.LocalStorageCacheRegistry();
//# sourceMappingURL=CacheRegistryProvider.js.map
;