UNPKG

react-http-fetch

Version:

An http library for React JS built on top of native JS fetch

68 lines (67 loc) 2.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpCacheStorePrefixDecorator = void 0; var HttpCacheStorePrefixDecorator = /** @class */ (function () { function HttpCacheStorePrefixDecorator(store, prefix, separator) { /** * The label use to prefix any entry identifier. */ this.prefix = 'rhf'; /** * The label used to separate the prefix and the entry identifier. */ this.separator = '__'; this.store = store; this.prefix = prefix || this.prefix; this.separator = separator || this.separator; } /** * Computes the entry identifier by concatenating the store prefix with * the base identifier. */ HttpCacheStorePrefixDecorator.prototype.getPrefixedIdentifier = function (entryIdentifier) { return "".concat(this.prefix).concat(this.separator).concat(entryIdentifier); }; /** * @inheritdoc */ HttpCacheStorePrefixDecorator.prototype.get = function (entryIdentifier) { var prefixedIdentifier = this.getPrefixedIdentifier(entryIdentifier); return this.store.get(prefixedIdentifier); }; /** * @inheritdoc */ HttpCacheStorePrefixDecorator.prototype.put = function (entryIdentifier, entry) { var prefixedIdentifier = this.getPrefixedIdentifier(entryIdentifier); return this.store.put(prefixedIdentifier, entry); }; /** * @inheritdoc */ HttpCacheStorePrefixDecorator.prototype.has = function (entryIdentifier) { var prefixedIdentifier = this.getPrefixedIdentifier(entryIdentifier); return this.store.has(prefixedIdentifier); }; /** * @inheritdoc */ HttpCacheStorePrefixDecorator.prototype.delete = function (entryIdentifier) { var prefixedIdentifier = this.getPrefixedIdentifier(entryIdentifier); return this.store.delete(prefixedIdentifier); }; /** * @inheritdoc */ HttpCacheStorePrefixDecorator.prototype.entries = function () { return this.store.entries(); }; /** * @inheritdoc */ HttpCacheStorePrefixDecorator.prototype.flush = function () { return this.store.flush(); }; return HttpCacheStorePrefixDecorator; }()); exports.HttpCacheStorePrefixDecorator = HttpCacheStorePrefixDecorator;