@httpc/kit
Version:
httpc toolbox for building function-based API with minimal code and end-to-end type safety
37 lines (36 loc) • 987 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrefixCacheDecorator = void 0;
class PrefixCacheDecorator {
constructor(prefix, provider) {
this.prefix = prefix;
this.provider = provider;
}
*keys() {
for (const key of this.provider.keys()) {
yield this._un_prefix(key);
}
}
has(key) {
return this.provider.has(this._prefix(key));
}
get(key) {
return this.provider.get(this._prefix(key));
}
set(key, value) {
return this.provider.set(this._prefix(key), value);
}
delete(key) {
return this.provider.delete(this._prefix(key));
}
clear() {
throw new Error("not-supported");
}
_prefix(key) {
return `${this.prefix}:${key}`;
}
_un_prefix(key) {
return key.substring(this.prefix.length + 1);
}
}
exports.PrefixCacheDecorator = PrefixCacheDecorator;