UNPKG

react-http-fetch

Version:

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

50 lines (49 loc) 1.34 kB
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; }()); export { HttpInMemoryCacheStore };