UNPKG

react-http-fetch

Version:

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

53 lines (52 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpInMemoryCacheStore = void 0; var HttpInMemoryCacheStore = /** @class */ (function () { function HttpInMemoryCacheStore() { /** * The local cache providing for a request identifier * the corresponding cached entry. */ this.store = new Map(); } /** * @inheritdoc */ HttpInMemoryCacheStore.prototype.get = function (identifier) { return this.store.get(identifier); }; /** * @inheritdoc */ HttpInMemoryCacheStore.prototype.put = function (identifier, entry) { var _this = this; this.store.set(identifier, entry); return function () { return _this.delete(identifier); }; }; /** * @inheritdoc */ HttpInMemoryCacheStore.prototype.has = function (identifier) { return this.store.has(identifier); }; /** * @inheritdoc */ HttpInMemoryCacheStore.prototype.delete = function (identifier) { this.store.delete(identifier); }; /** * Gets all stored entries. */ HttpInMemoryCacheStore.prototype.entries = function () { return Array.from(this.store.values()); }; /** * @inheritdoc */ HttpInMemoryCacheStore.prototype.flush = function () { this.store.clear(); }; return HttpInMemoryCacheStore; }()); exports.HttpInMemoryCacheStore = HttpInMemoryCacheStore;