@aws-amplify/cache 4.0.51-next.13 → 4.0.51-next.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,6 +96,292 @@ return /******/ (function(modules) { // webpackBootstrap
96
96
  /************************************************************************/
97
97
  /******/ ({
98
98
 
99
+ /***/ "../../node_modules/tslib/tslib.es6.js":
100
+ /*!********************************************************!*\
101
+ !*** /root/amplify-js/node_modules/tslib/tslib.es6.js ***!
102
+ \********************************************************/
103
+ /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __spreadArray, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet, __classPrivateFieldIn */
104
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
105
+
106
+ "use strict";
107
+ __webpack_require__.r(__webpack_exports__);
108
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
109
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
110
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
111
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
112
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
113
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
114
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
115
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
116
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
117
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
118
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
119
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
120
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
121
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
122
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArray", function() { return __spreadArray; });
123
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
124
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
125
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
126
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
127
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
128
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
129
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
130
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
131
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
132
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldIn", function() { return __classPrivateFieldIn; });
133
+ /******************************************************************************
134
+ Copyright (c) Microsoft Corporation.
135
+
136
+ Permission to use, copy, modify, and/or distribute this software for any
137
+ purpose with or without fee is hereby granted.
138
+
139
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
140
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
141
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
142
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
143
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
144
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
145
+ PERFORMANCE OF THIS SOFTWARE.
146
+ ***************************************************************************** */
147
+ /* global Reflect, Promise */
148
+
149
+ var extendStatics = function(d, b) {
150
+ extendStatics = Object.setPrototypeOf ||
151
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
152
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
153
+ return extendStatics(d, b);
154
+ };
155
+
156
+ function __extends(d, b) {
157
+ if (typeof b !== "function" && b !== null)
158
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
159
+ extendStatics(d, b);
160
+ function __() { this.constructor = d; }
161
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
162
+ }
163
+
164
+ var __assign = function() {
165
+ __assign = Object.assign || function __assign(t) {
166
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
167
+ s = arguments[i];
168
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
169
+ }
170
+ return t;
171
+ }
172
+ return __assign.apply(this, arguments);
173
+ }
174
+
175
+ function __rest(s, e) {
176
+ var t = {};
177
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
178
+ t[p] = s[p];
179
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
180
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
181
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
182
+ t[p[i]] = s[p[i]];
183
+ }
184
+ return t;
185
+ }
186
+
187
+ function __decorate(decorators, target, key, desc) {
188
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
189
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
190
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
191
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
192
+ }
193
+
194
+ function __param(paramIndex, decorator) {
195
+ return function (target, key) { decorator(target, key, paramIndex); }
196
+ }
197
+
198
+ function __metadata(metadataKey, metadataValue) {
199
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
200
+ }
201
+
202
+ function __awaiter(thisArg, _arguments, P, generator) {
203
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
204
+ return new (P || (P = Promise))(function (resolve, reject) {
205
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
206
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
207
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
208
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
209
+ });
210
+ }
211
+
212
+ function __generator(thisArg, body) {
213
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
214
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
215
+ function verb(n) { return function (v) { return step([n, v]); }; }
216
+ function step(op) {
217
+ if (f) throw new TypeError("Generator is already executing.");
218
+ while (_) try {
219
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
220
+ if (y = 0, t) op = [op[0] & 2, t.value];
221
+ switch (op[0]) {
222
+ case 0: case 1: t = op; break;
223
+ case 4: _.label++; return { value: op[1], done: false };
224
+ case 5: _.label++; y = op[1]; op = [0]; continue;
225
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
226
+ default:
227
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
228
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
229
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
230
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
231
+ if (t[2]) _.ops.pop();
232
+ _.trys.pop(); continue;
233
+ }
234
+ op = body.call(thisArg, _);
235
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
236
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
237
+ }
238
+ }
239
+
240
+ var __createBinding = Object.create ? (function(o, m, k, k2) {
241
+ if (k2 === undefined) k2 = k;
242
+ var desc = Object.getOwnPropertyDescriptor(m, k);
243
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
244
+ desc = { enumerable: true, get: function() { return m[k]; } };
245
+ }
246
+ Object.defineProperty(o, k2, desc);
247
+ }) : (function(o, m, k, k2) {
248
+ if (k2 === undefined) k2 = k;
249
+ o[k2] = m[k];
250
+ });
251
+
252
+ function __exportStar(m, o) {
253
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
254
+ }
255
+
256
+ function __values(o) {
257
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
258
+ if (m) return m.call(o);
259
+ if (o && typeof o.length === "number") return {
260
+ next: function () {
261
+ if (o && i >= o.length) o = void 0;
262
+ return { value: o && o[i++], done: !o };
263
+ }
264
+ };
265
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
266
+ }
267
+
268
+ function __read(o, n) {
269
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
270
+ if (!m) return o;
271
+ var i = m.call(o), r, ar = [], e;
272
+ try {
273
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
274
+ }
275
+ catch (error) { e = { error: error }; }
276
+ finally {
277
+ try {
278
+ if (r && !r.done && (m = i["return"])) m.call(i);
279
+ }
280
+ finally { if (e) throw e.error; }
281
+ }
282
+ return ar;
283
+ }
284
+
285
+ /** @deprecated */
286
+ function __spread() {
287
+ for (var ar = [], i = 0; i < arguments.length; i++)
288
+ ar = ar.concat(__read(arguments[i]));
289
+ return ar;
290
+ }
291
+
292
+ /** @deprecated */
293
+ function __spreadArrays() {
294
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
295
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
296
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
297
+ r[k] = a[j];
298
+ return r;
299
+ }
300
+
301
+ function __spreadArray(to, from, pack) {
302
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
303
+ if (ar || !(i in from)) {
304
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
305
+ ar[i] = from[i];
306
+ }
307
+ }
308
+ return to.concat(ar || Array.prototype.slice.call(from));
309
+ }
310
+
311
+ function __await(v) {
312
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
313
+ }
314
+
315
+ function __asyncGenerator(thisArg, _arguments, generator) {
316
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
317
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
318
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
319
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
320
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
321
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
322
+ function fulfill(value) { resume("next", value); }
323
+ function reject(value) { resume("throw", value); }
324
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
325
+ }
326
+
327
+ function __asyncDelegator(o) {
328
+ var i, p;
329
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
330
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
331
+ }
332
+
333
+ function __asyncValues(o) {
334
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
335
+ var m = o[Symbol.asyncIterator], i;
336
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
337
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
338
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
339
+ }
340
+
341
+ function __makeTemplateObject(cooked, raw) {
342
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
343
+ return cooked;
344
+ };
345
+
346
+ var __setModuleDefault = Object.create ? (function(o, v) {
347
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
348
+ }) : function(o, v) {
349
+ o["default"] = v;
350
+ };
351
+
352
+ function __importStar(mod) {
353
+ if (mod && mod.__esModule) return mod;
354
+ var result = {};
355
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
356
+ __setModuleDefault(result, mod);
357
+ return result;
358
+ }
359
+
360
+ function __importDefault(mod) {
361
+ return (mod && mod.__esModule) ? mod : { default: mod };
362
+ }
363
+
364
+ function __classPrivateFieldGet(receiver, state, kind, f) {
365
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
366
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
367
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
368
+ }
369
+
370
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
371
+ if (kind === "m") throw new TypeError("Private method is not writable");
372
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
373
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
374
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
375
+ }
376
+
377
+ function __classPrivateFieldIn(state, receiver) {
378
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
379
+ return typeof state === "function" ? receiver === state : state.has(receiver);
380
+ }
381
+
382
+
383
+ /***/ }),
384
+
99
385
  /***/ "./lib-esm/BrowserStorageCache.js":
100
386
  /*!****************************************!*\
101
387
  !*** ./lib-esm/BrowserStorageCache.js ***!
@@ -107,10 +393,11 @@ return /******/ (function(modules) { // webpackBootstrap
107
393
  __webpack_require__.r(__webpack_exports__);
108
394
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BrowserStorageCacheClass", function() { return BrowserStorageCacheClass; });
109
395
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BrowserStorageCache", function() { return BrowserStorageCache; });
110
- /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
111
- /* harmony import */ var _StorageCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./StorageCache */ "./lib-esm/StorageCache.js");
112
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
113
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__);
396
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
397
+ /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
398
+ /* harmony import */ var _StorageCache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./StorageCache */ "./lib-esm/StorageCache.js");
399
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
400
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__);
114
401
  /*
115
402
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
116
403
  *
@@ -123,54 +410,23 @@ __webpack_require__.r(__webpack_exports__);
123
410
  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
124
411
  * and limitations under the License.
125
412
  */
126
- var __extends = undefined && undefined.__extends || function () {
127
- var _extendStatics = function extendStatics(d, b) {
128
- _extendStatics = Object.setPrototypeOf || {
129
- __proto__: []
130
- } instanceof Array && function (d, b) {
131
- d.__proto__ = b;
132
- } || function (d, b) {
133
- for (var p in b) {
134
- if (b.hasOwnProperty(p)) d[p] = b[p];
135
- }
136
- };
137
-
138
- return _extendStatics(d, b);
139
- };
140
-
141
- return function (d, b) {
142
- _extendStatics(d, b);
143
-
144
- function __() {
145
- this.constructor = d;
146
- }
147
-
148
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
149
- };
150
- }();
151
413
 
152
414
 
153
415
 
154
416
 
155
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('Cache');
417
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('Cache');
156
418
  /**
157
419
  * Customized storage based on the SessionStorage or LocalStorage with LRU implemented
158
420
  */
159
-
160
- var BrowserStorageCacheClass =
161
- /** @class */
162
- function (_super) {
163
- __extends(BrowserStorageCacheClass, _super);
421
+ var BrowserStorageCacheClass = /** @class */function (_super) {
422
+ Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BrowserStorageCacheClass, _super);
164
423
  /**
165
424
  * initialize the cache
166
425
  * @param config - the configuration of the cache
167
426
  */
168
-
169
-
170
427
  function BrowserStorageCacheClass(config) {
171
428
  var _this = this;
172
-
173
- var cacheConfig = config ? Object.assign({}, _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"], config) : _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"];
429
+ var cacheConfig = config ? Object.assign({}, _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"], config) : _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"];
174
430
  _this = _super.call(this, cacheConfig) || this;
175
431
  _this.config.storage = cacheConfig.storage;
176
432
  _this.getItem = _this.getItem.bind(_this);
@@ -184,8 +440,6 @@ function (_super) {
184
440
  * @private
185
441
  * @param amount - the amount of the cache size which needs to be decreased
186
442
  */
187
-
188
-
189
443
  BrowserStorageCacheClass.prototype._decreaseCurSizeInBytes = function (amount) {
190
444
  var curSize = this.getCacheCurSize();
191
445
  this.config.storage.setItem(this.cacheCurSizeKey, (curSize - amount).toString());
@@ -196,8 +450,6 @@ function (_super) {
196
450
  * @private
197
451
  * @param amount - the amount of the cache szie which need to be increased
198
452
  */
199
-
200
-
201
453
  BrowserStorageCacheClass.prototype._increaseCurSizeInBytes = function (amount) {
202
454
  var curSize = this.getCacheCurSize();
203
455
  this.config.storage.setItem(this.cacheCurSizeKey, (curSize + amount).toString());
@@ -211,10 +463,8 @@ function (_super) {
211
463
  *
212
464
  * @return the refreshed item
213
465
  */
214
-
215
-
216
466
  BrowserStorageCacheClass.prototype._refreshItem = function (item, prefixedKey) {
217
- item.visitedTime = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])();
467
+ item.visitedTime = Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])();
218
468
  this.config.storage.setItem(prefixedKey, JSON.stringify(item));
219
469
  return item;
220
470
  };
@@ -226,16 +476,12 @@ function (_super) {
226
476
  *
227
477
  * @return true if the item is expired.
228
478
  */
229
-
230
-
231
479
  BrowserStorageCacheClass.prototype._isExpired = function (key) {
232
480
  var text = this.config.storage.getItem(key);
233
481
  var item = JSON.parse(text);
234
-
235
- if (Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])() >= item.expires) {
482
+ if (Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])() >= item.expires) {
236
483
  return true;
237
484
  }
238
-
239
485
  return false;
240
486
  };
241
487
  /**
@@ -245,14 +491,10 @@ function (_super) {
245
491
  * @param prefixedKey - the key of the item
246
492
  * @param size - optional, the byte size of the item
247
493
  */
248
-
249
-
250
494
  BrowserStorageCacheClass.prototype._removeItem = function (prefixedKey, size) {
251
495
  var itemSize = size ? size : JSON.parse(this.config.storage.getItem(prefixedKey)).byteSize;
252
-
253
- this._decreaseCurSizeInBytes(itemSize); // remove the cache item
254
-
255
-
496
+ this._decreaseCurSizeInBytes(itemSize);
497
+ // remove the cache item
256
498
  this.config.storage.removeItem(prefixedKey);
257
499
  };
258
500
  /**
@@ -263,18 +505,14 @@ function (_super) {
263
505
  * @param itemData - the value of the item
264
506
  * @param itemSizeInBytes - the byte size of the item
265
507
  */
266
-
267
-
268
508
  BrowserStorageCacheClass.prototype._setItem = function (prefixedKey, item) {
269
509
  // update the cache size
270
510
  this._increaseCurSizeInBytes(item.byteSize);
271
-
272
511
  try {
273
512
  this.config.storage.setItem(prefixedKey, JSON.stringify(item));
274
513
  } catch (setItemErr) {
275
514
  // if failed, we need to rollback the cache size
276
515
  this._decreaseCurSizeInBytes(item.byteSize);
277
-
278
516
  logger.error("Failed to set item " + setItemErr);
279
517
  }
280
518
  };
@@ -286,8 +524,6 @@ function (_super) {
286
524
  *
287
525
  * @return total space needed
288
526
  */
289
-
290
-
291
527
  BrowserStorageCacheClass.prototype._sizeToPop = function (itemSize) {
292
528
  var spaceItemNeed = this.getCacheCurSize() + itemSize - this.config.capacityInBytes;
293
529
  var cacheThresholdSpace = (1 - this.config.warningThreshold) * this.config.capacityInBytes;
@@ -301,8 +537,6 @@ function (_super) {
301
537
  *
302
538
  * @return true if cache is full
303
539
  */
304
-
305
-
306
540
  BrowserStorageCacheClass.prototype._isCacheFull = function (itemSize) {
307
541
  return itemSize + this.getCacheCurSize() > this.config.capacityInBytes;
308
542
  };
@@ -314,20 +548,16 @@ function (_super) {
314
548
  *
315
549
  * @return array of keys
316
550
  */
317
-
318
-
319
551
  BrowserStorageCacheClass.prototype._findValidKeys = function () {
320
552
  var keys = [];
321
- var keyInCache = []; // get all keys in Storage
322
-
553
+ var keyInCache = [];
554
+ // get all keys in Storage
323
555
  for (var i = 0; i < this.config.storage.length; i += 1) {
324
556
  keyInCache.push(this.config.storage.key(i));
325
- } // find those items which belong to our cache and also clean those expired items
326
-
327
-
557
+ }
558
+ // find those items which belong to our cache and also clean those expired items
328
559
  for (var i = 0; i < keyInCache.length; i += 1) {
329
560
  var key = keyInCache[i];
330
-
331
561
  if (key.indexOf(this.config.keyPrefix) === 0 && key !== this.cacheCurSizeKey) {
332
562
  if (this._isExpired(key)) {
333
563
  this._removeItem(key);
@@ -336,7 +566,6 @@ function (_super) {
336
566
  }
337
567
  }
338
568
  }
339
-
340
569
  return keys;
341
570
  };
342
571
  /**
@@ -348,23 +577,19 @@ function (_super) {
348
577
  * @param keys - all the keys in this cache
349
578
  * @param sizeToPop - the total size of the items which needed to be poped out
350
579
  */
351
-
352
-
353
580
  BrowserStorageCacheClass.prototype._popOutItems = function (keys, sizeToPop) {
354
581
  var items = [];
355
- var remainedSize = sizeToPop; // get the items from Storage
356
-
582
+ var remainedSize = sizeToPop;
583
+ // get the items from Storage
357
584
  for (var i = 0; i < keys.length; i += 1) {
358
585
  var val = this.config.storage.getItem(keys[i]);
359
-
360
586
  if (val != null) {
361
587
  var item = JSON.parse(val);
362
588
  items.push(item);
363
589
  }
364
- } // first compare priority
590
+ }
591
+ // first compare priority
365
592
  // then compare visited time
366
-
367
-
368
593
  items.sort(function (a, b) {
369
594
  if (a.priority > b.priority) {
370
595
  return -1;
@@ -376,13 +601,10 @@ function (_super) {
376
601
  } else return 1;
377
602
  }
378
603
  });
379
-
380
604
  for (var i = 0; i < items.length; i += 1) {
381
605
  // pop out items until we have enough room for new item
382
606
  this._removeItem(items[i].key, items[i].byteSize);
383
-
384
607
  remainedSize -= items[i].byteSize;
385
-
386
608
  if (remainedSize <= 0) {
387
609
  return;
388
610
  }
@@ -404,61 +626,49 @@ function (_super) {
404
626
  * @param value - the value of the item
405
627
  * @param {Object} [options] - optional, the specified meta-data
406
628
  */
407
-
408
-
409
629
  BrowserStorageCacheClass.prototype.setItem = function (key, value, options) {
410
630
  logger.log("Set item: key is " + key + ", value is " + value + " with options: " + options);
411
- var prefixedKey = this.config.keyPrefix + key; // invalid keys
412
-
631
+ var prefixedKey = this.config.keyPrefix + key;
632
+ // invalid keys
413
633
  if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
414
634
  logger.warn("Invalid key: should not be empty or 'CurSize'");
415
635
  return;
416
636
  }
417
-
418
637
  if (typeof value === 'undefined') {
419
638
  logger.warn("The value of item should not be undefined!");
420
639
  return;
421
640
  }
422
-
423
641
  var cacheItemOptions = {
424
642
  priority: options && options.priority !== undefined ? options.priority : this.config.defaultPriority,
425
- expires: options && options.expires !== undefined ? options.expires : this.config.defaultTTL + Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])()
643
+ expires: options && options.expires !== undefined ? options.expires : this.config.defaultTTL + Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])()
426
644
  };
427
-
428
645
  if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {
429
646
  logger.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");
430
647
  return;
431
648
  }
432
-
433
- var item = this.fillCacheItem(prefixedKey, value, cacheItemOptions); // check wether this item is too big;
434
-
649
+ var item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);
650
+ // check wether this item is too big;
435
651
  if (item.byteSize > this.config.itemMaxSize) {
436
652
  logger.warn("Item with key: " + key + " you are trying to put into is too big!");
437
653
  return;
438
654
  }
439
-
440
655
  try {
441
656
  // first look into the storage, if it exists, delete it.
442
657
  var val = this.config.storage.getItem(prefixedKey);
443
-
444
658
  if (val) {
445
659
  this._removeItem(prefixedKey, JSON.parse(val).byteSize);
446
- } // check whether the cache is full
447
-
448
-
660
+ }
661
+ // check whether the cache is full
449
662
  if (this._isCacheFull(item.byteSize)) {
450
- var validKeys = this._findValidKeys(); // check again and then pop out items
451
-
452
-
663
+ var validKeys = this._findValidKeys();
664
+ // check again and then pop out items
453
665
  if (this._isCacheFull(item.byteSize)) {
454
666
  var sizeToPop = this._sizeToPop(item.byteSize);
455
-
456
667
  this._popOutItems(validKeys, sizeToPop);
457
668
  }
458
- } // put item in the cache
669
+ }
670
+ // put item in the cache
459
671
  // may failed due to storage full
460
-
461
-
462
672
  this._setItem(prefixedKey, item);
463
673
  } catch (e) {
464
674
  logger.warn("setItem failed! " + e);
@@ -479,26 +689,20 @@ function (_super) {
479
689
  *
480
690
  * @return - return the value of the item
481
691
  */
482
-
483
-
484
692
  BrowserStorageCacheClass.prototype.getItem = function (key, options) {
485
693
  logger.log("Get item: key is " + key + " with options " + options);
486
694
  var ret = null;
487
695
  var prefixedKey = this.config.keyPrefix + key;
488
-
489
696
  if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
490
697
  logger.warn("Invalid key: should not be empty or 'CurSize'");
491
698
  return null;
492
699
  }
493
-
494
700
  try {
495
701
  ret = this.config.storage.getItem(prefixedKey);
496
-
497
702
  if (ret != null) {
498
703
  if (this._isExpired(prefixedKey)) {
499
704
  // if expired, remove that item and return null
500
705
  this._removeItem(prefixedKey, JSON.parse(ret).byteSize);
501
-
502
706
  ret = null;
503
707
  } else {
504
708
  // if not expired, great, return the value and refresh it
@@ -507,17 +711,13 @@ function (_super) {
507
711
  return item.data;
508
712
  }
509
713
  }
510
-
511
714
  if (options && options.callback !== undefined) {
512
715
  var val = options.callback();
513
-
514
716
  if (val !== null) {
515
717
  this.setItem(key, val, options);
516
718
  }
517
-
518
719
  return val;
519
720
  }
520
-
521
721
  return null;
522
722
  } catch (e) {
523
723
  logger.warn("getItem failed! " + e);
@@ -530,19 +730,14 @@ function (_super) {
530
730
  * If error happened with browser storage
531
731
  * @param key - the key of the item
532
732
  */
533
-
534
-
535
733
  BrowserStorageCacheClass.prototype.removeItem = function (key) {
536
734
  logger.log("Remove item: key is " + key);
537
735
  var prefixedKey = this.config.keyPrefix + key;
538
-
539
736
  if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
540
737
  return;
541
738
  }
542
-
543
739
  try {
544
740
  var val = this.config.storage.getItem(prefixedKey);
545
-
546
741
  if (val) {
547
742
  this._removeItem(prefixedKey, JSON.parse(val).byteSize);
548
743
  }
@@ -555,20 +750,15 @@ function (_super) {
555
750
  * The cache will abort output a warning:
556
751
  * If error happened with browser storage
557
752
  */
558
-
559
-
560
753
  BrowserStorageCacheClass.prototype.clear = function () {
561
754
  logger.log("Clear Cache");
562
755
  var keysToRemove = [];
563
-
564
756
  for (var i = 0; i < this.config.storage.length; i += 1) {
565
757
  var key = this.config.storage.key(i);
566
-
567
758
  if (key.indexOf(this.config.keyPrefix) === 0) {
568
759
  keysToRemove.push(key);
569
760
  }
570
761
  }
571
-
572
762
  try {
573
763
  for (var i = 0; i < keysToRemove.length; i += 1) {
574
764
  this.config.storage.removeItem(keysToRemove[i]);
@@ -582,19 +772,14 @@ function (_super) {
582
772
  *
583
773
  * @return - all keys in the cache
584
774
  */
585
-
586
-
587
775
  BrowserStorageCacheClass.prototype.getAllKeys = function () {
588
776
  var keys = [];
589
-
590
777
  for (var i = 0; i < this.config.storage.length; i += 1) {
591
778
  var key = this.config.storage.key(i);
592
-
593
779
  if (key.indexOf(this.config.keyPrefix) === 0 && key !== this.cacheCurSizeKey) {
594
780
  keys.push(key.substring(this.config.keyPrefix.length));
595
781
  }
596
782
  }
597
-
598
783
  return keys;
599
784
  };
600
785
  /**
@@ -602,16 +787,12 @@ function (_super) {
602
787
  *
603
788
  * @return - current size of the cache
604
789
  */
605
-
606
-
607
790
  BrowserStorageCacheClass.prototype.getCacheCurSize = function () {
608
791
  var ret = this.config.storage.getItem(this.cacheCurSizeKey);
609
-
610
792
  if (!ret) {
611
793
  this.config.storage.setItem(this.cacheCurSizeKey, '0');
612
794
  ret = '0';
613
795
  }
614
-
615
796
  return Number(ret);
616
797
  };
617
798
  /**
@@ -620,26 +801,20 @@ function (_super) {
620
801
  *
621
802
  * @return - new instance of Cache
622
803
  */
623
-
624
-
625
804
  BrowserStorageCacheClass.prototype.createInstance = function (config) {
626
- if (!config.keyPrefix || config.keyPrefix === _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].keyPrefix) {
805
+ if (!config.keyPrefix || config.keyPrefix === _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"].keyPrefix) {
627
806
  logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
628
- config.keyPrefix = _Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"].toString();
807
+ config.keyPrefix = _Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"].toString();
629
808
  }
630
-
631
809
  return new BrowserStorageCacheClass(config);
632
810
  };
633
-
634
811
  return BrowserStorageCacheClass;
635
- }(_StorageCache__WEBPACK_IMPORTED_MODULE_1__["StorageCache"]);
636
-
812
+ }(_StorageCache__WEBPACK_IMPORTED_MODULE_2__["StorageCache"]);
637
813
 
638
814
  var BrowserStorageCache = new BrowserStorageCacheClass();
639
815
  /**
640
816
  * @deprecated use named import
641
817
  */
642
-
643
818
  /* harmony default export */ __webpack_exports__["default"] = (BrowserStorageCache);
644
819
 
645
820
  /***/ }),
@@ -655,10 +830,11 @@ var BrowserStorageCache = new BrowserStorageCacheClass();
655
830
  __webpack_require__.r(__webpack_exports__);
656
831
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InMemoryCacheClass", function() { return InMemoryCacheClass; });
657
832
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InMemoryCache", function() { return InMemoryCache; });
658
- /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
659
- /* harmony import */ var _StorageCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./StorageCache */ "./lib-esm/StorageCache.js");
660
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
661
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__);
833
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
834
+ /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
835
+ /* harmony import */ var _StorageCache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./StorageCache */ "./lib-esm/StorageCache.js");
836
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
837
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__);
662
838
  /*
663
839
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
664
840
  *
@@ -671,53 +847,11 @@ __webpack_require__.r(__webpack_exports__);
671
847
  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
672
848
  * and limitations under the License.
673
849
  */
674
- var __extends = undefined && undefined.__extends || function () {
675
- var _extendStatics = function extendStatics(d, b) {
676
- _extendStatics = Object.setPrototypeOf || {
677
- __proto__: []
678
- } instanceof Array && function (d, b) {
679
- d.__proto__ = b;
680
- } || function (d, b) {
681
- for (var p in b) {
682
- if (b.hasOwnProperty(p)) d[p] = b[p];
683
- }
684
- };
685
-
686
- return _extendStatics(d, b);
687
- };
688
-
689
- return function (d, b) {
690
- _extendStatics(d, b);
691
-
692
- function __() {
693
- this.constructor = d;
694
- }
695
-
696
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
697
- };
698
- }();
699
-
700
- var __values = undefined && undefined.__values || function (o) {
701
- var s = typeof Symbol === "function" && Symbol.iterator,
702
- m = s && o[s],
703
- i = 0;
704
- if (m) return m.call(o);
705
- if (o && typeof o.length === "number") return {
706
- next: function next() {
707
- if (o && i >= o.length) o = void 0;
708
- return {
709
- value: o && o[i++],
710
- done: !o
711
- };
712
- }
713
- };
714
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
715
- };
716
850
 
717
851
 
718
852
 
719
853
 
720
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('InMemoryCache');
854
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('InMemoryCache');
721
855
  /**
722
856
  * Customized in-memory cache with LRU implemented
723
857
  * @member cacheObj - object which store items
@@ -726,22 +860,16 @@ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]
726
860
  * @member maxPriority - max of the priority
727
861
  * @member cacheSizeLimit - the limit of cache size
728
862
  */
729
-
730
- var InMemoryCacheClass =
731
- /** @class */
732
- function (_super) {
733
- __extends(InMemoryCacheClass, _super);
863
+ var InMemoryCacheClass = /** @class */function (_super) {
864
+ Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InMemoryCacheClass, _super);
734
865
  /**
735
866
  * initialize the cache
736
867
  *
737
868
  * @param config - the configuration of the cache
738
869
  */
739
-
740
-
741
870
  function InMemoryCacheClass(config) {
742
871
  var _this = this;
743
-
744
- var cacheConfig = config ? Object.assign({}, _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"], config) : _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"];
872
+ var cacheConfig = config ? Object.assign({}, _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"], config) : _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"];
745
873
  _this = _super.call(this, cacheConfig) || this;
746
874
  logger.debug('now we start!');
747
875
  _this.cacheList = [];
@@ -749,12 +877,11 @@ function (_super) {
749
877
  _this.maxPriority = 5;
750
878
  _this.getItem = _this.getItem.bind(_this);
751
879
  _this.setItem = _this.setItem.bind(_this);
752
- _this.removeItem = _this.removeItem.bind(_this); // initialize list for every priority
753
-
880
+ _this.removeItem = _this.removeItem.bind(_this);
881
+ // initialize list for every priority
754
882
  for (var i = 0; i < _this.maxPriority; i += 1) {
755
- _this.cacheList[i] = new _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheList"]();
883
+ _this.cacheList[i] = new _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheList"]();
756
884
  }
757
-
758
885
  return _this;
759
886
  }
760
887
  /**
@@ -762,8 +889,6 @@ function (_super) {
762
889
  *
763
890
  * @param amount - the amount of the cache size which needs to be decreased
764
891
  */
765
-
766
-
767
892
  InMemoryCacheClass.prototype._decreaseCurSizeInBytes = function (amount) {
768
893
  this.curSizeInBytes -= amount;
769
894
  };
@@ -772,8 +897,6 @@ function (_super) {
772
897
  *
773
898
  * @param amount - the amount of the cache szie which need to be increased
774
899
  */
775
-
776
-
777
900
  InMemoryCacheClass.prototype._increaseCurSizeInBytes = function (amount) {
778
901
  this.curSizeInBytes += amount;
779
902
  };
@@ -784,16 +907,12 @@ function (_super) {
784
907
  *
785
908
  * @return true if the item is expired.
786
909
  */
787
-
788
-
789
910
  InMemoryCacheClass.prototype._isExpired = function (key) {
790
- var text = _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].getItem(key);
911
+ var text = _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].getItem(key);
791
912
  var item = JSON.parse(text);
792
-
793
- if (Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])() >= item.expires) {
913
+ if (Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])() >= item.expires) {
794
914
  return true;
795
915
  }
796
-
797
916
  return false;
798
917
  };
799
918
  /**
@@ -802,16 +921,13 @@ function (_super) {
802
921
  * @param prefixedKey - the key of the item
803
922
  * @param listIdx - indicates which cache list the key belongs to
804
923
  */
805
-
806
-
807
924
  InMemoryCacheClass.prototype._removeItem = function (prefixedKey, listIdx) {
808
925
  // delete the key from the list
809
- this.cacheList[listIdx].removeItem(prefixedKey); // decrease the current size of the cache
810
-
811
- this._decreaseCurSizeInBytes(JSON.parse(_Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].getItem(prefixedKey)).byteSize); // finally remove the item from memory
812
-
813
-
814
- _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].removeItem(prefixedKey);
926
+ this.cacheList[listIdx].removeItem(prefixedKey);
927
+ // decrease the current size of the cache
928
+ this._decreaseCurSizeInBytes(JSON.parse(_Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].getItem(prefixedKey)).byteSize);
929
+ // finally remove the item from memory
930
+ _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].removeItem(prefixedKey);
815
931
  };
816
932
  /**
817
933
  * put item into cache
@@ -821,16 +937,13 @@ function (_super) {
821
937
  * @param itemSizeInBytes - the byte size of the item
822
938
  * @param listIdx - indicates which cache list the key belongs to
823
939
  */
824
-
825
-
826
940
  InMemoryCacheClass.prototype._setItem = function (prefixedKey, item, listIdx) {
827
941
  // insert the key into the list
828
- this.cacheList[listIdx].insertItem(prefixedKey); // increase the current size of the cache
829
-
830
- this._increaseCurSizeInBytes(item.byteSize); // finally add the item into memory
831
-
832
-
833
- _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].setItem(prefixedKey, JSON.stringify(item));
942
+ this.cacheList[listIdx].insertItem(prefixedKey);
943
+ // increase the current size of the cache
944
+ this._increaseCurSizeInBytes(item.byteSize);
945
+ // finally add the item into memory
946
+ _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].setItem(prefixedKey, JSON.stringify(item));
834
947
  };
835
948
  /**
836
949
  * see whether cache is full
@@ -839,8 +952,6 @@ function (_super) {
839
952
  *
840
953
  * @return true if cache is full
841
954
  */
842
-
843
-
844
955
  InMemoryCacheClass.prototype._isCacheFull = function (itemSize) {
845
956
  return this.curSizeInBytes + itemSize > this.config.capacityInBytes;
846
957
  };
@@ -849,17 +960,13 @@ function (_super) {
849
960
  *
850
961
  * @param key
851
962
  */
852
-
853
-
854
963
  InMemoryCacheClass.prototype.containsKey = function (key) {
855
964
  var prefixedKey = this.config.keyPrefix + key;
856
-
857
965
  for (var i = 0; i < this.maxPriority; i += 1) {
858
966
  if (this.cacheList[i].containsKey(prefixedKey)) {
859
967
  return i + 1;
860
968
  }
861
969
  }
862
-
863
970
  return -1;
864
971
  };
865
972
  /**
@@ -881,59 +988,47 @@ function (_super) {
881
988
  * @throws if the item is too big which exceeds the limit of single item size
882
989
  * @throws if the key is invalid
883
990
  */
884
-
885
-
886
991
  InMemoryCacheClass.prototype.setItem = function (key, value, options) {
887
- var prefixedKey = this.config.keyPrefix + key; // invalid keys
888
-
992
+ var prefixedKey = this.config.keyPrefix + key;
993
+ // invalid keys
889
994
  if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
890
995
  logger.warn("Invalid key: should not be empty or 'CurSize'");
891
996
  return;
892
997
  }
893
-
894
998
  if (typeof value === 'undefined') {
895
999
  logger.warn("The value of item should not be undefined!");
896
1000
  return;
897
1001
  }
898
-
899
1002
  var cacheItemOptions = {
900
1003
  priority: options && options.priority !== undefined ? options.priority : this.config.defaultPriority,
901
- expires: options && options.expires !== undefined ? options.expires : this.config.defaultTTL + Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])()
1004
+ expires: options && options.expires !== undefined ? options.expires : this.config.defaultTTL + Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])()
902
1005
  };
903
-
904
1006
  if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {
905
1007
  logger.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");
906
1008
  return;
907
1009
  }
908
-
909
- var item = this.fillCacheItem(prefixedKey, value, cacheItemOptions); // check wether this item is too big;
910
-
1010
+ var item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);
1011
+ // check wether this item is too big;
911
1012
  if (item.byteSize > this.config.itemMaxSize) {
912
1013
  logger.warn("Item with key: " + key + " you are trying to put into is too big!");
913
1014
  return;
914
- } // if key already in the cache, then delete it.
915
-
916
-
1015
+ }
1016
+ // if key already in the cache, then delete it.
917
1017
  var presentKeyPrio = this.containsKey(key);
918
-
919
1018
  if (presentKeyPrio !== -1) {
920
1019
  this._removeItem(prefixedKey, presentKeyPrio - 1);
921
- } // pop out items in the cache when cache is full based on LRU
1020
+ }
1021
+ // pop out items in the cache when cache is full based on LRU
922
1022
  // first start from lowest priority cache list
923
-
924
-
925
1023
  var cacheListIdx = this.maxPriority - 1;
926
-
927
1024
  while (this._isCacheFull(item.byteSize) && cacheListIdx >= 0) {
928
1025
  if (!this.cacheList[cacheListIdx].isEmpty()) {
929
1026
  var popedItemKey = this.cacheList[cacheListIdx].getLastItem();
930
-
931
1027
  this._removeItem(popedItemKey, cacheListIdx);
932
1028
  } else {
933
1029
  cacheListIdx -= 1;
934
1030
  }
935
1031
  }
936
-
937
1032
  this._setItem(prefixedKey, item, Number(item.priority) - 1);
938
1033
  };
939
1034
  /**
@@ -948,43 +1043,34 @@ function (_super) {
948
1043
  * @param key - the key of the item
949
1044
  * @param options - the options of callback function
950
1045
  */
951
-
952
-
953
1046
  InMemoryCacheClass.prototype.getItem = function (key, options) {
954
1047
  var ret = null;
955
1048
  var prefixedKey = this.config.keyPrefix + key;
956
-
957
1049
  if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
958
1050
  logger.warn("Invalid key: should not be empty or 'CurSize'");
959
1051
  return null;
960
- } // check whether it's in the cachelist
961
-
962
-
1052
+ }
1053
+ // check whether it's in the cachelist
963
1054
  var presentKeyPrio = this.containsKey(key);
964
-
965
1055
  if (presentKeyPrio !== -1) {
966
1056
  if (this._isExpired(prefixedKey)) {
967
1057
  // if expired, remove that item and return null
968
1058
  this._removeItem(prefixedKey, presentKeyPrio - 1);
969
1059
  } else {
970
1060
  // if not expired, great, return the value and refresh it
971
- ret = _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].getItem(prefixedKey);
1061
+ ret = _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].getItem(prefixedKey);
972
1062
  var item = JSON.parse(ret);
973
1063
  this.cacheList[item.priority - 1].refresh(prefixedKey);
974
1064
  return item.data;
975
1065
  }
976
1066
  }
977
-
978
1067
  if (options && options.callback !== undefined) {
979
1068
  var val = options.callback();
980
-
981
1069
  if (val !== null) {
982
1070
  this.setItem(key, val, options);
983
1071
  }
984
-
985
1072
  return val;
986
1073
  }
987
-
988
1074
  return null;
989
1075
  };
990
1076
  /**
@@ -992,13 +1078,10 @@ function (_super) {
992
1078
  *
993
1079
  * @param key - the key of the item
994
1080
  */
995
-
996
-
997
1081
  InMemoryCacheClass.prototype.removeItem = function (key) {
998
- var prefixedKey = this.config.keyPrefix + key; // check if the key is in the cache
999
-
1082
+ var prefixedKey = this.config.keyPrefix + key;
1083
+ // check if the key is in the cache
1000
1084
  var presentKeyPrio = this.containsKey(key);
1001
-
1002
1085
  if (presentKeyPrio !== -1) {
1003
1086
  this._removeItem(prefixedKey, presentKeyPrio - 1);
1004
1087
  }
@@ -1006,16 +1089,12 @@ function (_super) {
1006
1089
  /**
1007
1090
  * clear the entire cache
1008
1091
  */
1009
-
1010
-
1011
1092
  InMemoryCacheClass.prototype.clear = function () {
1012
1093
  var e_1, _a;
1013
-
1014
1094
  for (var i = 0; i < this.maxPriority; i += 1) {
1015
1095
  try {
1016
- for (var _b = (e_1 = void 0, __values(this.cacheList[i].getKeys())), _c = _b.next(); !_c.done; _c = _b.next()) {
1096
+ for (var _b = (e_1 = void 0, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(this.cacheList[i].getKeys())), _c = _b.next(); !_c.done; _c = _b.next()) {
1017
1097
  var key = _c.value;
1018
-
1019
1098
  this._removeItem(key, i);
1020
1099
  }
1021
1100
  } catch (e_1_1) {
@@ -1034,16 +1113,12 @@ function (_super) {
1034
1113
  /**
1035
1114
  * Return all the keys in the cache.
1036
1115
  */
1037
-
1038
-
1039
1116
  InMemoryCacheClass.prototype.getAllKeys = function () {
1040
1117
  var e_2, _a;
1041
-
1042
1118
  var keys = [];
1043
-
1044
1119
  for (var i = 0; i < this.maxPriority; i += 1) {
1045
1120
  try {
1046
- for (var _b = (e_2 = void 0, __values(this.cacheList[i].getKeys())), _c = _b.next(); !_c.done; _c = _b.next()) {
1121
+ for (var _b = (e_2 = void 0, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(this.cacheList[i].getKeys())), _c = _b.next(); !_c.done; _c = _b.next()) {
1047
1122
  var key = _c.value;
1048
1123
  keys.push(key.substring(this.config.keyPrefix.length));
1049
1124
  }
@@ -1059,7 +1134,6 @@ function (_super) {
1059
1134
  }
1060
1135
  }
1061
1136
  }
1062
-
1063
1137
  return keys;
1064
1138
  };
1065
1139
  /**
@@ -1067,8 +1141,6 @@ function (_super) {
1067
1141
  *
1068
1142
  * @return the current size of the cache
1069
1143
  */
1070
-
1071
-
1072
1144
  InMemoryCacheClass.prototype.getCacheCurSize = function () {
1073
1145
  return this.curSizeInBytes;
1074
1146
  };
@@ -1076,21 +1148,16 @@ function (_super) {
1076
1148
  * Return a new instance of cache with customized configuration.
1077
1149
  * @param config - the customized configuration
1078
1150
  */
1079
-
1080
-
1081
1151
  InMemoryCacheClass.prototype.createInstance = function (config) {
1082
1152
  return new InMemoryCacheClass(config);
1083
1153
  };
1084
-
1085
1154
  return InMemoryCacheClass;
1086
- }(_StorageCache__WEBPACK_IMPORTED_MODULE_1__["StorageCache"]);
1087
-
1155
+ }(_StorageCache__WEBPACK_IMPORTED_MODULE_2__["StorageCache"]);
1088
1156
 
1089
1157
  var InMemoryCache = new InMemoryCacheClass();
1090
1158
  /**
1091
1159
  * @deprecated use named import
1092
1160
  */
1093
-
1094
1161
  /* harmony default export */ __webpack_exports__["default"] = (InMemoryCache);
1095
1162
 
1096
1163
  /***/ }),
@@ -1131,17 +1198,12 @@ function _typeof(obj) {
1131
1198
  */
1132
1199
 
1133
1200
 
1134
-
1135
-
1136
1201
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('StorageCache');
1137
1202
  /**
1138
1203
  * Initialization of the cache
1139
1204
  *
1140
1205
  */
1141
-
1142
- var StorageCache =
1143
- /** @class */
1144
- function () {
1206
+ var StorageCache = /** @class */function () {
1145
1207
  /**
1146
1208
  * Initialize the cache
1147
1209
  * @param config - the configuration of the cache
@@ -1151,51 +1213,41 @@ function () {
1151
1213
  this.cacheCurSizeKey = this.config.keyPrefix + 'CurSize';
1152
1214
  this.checkConfig();
1153
1215
  }
1154
-
1155
1216
  StorageCache.prototype.getModuleName = function () {
1156
1217
  return 'Cache';
1157
1218
  };
1158
-
1159
1219
  StorageCache.prototype.checkConfig = function () {
1160
1220
  // check configuration
1161
1221
  if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.capacityInBytes)) {
1162
1222
  logger.error('Invalid parameter: capacityInBytes. It should be an Integer. Setting back to default.');
1163
1223
  this.config.capacityInBytes = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].capacityInBytes;
1164
1224
  }
1165
-
1166
1225
  if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.itemMaxSize)) {
1167
1226
  logger.error('Invalid parameter: itemMaxSize. It should be an Integer. Setting back to default.');
1168
1227
  this.config.itemMaxSize = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].itemMaxSize;
1169
1228
  }
1170
-
1171
1229
  if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.defaultTTL)) {
1172
1230
  logger.error('Invalid parameter: defaultTTL. It should be an Integer. Setting back to default.');
1173
1231
  this.config.defaultTTL = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultTTL;
1174
1232
  }
1175
-
1176
1233
  if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.defaultPriority)) {
1177
1234
  logger.error('Invalid parameter: defaultPriority. It should be an Integer. Setting back to default.');
1178
1235
  this.config.defaultPriority = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultPriority;
1179
1236
  }
1180
-
1181
1237
  if (this.config.itemMaxSize > this.config.capacityInBytes) {
1182
1238
  logger.error('Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default.');
1183
1239
  this.config.itemMaxSize = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].itemMaxSize;
1184
1240
  }
1185
-
1186
1241
  if (this.config.defaultPriority > 5 || this.config.defaultPriority < 1) {
1187
1242
  logger.error('Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default.');
1188
1243
  this.config.defaultPriority = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultPriority;
1189
1244
  }
1190
-
1191
1245
  if (Number(this.config.warningThreshold) > 1 || Number(this.config.warningThreshold) < 0) {
1192
1246
  logger.error('Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default.');
1193
1247
  this.config.warningThreshold = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].warningThreshold;
1194
- } // set 5MB limit
1195
-
1196
-
1248
+ }
1249
+ // set 5MB limit
1197
1250
  var cacheLimit = 5 * 1024 * 1024;
1198
-
1199
1251
  if (this.config.capacityInBytes > cacheLimit) {
1200
1252
  logger.error('Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.');
1201
1253
  this.config.capacityInBytes = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].capacityInBytes;
@@ -1208,8 +1260,6 @@ function () {
1208
1260
  *
1209
1261
  * @return - the item which has the meta-data and the value
1210
1262
  */
1211
-
1212
-
1213
1263
  StorageCache.prototype.fillCacheItem = function (key, value, options) {
1214
1264
  var ret = {
1215
1265
  key: key,
@@ -1221,8 +1271,8 @@ function () {
1221
1271
  type: _typeof(value),
1222
1272
  byteSize: 0
1223
1273
  };
1224
- ret.byteSize = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"])(JSON.stringify(ret)); // for accurate size
1225
-
1274
+ ret.byteSize = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"])(JSON.stringify(ret));
1275
+ // for accurate size
1226
1276
  ret.byteSize = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"])(JSON.stringify(ret));
1227
1277
  return ret;
1228
1278
  };
@@ -1232,30 +1282,23 @@ function () {
1232
1282
  *
1233
1283
  * @return - the current configuration
1234
1284
  */
1235
-
1236
-
1237
1285
  StorageCache.prototype.configure = function (config) {
1238
1286
  if (!config) {
1239
1287
  return this.config;
1240
1288
  }
1241
-
1242
1289
  if (config.keyPrefix) {
1243
1290
  logger.warn("Don't try to configure keyPrefix!");
1244
1291
  }
1245
-
1246
1292
  this.config = Object.assign({}, this.config, config, config.Cache);
1247
1293
  this.checkConfig();
1248
1294
  return this.config;
1249
1295
  };
1250
-
1251
1296
  return StorageCache;
1252
1297
  }();
1253
1298
 
1254
-
1255
1299
  /**
1256
1300
  * @deprecated use named import
1257
1301
  */
1258
-
1259
1302
  /* harmony default export */ __webpack_exports__["default"] = (StorageCache);
1260
1303
 
1261
1304
  /***/ }),
@@ -1269,6 +1312,7 @@ function () {
1269
1312
 
1270
1313
  "use strict";
1271
1314
  __webpack_require__.r(__webpack_exports__);
1315
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
1272
1316
  /*
1273
1317
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1274
1318
  *
@@ -1281,32 +1325,13 @@ __webpack_require__.r(__webpack_exports__);
1281
1325
  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1282
1326
  * and limitations under the License.
1283
1327
  */
1284
- var __values = undefined && undefined.__values || function (o) {
1285
- var s = typeof Symbol === "function" && Symbol.iterator,
1286
- m = s && o[s],
1287
- i = 0;
1288
- if (m) return m.call(o);
1289
- if (o && typeof o.length === "number") return {
1290
- next: function next() {
1291
- if (o && i >= o.length) o = void 0;
1292
- return {
1293
- value: o && o[i++],
1294
- done: !o
1295
- };
1296
- }
1297
- };
1298
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1299
- };
1300
1328
 
1301
- var DoubleLinkedNode =
1302
- /** @class */
1303
- function () {
1329
+ var DoubleLinkedNode = /** @class */function () {
1304
1330
  function DoubleLinkedNode(keyVal) {
1305
1331
  this.key = keyVal ? keyVal : '';
1306
1332
  this.prevNode = null;
1307
1333
  this.nextNode = null;
1308
1334
  }
1309
-
1310
1335
  return DoubleLinkedNode;
1311
1336
  }();
1312
1337
  /**
@@ -1320,11 +1345,7 @@ function () {
1320
1345
  * @member hashtable - the hashtable which maps cache key to list node
1321
1346
  * @member length - length of the list
1322
1347
  */
1323
-
1324
-
1325
- var CacheList =
1326
- /** @class */
1327
- function () {
1348
+ var CacheList = /** @class */function () {
1328
1349
  /**
1329
1350
  * initialization
1330
1351
  */
@@ -1341,8 +1362,6 @@ function () {
1341
1362
  *
1342
1363
  * @param node
1343
1364
  */
1344
-
1345
-
1346
1365
  CacheList.prototype.insertNodeToHead = function (node) {
1347
1366
  var tmp = this.head.nextNode;
1348
1367
  this.head.nextNode = node;
@@ -1356,8 +1375,6 @@ function () {
1356
1375
  *
1357
1376
  * @param node
1358
1377
  */
1359
-
1360
-
1361
1378
  CacheList.prototype.removeNode = function (node) {
1362
1379
  node.prevNode.nextNode = node.nextNode;
1363
1380
  node.nextNode.prevNode = node.prevNode;
@@ -1368,8 +1385,6 @@ function () {
1368
1385
  /**
1369
1386
  * @return true if list is empty
1370
1387
  */
1371
-
1372
-
1373
1388
  CacheList.prototype.isEmpty = function () {
1374
1389
  return this.length === 0;
1375
1390
  };
@@ -1378,8 +1393,6 @@ function () {
1378
1393
  *
1379
1394
  * @param key - key of the node
1380
1395
  */
1381
-
1382
-
1383
1396
  CacheList.prototype.refresh = function (key) {
1384
1397
  var node = this.hashtable[key];
1385
1398
  this.removeNode(node);
@@ -1390,8 +1403,6 @@ function () {
1390
1403
  *
1391
1404
  * @param key - the key of the node
1392
1405
  */
1393
-
1394
-
1395
1406
  CacheList.prototype.insertItem = function (key) {
1396
1407
  var node = new DoubleLinkedNode(key);
1397
1408
  this.hashtable[key] = node;
@@ -1400,8 +1411,6 @@ function () {
1400
1411
  /**
1401
1412
  * @return the LAST Recently Visited key
1402
1413
  */
1403
-
1404
-
1405
1414
  CacheList.prototype.getLastItem = function () {
1406
1415
  return this.tail.prevNode.key;
1407
1416
  };
@@ -1409,8 +1418,6 @@ function () {
1409
1418
  * remove the cache key from the list and hashtable
1410
1419
  * @param key - the key of the node
1411
1420
  */
1412
-
1413
-
1414
1421
  CacheList.prototype.removeItem = function (key) {
1415
1422
  var removedItem = this.hashtable[key];
1416
1423
  this.removeNode(removedItem);
@@ -1419,8 +1426,6 @@ function () {
1419
1426
  /**
1420
1427
  * @return length of the list
1421
1428
  */
1422
-
1423
-
1424
1429
  CacheList.prototype.getSize = function () {
1425
1430
  return this.length;
1426
1431
  };
@@ -1428,23 +1433,17 @@ function () {
1428
1433
  * @return true if the key is in the hashtable
1429
1434
  * @param key
1430
1435
  */
1431
-
1432
-
1433
1436
  CacheList.prototype.containsKey = function (key) {
1434
1437
  return key in this.hashtable;
1435
1438
  };
1436
1439
  /**
1437
1440
  * clean up the list and hashtable
1438
1441
  */
1439
-
1440
-
1441
1442
  CacheList.prototype.clearList = function () {
1442
1443
  var e_1, _a;
1443
-
1444
1444
  try {
1445
- for (var _b = __values(Object.keys(this.hashtable)), _c = _b.next(); !_c.done; _c = _b.next()) {
1445
+ for (var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(Object.keys(this.hashtable)), _c = _b.next(); !_c.done; _c = _b.next()) {
1446
1446
  var key = _c.value;
1447
-
1448
1447
  if (this.hashtable.hasOwnProperty(key)) {
1449
1448
  delete this.hashtable[key];
1450
1449
  }
@@ -1460,7 +1459,6 @@ function () {
1460
1459
  if (e_1) throw e_1.error;
1461
1460
  }
1462
1461
  }
1463
-
1464
1462
  this.head.nextNode = this.tail;
1465
1463
  this.tail.prevNode = this.head;
1466
1464
  this.length = 0;
@@ -1468,8 +1466,6 @@ function () {
1468
1466
  /**
1469
1467
  * @return all keys in the hashtable
1470
1468
  */
1471
-
1472
-
1473
1469
  CacheList.prototype.getKeys = function () {
1474
1470
  return Object.keys(this.hashtable);
1475
1471
  };
@@ -1479,8 +1475,6 @@ function () {
1479
1475
  * @param key
1480
1476
  * @return true if key is the head node
1481
1477
  */
1482
-
1483
-
1484
1478
  CacheList.prototype.isHeadNode = function (key) {
1485
1479
  var node = this.hashtable[key];
1486
1480
  return node.prevNode === this.head;
@@ -1491,16 +1485,12 @@ function () {
1491
1485
  * @param key
1492
1486
  * @return true if key is the tail node
1493
1487
  */
1494
-
1495
-
1496
1488
  CacheList.prototype.isTailNode = function (key) {
1497
1489
  var node = this.hashtable[key];
1498
1490
  return node.nextNode === this.tail;
1499
1491
  };
1500
-
1501
1492
  return CacheList;
1502
1493
  }();
1503
-
1504
1494
  /* harmony default export */ __webpack_exports__["default"] = (CacheList);
1505
1495
 
1506
1496
  /***/ }),
@@ -1537,7 +1527,6 @@ __webpack_require__.r(__webpack_exports__);
1537
1527
  /**
1538
1528
  * Default cache config
1539
1529
  */
1540
-
1541
1530
  var defaultConfig = {
1542
1531
  keyPrefix: 'aws-amplify-cache',
1543
1532
  capacityInBytes: 1048576,
@@ -1553,32 +1542,26 @@ var defaultConfig = {
1553
1542
  * return the byte size of the string
1554
1543
  * @param str
1555
1544
  */
1556
-
1557
1545
  function getByteLength(str) {
1558
1546
  var ret = 0;
1559
1547
  ret = str.length;
1560
-
1561
1548
  for (var i = str.length; i >= 0; i -= 1) {
1562
1549
  var charCode = str.charCodeAt(i);
1563
-
1564
1550
  if (charCode > 0x7f && charCode <= 0x7ff) {
1565
1551
  ret += 1;
1566
1552
  } else if (charCode > 0x7ff && charCode <= 0xffff) {
1567
1553
  ret += 2;
1568
- } // trail surrogate
1569
-
1570
-
1554
+ }
1555
+ // trail surrogate
1571
1556
  if (charCode >= 0xdc00 && charCode <= 0xdfff) {
1572
1557
  i -= 1;
1573
1558
  }
1574
1559
  }
1575
-
1576
1560
  return ret;
1577
1561
  }
1578
1562
  /**
1579
1563
  * get current time
1580
1564
  */
1581
-
1582
1565
  function getCurrTime() {
1583
1566
  var currTime = new Date();
1584
1567
  return currTime.getTime();
@@ -1586,51 +1569,37 @@ function getCurrTime() {
1586
1569
  /**
1587
1570
  * check if passed value is an integer
1588
1571
  */
1589
-
1590
1572
  function isInteger(value) {
1591
1573
  if (Number.isInteger) {
1592
1574
  return Number.isInteger(value);
1593
1575
  }
1594
-
1595
1576
  return _isInteger(value);
1596
1577
  }
1597
-
1598
1578
  function _isInteger(value) {
1599
1579
  return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
1600
1580
  }
1601
1581
  /**
1602
1582
  * provide an object as the in-memory cache
1603
1583
  */
1604
-
1605
-
1606
1584
  var store = {};
1607
-
1608
- var CacheObject =
1609
- /** @class */
1610
- function () {
1585
+ var CacheObject = /** @class */function () {
1611
1586
  function CacheObject() {}
1612
-
1613
1587
  CacheObject.clear = function () {
1614
1588
  store = {};
1615
1589
  };
1616
-
1617
1590
  CacheObject.getItem = function (key) {
1618
1591
  return store[key] || null;
1619
1592
  };
1620
-
1621
1593
  CacheObject.setItem = function (key, value) {
1622
1594
  store[key] = value;
1623
1595
  };
1624
-
1625
1596
  CacheObject.removeItem = function (key) {
1626
1597
  delete store[key];
1627
1598
  };
1628
-
1629
1599
  return CacheObject;
1630
1600
  }();
1631
1601
 
1632
1602
 
1633
-
1634
1603
  /***/ }),
1635
1604
 
1636
1605
  /***/ "./lib-esm/Utils/index.js":
@@ -1709,7 +1678,6 @@ __webpack_require__.r(__webpack_exports__);
1709
1678
  /**
1710
1679
  * @deprecated use named import
1711
1680
  */
1712
-
1713
1681
  /* harmony default export */ __webpack_exports__["default"] = (_BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]);
1714
1682
  _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Amplify"].register(_BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]);
1715
1683