UNPKG

@pnp/odata

Version:

pnp - provides shared odata functionality and base classes

42 lines 1.43 kB
import { PnPClientStorage } from "@pnp/common"; var storage = new PnPClientStorage(); var CachingOptions = /** @class */ (function () { function CachingOptions(key, storeName, expiration) { this.key = key; this.storeName = storeName; this.expiration = expiration; } Object.defineProperty(CachingOptions.prototype, "store", { get: function () { if (this.storeName === "local") { return storage.local; } else { return storage.session; } }, enumerable: false, configurable: true }); return CachingOptions; }()); export { CachingOptions }; var CachingParserWrapper = /** @class */ (function () { function CachingParserWrapper(parser, cacheOptions) { this.parser = parser; this.cacheOptions = cacheOptions; } CachingParserWrapper.prototype.parse = function (response) { var _this = this; return this.parser.parse(response).then(function (r) { return _this.cacheData(r); }); }; CachingParserWrapper.prototype.cacheData = function (data) { if (this.cacheOptions.store !== null) { this.cacheOptions.store.put(this.cacheOptions.key, data, this.cacheOptions.expiration); } return data; }; return CachingParserWrapper; }()); export { CachingParserWrapper }; //# sourceMappingURL=caching.js.map