@common.js/quick-lru 6.1.1
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.
- package/README.md +5 -0
- package/index.d.ts +123 -0
- package/index.js +1176 -0
- package/license +9 -0
- package/package.json +35 -0
- package/readme.md +157 -0
package/index.js
ADDED
|
@@ -0,0 +1,1176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return QuickLRU;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function _arrayLikeToArray(arr, len) {
|
|
12
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
13
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
14
|
+
return arr2;
|
|
15
|
+
}
|
|
16
|
+
function _arrayWithHoles(arr) {
|
|
17
|
+
if (Array.isArray(arr)) return arr;
|
|
18
|
+
}
|
|
19
|
+
function _arrayWithoutHoles(arr) {
|
|
20
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
21
|
+
}
|
|
22
|
+
function _assertThisInitialized(self) {
|
|
23
|
+
if (self === void 0) {
|
|
24
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
25
|
+
}
|
|
26
|
+
return self;
|
|
27
|
+
}
|
|
28
|
+
function _classCallCheck(instance, Constructor) {
|
|
29
|
+
if (!(instance instanceof Constructor)) {
|
|
30
|
+
throw new TypeError("Cannot call a class as a function");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function isNativeReflectConstruct() {
|
|
34
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
35
|
+
if (Reflect.construct.sham) return false;
|
|
36
|
+
if (typeof Proxy === "function") return true;
|
|
37
|
+
try {
|
|
38
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
|
|
39
|
+
return true;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _construct(Parent, args, Class) {
|
|
45
|
+
if (isNativeReflectConstruct()) {
|
|
46
|
+
_construct = Reflect.construct;
|
|
47
|
+
} else {
|
|
48
|
+
_construct = function _construct(Parent, args, Class) {
|
|
49
|
+
var a = [
|
|
50
|
+
null
|
|
51
|
+
];
|
|
52
|
+
a.push.apply(a, args);
|
|
53
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
54
|
+
var instance = new Constructor();
|
|
55
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
56
|
+
return instance;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return _construct.apply(null, arguments);
|
|
60
|
+
}
|
|
61
|
+
function _defineProperties(target, props) {
|
|
62
|
+
for(var i = 0; i < props.length; i++){
|
|
63
|
+
var descriptor = props[i];
|
|
64
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
65
|
+
descriptor.configurable = true;
|
|
66
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
67
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
71
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
72
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
73
|
+
return Constructor;
|
|
74
|
+
}
|
|
75
|
+
function _getPrototypeOf(o) {
|
|
76
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
77
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
78
|
+
};
|
|
79
|
+
return _getPrototypeOf(o);
|
|
80
|
+
}
|
|
81
|
+
function _inherits(subClass, superClass) {
|
|
82
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
83
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
84
|
+
}
|
|
85
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
86
|
+
constructor: {
|
|
87
|
+
value: subClass,
|
|
88
|
+
writable: true,
|
|
89
|
+
configurable: true
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
93
|
+
}
|
|
94
|
+
function _isNativeFunction(fn) {
|
|
95
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
96
|
+
}
|
|
97
|
+
function _iterableToArray(iter) {
|
|
98
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
99
|
+
}
|
|
100
|
+
function _iterableToArrayLimit(arr, i) {
|
|
101
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
102
|
+
if (_i == null) return;
|
|
103
|
+
var _arr = [];
|
|
104
|
+
var _n = true;
|
|
105
|
+
var _d = false;
|
|
106
|
+
var _s, _e;
|
|
107
|
+
try {
|
|
108
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
109
|
+
_arr.push(_s.value);
|
|
110
|
+
if (i && _arr.length === i) break;
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
_d = true;
|
|
114
|
+
_e = err;
|
|
115
|
+
} finally{
|
|
116
|
+
try {
|
|
117
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
118
|
+
} finally{
|
|
119
|
+
if (_d) throw _e;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return _arr;
|
|
123
|
+
}
|
|
124
|
+
function _nonIterableRest() {
|
|
125
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
126
|
+
}
|
|
127
|
+
function _nonIterableSpread() {
|
|
128
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
129
|
+
}
|
|
130
|
+
function _possibleConstructorReturn(self, call) {
|
|
131
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
132
|
+
return call;
|
|
133
|
+
}
|
|
134
|
+
return _assertThisInitialized(self);
|
|
135
|
+
}
|
|
136
|
+
function _setPrototypeOf(o, p) {
|
|
137
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
138
|
+
o.__proto__ = p;
|
|
139
|
+
return o;
|
|
140
|
+
};
|
|
141
|
+
return _setPrototypeOf(o, p);
|
|
142
|
+
}
|
|
143
|
+
function _slicedToArray(arr, i) {
|
|
144
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
145
|
+
}
|
|
146
|
+
function _toConsumableArray(arr) {
|
|
147
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
148
|
+
}
|
|
149
|
+
var _typeof = function(obj) {
|
|
150
|
+
"@swc/helpers - typeof";
|
|
151
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
152
|
+
};
|
|
153
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
154
|
+
if (!o) return;
|
|
155
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
156
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
157
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
158
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
159
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
160
|
+
}
|
|
161
|
+
function _wrapNativeSuper(Class) {
|
|
162
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
163
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
164
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
165
|
+
if (typeof Class !== "function") {
|
|
166
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
167
|
+
}
|
|
168
|
+
if (typeof _cache !== "undefined") {
|
|
169
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
170
|
+
_cache.set(Class, Wrapper);
|
|
171
|
+
}
|
|
172
|
+
function Wrapper() {
|
|
173
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
174
|
+
}
|
|
175
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
176
|
+
constructor: {
|
|
177
|
+
value: Wrapper,
|
|
178
|
+
enumerable: false,
|
|
179
|
+
writable: true,
|
|
180
|
+
configurable: true
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
184
|
+
};
|
|
185
|
+
return _wrapNativeSuper(Class);
|
|
186
|
+
}
|
|
187
|
+
function _isNativeReflectConstruct() {
|
|
188
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
189
|
+
if (Reflect.construct.sham) return false;
|
|
190
|
+
if (typeof Proxy === "function") return true;
|
|
191
|
+
try {
|
|
192
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
193
|
+
return true;
|
|
194
|
+
} catch (e) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function _createSuper(Derived) {
|
|
199
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
200
|
+
return function _createSuperInternal() {
|
|
201
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
202
|
+
if (hasNativeReflectConstruct) {
|
|
203
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
204
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
205
|
+
} else {
|
|
206
|
+
result = Super.apply(this, arguments);
|
|
207
|
+
}
|
|
208
|
+
return _possibleConstructorReturn(this, result);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
var __generator = (void 0) && (void 0).__generator || function(thisArg, body) {
|
|
212
|
+
var f, y, t, g, _ = {
|
|
213
|
+
label: 0,
|
|
214
|
+
sent: function() {
|
|
215
|
+
if (t[0] & 1) throw t[1];
|
|
216
|
+
return t[1];
|
|
217
|
+
},
|
|
218
|
+
trys: [],
|
|
219
|
+
ops: []
|
|
220
|
+
};
|
|
221
|
+
return g = {
|
|
222
|
+
next: verb(0),
|
|
223
|
+
"throw": verb(1),
|
|
224
|
+
"return": verb(2)
|
|
225
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
226
|
+
return this;
|
|
227
|
+
}), g;
|
|
228
|
+
function verb(n) {
|
|
229
|
+
return function(v) {
|
|
230
|
+
return step([
|
|
231
|
+
n,
|
|
232
|
+
v
|
|
233
|
+
]);
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function step(op) {
|
|
237
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
238
|
+
while(_)try {
|
|
239
|
+
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;
|
|
240
|
+
if (y = 0, t) op = [
|
|
241
|
+
op[0] & 2,
|
|
242
|
+
t.value
|
|
243
|
+
];
|
|
244
|
+
switch(op[0]){
|
|
245
|
+
case 0:
|
|
246
|
+
case 1:
|
|
247
|
+
t = op;
|
|
248
|
+
break;
|
|
249
|
+
case 4:
|
|
250
|
+
_.label++;
|
|
251
|
+
return {
|
|
252
|
+
value: op[1],
|
|
253
|
+
done: false
|
|
254
|
+
};
|
|
255
|
+
case 5:
|
|
256
|
+
_.label++;
|
|
257
|
+
y = op[1];
|
|
258
|
+
op = [
|
|
259
|
+
0
|
|
260
|
+
];
|
|
261
|
+
continue;
|
|
262
|
+
case 7:
|
|
263
|
+
op = _.ops.pop();
|
|
264
|
+
_.trys.pop();
|
|
265
|
+
continue;
|
|
266
|
+
default:
|
|
267
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
268
|
+
_ = 0;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
272
|
+
_.label = op[1];
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
276
|
+
_.label = t[1];
|
|
277
|
+
t = op;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
if (t && _.label < t[2]) {
|
|
281
|
+
_.label = t[2];
|
|
282
|
+
_.ops.push(op);
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
if (t[2]) _.ops.pop();
|
|
286
|
+
_.trys.pop();
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
op = body.call(thisArg, _);
|
|
290
|
+
} catch (e) {
|
|
291
|
+
op = [
|
|
292
|
+
6,
|
|
293
|
+
e
|
|
294
|
+
];
|
|
295
|
+
y = 0;
|
|
296
|
+
} finally{
|
|
297
|
+
f = t = 0;
|
|
298
|
+
}
|
|
299
|
+
if (op[0] & 5) throw op[1];
|
|
300
|
+
return {
|
|
301
|
+
value: op[0] ? op[1] : void 0,
|
|
302
|
+
done: true
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
var QuickLRU = /*#__PURE__*/ function(Map1) {
|
|
307
|
+
"use strict";
|
|
308
|
+
_inherits(QuickLRU, Map1);
|
|
309
|
+
var _super = _createSuper(QuickLRU);
|
|
310
|
+
function QuickLRU() {
|
|
311
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
312
|
+
_classCallCheck(this, QuickLRU);
|
|
313
|
+
var _this;
|
|
314
|
+
_this = _super.call(this);
|
|
315
|
+
if (!(options.maxSize && options.maxSize > 0)) {
|
|
316
|
+
throw new TypeError("`maxSize` must be a number greater than 0");
|
|
317
|
+
}
|
|
318
|
+
if (typeof options.maxAge === "number" && options.maxAge === 0) {
|
|
319
|
+
throw new TypeError("`maxAge` must be a number greater than 0");
|
|
320
|
+
}
|
|
321
|
+
// TODO: Use private class fields when ESLint supports them.
|
|
322
|
+
_this.maxSize = options.maxSize;
|
|
323
|
+
_this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
|
|
324
|
+
_this.onEviction = options.onEviction;
|
|
325
|
+
_this.cache = new Map();
|
|
326
|
+
_this.oldCache = new Map();
|
|
327
|
+
_this._size = 0;
|
|
328
|
+
return _this;
|
|
329
|
+
}
|
|
330
|
+
_createClass(QuickLRU, [
|
|
331
|
+
{
|
|
332
|
+
// TODO: Use private class methods when targeting Node.js 16.
|
|
333
|
+
key: "_emitEvictions",
|
|
334
|
+
value: function _emitEvictions(cache) {
|
|
335
|
+
if (typeof this.onEviction !== "function") {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
339
|
+
try {
|
|
340
|
+
for(var _iterator = cache[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
341
|
+
var _value = _slicedToArray(_step.value, 2), key = _value[0], item = _value[1];
|
|
342
|
+
this.onEviction(key, item.value);
|
|
343
|
+
}
|
|
344
|
+
} catch (err) {
|
|
345
|
+
_didIteratorError = true;
|
|
346
|
+
_iteratorError = err;
|
|
347
|
+
} finally{
|
|
348
|
+
try {
|
|
349
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
350
|
+
_iterator.return();
|
|
351
|
+
}
|
|
352
|
+
} finally{
|
|
353
|
+
if (_didIteratorError) {
|
|
354
|
+
throw _iteratorError;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
key: "_deleteIfExpired",
|
|
362
|
+
value: function _deleteIfExpired(key, item) {
|
|
363
|
+
if (typeof item.expiry === "number" && item.expiry <= Date.now()) {
|
|
364
|
+
if (typeof this.onEviction === "function") {
|
|
365
|
+
this.onEviction(key, item.value);
|
|
366
|
+
}
|
|
367
|
+
return this.delete(key);
|
|
368
|
+
}
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
key: "_getOrDeleteIfExpired",
|
|
374
|
+
value: function _getOrDeleteIfExpired(key, item) {
|
|
375
|
+
var deleted = this._deleteIfExpired(key, item);
|
|
376
|
+
if (deleted === false) {
|
|
377
|
+
return item.value;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
key: "_getItemValue",
|
|
383
|
+
value: function _getItemValue(key, item) {
|
|
384
|
+
return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
key: "_peek",
|
|
389
|
+
value: function _peek(key, cache) {
|
|
390
|
+
var item = cache.get(key);
|
|
391
|
+
return this._getItemValue(key, item);
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
key: "_set",
|
|
396
|
+
value: function _set(key, value) {
|
|
397
|
+
this.cache.set(key, value);
|
|
398
|
+
this._size++;
|
|
399
|
+
if (this._size >= this.maxSize) {
|
|
400
|
+
this._size = 0;
|
|
401
|
+
this._emitEvictions(this.oldCache);
|
|
402
|
+
this.oldCache = this.cache;
|
|
403
|
+
this.cache = new Map();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
key: "_moveToRecent",
|
|
409
|
+
value: function _moveToRecent(key, item) {
|
|
410
|
+
this.oldCache.delete(key);
|
|
411
|
+
this._set(key, item);
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
key: "_entriesAscending",
|
|
416
|
+
value: function _entriesAscending() {
|
|
417
|
+
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, _item, key, value, deleted, err, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, item1, _item1, key1, value1, deleted1, err;
|
|
418
|
+
return __generator(this, function(_state) {
|
|
419
|
+
switch(_state.label){
|
|
420
|
+
case 0:
|
|
421
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
422
|
+
_state.label = 1;
|
|
423
|
+
case 1:
|
|
424
|
+
_state.trys.push([
|
|
425
|
+
1,
|
|
426
|
+
6,
|
|
427
|
+
7,
|
|
428
|
+
8
|
|
429
|
+
]);
|
|
430
|
+
_iterator = this.oldCache[Symbol.iterator]();
|
|
431
|
+
_state.label = 2;
|
|
432
|
+
case 2:
|
|
433
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
434
|
+
3,
|
|
435
|
+
5
|
|
436
|
+
];
|
|
437
|
+
item = _step.value;
|
|
438
|
+
_item = _slicedToArray(item, 2), key = _item[0], value = _item[1];
|
|
439
|
+
if (!!this.cache.has(key)) return [
|
|
440
|
+
3,
|
|
441
|
+
4
|
|
442
|
+
];
|
|
443
|
+
deleted = this._deleteIfExpired(key, value);
|
|
444
|
+
if (!(deleted === false)) return [
|
|
445
|
+
3,
|
|
446
|
+
4
|
|
447
|
+
];
|
|
448
|
+
return [
|
|
449
|
+
4,
|
|
450
|
+
item
|
|
451
|
+
];
|
|
452
|
+
case 3:
|
|
453
|
+
_state.sent();
|
|
454
|
+
_state.label = 4;
|
|
455
|
+
case 4:
|
|
456
|
+
_iteratorNormalCompletion = true;
|
|
457
|
+
return [
|
|
458
|
+
3,
|
|
459
|
+
2
|
|
460
|
+
];
|
|
461
|
+
case 5:
|
|
462
|
+
return [
|
|
463
|
+
3,
|
|
464
|
+
8
|
|
465
|
+
];
|
|
466
|
+
case 6:
|
|
467
|
+
err = _state.sent();
|
|
468
|
+
_didIteratorError = true;
|
|
469
|
+
_iteratorError = err;
|
|
470
|
+
return [
|
|
471
|
+
3,
|
|
472
|
+
8
|
|
473
|
+
];
|
|
474
|
+
case 7:
|
|
475
|
+
try {
|
|
476
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
477
|
+
_iterator.return();
|
|
478
|
+
}
|
|
479
|
+
} finally{
|
|
480
|
+
if (_didIteratorError) {
|
|
481
|
+
throw _iteratorError;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return [
|
|
485
|
+
7
|
|
486
|
+
];
|
|
487
|
+
case 8:
|
|
488
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
489
|
+
_state.label = 9;
|
|
490
|
+
case 9:
|
|
491
|
+
_state.trys.push([
|
|
492
|
+
9,
|
|
493
|
+
14,
|
|
494
|
+
15,
|
|
495
|
+
16
|
|
496
|
+
]);
|
|
497
|
+
_iterator1 = this.cache[Symbol.iterator]();
|
|
498
|
+
_state.label = 10;
|
|
499
|
+
case 10:
|
|
500
|
+
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
501
|
+
3,
|
|
502
|
+
13
|
|
503
|
+
];
|
|
504
|
+
item1 = _step1.value;
|
|
505
|
+
_item1 = _slicedToArray(item1, 2), key1 = _item1[0], value1 = _item1[1];
|
|
506
|
+
deleted1 = this._deleteIfExpired(key1, value1);
|
|
507
|
+
if (!(deleted1 === false)) return [
|
|
508
|
+
3,
|
|
509
|
+
12
|
|
510
|
+
];
|
|
511
|
+
return [
|
|
512
|
+
4,
|
|
513
|
+
item1
|
|
514
|
+
];
|
|
515
|
+
case 11:
|
|
516
|
+
_state.sent();
|
|
517
|
+
_state.label = 12;
|
|
518
|
+
case 12:
|
|
519
|
+
_iteratorNormalCompletion1 = true;
|
|
520
|
+
return [
|
|
521
|
+
3,
|
|
522
|
+
10
|
|
523
|
+
];
|
|
524
|
+
case 13:
|
|
525
|
+
return [
|
|
526
|
+
3,
|
|
527
|
+
16
|
|
528
|
+
];
|
|
529
|
+
case 14:
|
|
530
|
+
err = _state.sent();
|
|
531
|
+
_didIteratorError1 = true;
|
|
532
|
+
_iteratorError1 = err;
|
|
533
|
+
return [
|
|
534
|
+
3,
|
|
535
|
+
16
|
|
536
|
+
];
|
|
537
|
+
case 15:
|
|
538
|
+
try {
|
|
539
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
540
|
+
_iterator1.return();
|
|
541
|
+
}
|
|
542
|
+
} finally{
|
|
543
|
+
if (_didIteratorError1) {
|
|
544
|
+
throw _iteratorError1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return [
|
|
548
|
+
7
|
|
549
|
+
];
|
|
550
|
+
case 16:
|
|
551
|
+
return [
|
|
552
|
+
2
|
|
553
|
+
];
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
key: "get",
|
|
560
|
+
value: function get(key) {
|
|
561
|
+
if (this.cache.has(key)) {
|
|
562
|
+
var item = this.cache.get(key);
|
|
563
|
+
return this._getItemValue(key, item);
|
|
564
|
+
}
|
|
565
|
+
if (this.oldCache.has(key)) {
|
|
566
|
+
var item1 = this.oldCache.get(key);
|
|
567
|
+
if (this._deleteIfExpired(key, item1) === false) {
|
|
568
|
+
this._moveToRecent(key, item1);
|
|
569
|
+
return item1.value;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
key: "set",
|
|
576
|
+
value: function set(key, value) {
|
|
577
|
+
var ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, _maxAge = ref.maxAge, maxAge = _maxAge === void 0 ? this.maxAge : _maxAge;
|
|
578
|
+
var expiry = typeof maxAge === "number" && maxAge !== Number.POSITIVE_INFINITY ? Date.now() + maxAge : undefined;
|
|
579
|
+
if (this.cache.has(key)) {
|
|
580
|
+
this.cache.set(key, {
|
|
581
|
+
value: value,
|
|
582
|
+
expiry: expiry
|
|
583
|
+
});
|
|
584
|
+
} else {
|
|
585
|
+
this._set(key, {
|
|
586
|
+
value: value,
|
|
587
|
+
expiry: expiry
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
key: "has",
|
|
594
|
+
value: function has(key) {
|
|
595
|
+
if (this.cache.has(key)) {
|
|
596
|
+
return !this._deleteIfExpired(key, this.cache.get(key));
|
|
597
|
+
}
|
|
598
|
+
if (this.oldCache.has(key)) {
|
|
599
|
+
return !this._deleteIfExpired(key, this.oldCache.get(key));
|
|
600
|
+
}
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
key: "peek",
|
|
606
|
+
value: function peek(key) {
|
|
607
|
+
if (this.cache.has(key)) {
|
|
608
|
+
return this._peek(key, this.cache);
|
|
609
|
+
}
|
|
610
|
+
if (this.oldCache.has(key)) {
|
|
611
|
+
return this._peek(key, this.oldCache);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
key: "delete",
|
|
617
|
+
value: function _delete(key) {
|
|
618
|
+
var deleted = this.cache.delete(key);
|
|
619
|
+
if (deleted) {
|
|
620
|
+
this._size--;
|
|
621
|
+
}
|
|
622
|
+
return this.oldCache.delete(key) || deleted;
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
key: "clear",
|
|
627
|
+
value: function clear() {
|
|
628
|
+
this.cache.clear();
|
|
629
|
+
this.oldCache.clear();
|
|
630
|
+
this._size = 0;
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
key: "resize",
|
|
635
|
+
value: function resize(newSize) {
|
|
636
|
+
if (!(newSize && newSize > 0)) {
|
|
637
|
+
throw new TypeError("`maxSize` must be a number greater than 0");
|
|
638
|
+
}
|
|
639
|
+
var items = _toConsumableArray(this._entriesAscending());
|
|
640
|
+
var removeCount = items.length - newSize;
|
|
641
|
+
if (removeCount < 0) {
|
|
642
|
+
this.cache = new Map(items);
|
|
643
|
+
this.oldCache = new Map();
|
|
644
|
+
this._size = items.length;
|
|
645
|
+
} else {
|
|
646
|
+
if (removeCount > 0) {
|
|
647
|
+
this._emitEvictions(items.slice(0, removeCount));
|
|
648
|
+
}
|
|
649
|
+
this.oldCache = new Map(items.slice(removeCount));
|
|
650
|
+
this.cache = new Map();
|
|
651
|
+
this._size = 0;
|
|
652
|
+
}
|
|
653
|
+
this.maxSize = newSize;
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
key: "keys",
|
|
658
|
+
value: function keys() {
|
|
659
|
+
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, key, err;
|
|
660
|
+
return __generator(this, function(_state) {
|
|
661
|
+
switch(_state.label){
|
|
662
|
+
case 0:
|
|
663
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
664
|
+
_state.label = 1;
|
|
665
|
+
case 1:
|
|
666
|
+
_state.trys.push([
|
|
667
|
+
1,
|
|
668
|
+
6,
|
|
669
|
+
7,
|
|
670
|
+
8
|
|
671
|
+
]);
|
|
672
|
+
_iterator = this[Symbol.iterator]();
|
|
673
|
+
_state.label = 2;
|
|
674
|
+
case 2:
|
|
675
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
676
|
+
3,
|
|
677
|
+
5
|
|
678
|
+
];
|
|
679
|
+
_value = _slicedToArray(_step.value, 1), key = _value[0];
|
|
680
|
+
return [
|
|
681
|
+
4,
|
|
682
|
+
key
|
|
683
|
+
];
|
|
684
|
+
case 3:
|
|
685
|
+
_state.sent();
|
|
686
|
+
_state.label = 4;
|
|
687
|
+
case 4:
|
|
688
|
+
_iteratorNormalCompletion = true;
|
|
689
|
+
return [
|
|
690
|
+
3,
|
|
691
|
+
2
|
|
692
|
+
];
|
|
693
|
+
case 5:
|
|
694
|
+
return [
|
|
695
|
+
3,
|
|
696
|
+
8
|
|
697
|
+
];
|
|
698
|
+
case 6:
|
|
699
|
+
err = _state.sent();
|
|
700
|
+
_didIteratorError = true;
|
|
701
|
+
_iteratorError = err;
|
|
702
|
+
return [
|
|
703
|
+
3,
|
|
704
|
+
8
|
|
705
|
+
];
|
|
706
|
+
case 7:
|
|
707
|
+
try {
|
|
708
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
709
|
+
_iterator.return();
|
|
710
|
+
}
|
|
711
|
+
} finally{
|
|
712
|
+
if (_didIteratorError) {
|
|
713
|
+
throw _iteratorError;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return [
|
|
717
|
+
7
|
|
718
|
+
];
|
|
719
|
+
case 8:
|
|
720
|
+
return [
|
|
721
|
+
2
|
|
722
|
+
];
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
key: "values",
|
|
729
|
+
value: function values() {
|
|
730
|
+
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value, err;
|
|
731
|
+
return __generator(this, function(_state) {
|
|
732
|
+
switch(_state.label){
|
|
733
|
+
case 0:
|
|
734
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
735
|
+
_state.label = 1;
|
|
736
|
+
case 1:
|
|
737
|
+
_state.trys.push([
|
|
738
|
+
1,
|
|
739
|
+
6,
|
|
740
|
+
7,
|
|
741
|
+
8
|
|
742
|
+
]);
|
|
743
|
+
_iterator = this[Symbol.iterator]();
|
|
744
|
+
_state.label = 2;
|
|
745
|
+
case 2:
|
|
746
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
747
|
+
3,
|
|
748
|
+
5
|
|
749
|
+
];
|
|
750
|
+
_value = _slicedToArray(_step.value, 2), value = _value[1];
|
|
751
|
+
return [
|
|
752
|
+
4,
|
|
753
|
+
value
|
|
754
|
+
];
|
|
755
|
+
case 3:
|
|
756
|
+
_state.sent();
|
|
757
|
+
_state.label = 4;
|
|
758
|
+
case 4:
|
|
759
|
+
_iteratorNormalCompletion = true;
|
|
760
|
+
return [
|
|
761
|
+
3,
|
|
762
|
+
2
|
|
763
|
+
];
|
|
764
|
+
case 5:
|
|
765
|
+
return [
|
|
766
|
+
3,
|
|
767
|
+
8
|
|
768
|
+
];
|
|
769
|
+
case 6:
|
|
770
|
+
err = _state.sent();
|
|
771
|
+
_didIteratorError = true;
|
|
772
|
+
_iteratorError = err;
|
|
773
|
+
return [
|
|
774
|
+
3,
|
|
775
|
+
8
|
|
776
|
+
];
|
|
777
|
+
case 7:
|
|
778
|
+
try {
|
|
779
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
780
|
+
_iterator.return();
|
|
781
|
+
}
|
|
782
|
+
} finally{
|
|
783
|
+
if (_didIteratorError) {
|
|
784
|
+
throw _iteratorError;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return [
|
|
788
|
+
7
|
|
789
|
+
];
|
|
790
|
+
case 8:
|
|
791
|
+
return [
|
|
792
|
+
2
|
|
793
|
+
];
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
key: Symbol.iterator,
|
|
800
|
+
value: function value() {
|
|
801
|
+
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, _item, key, value1, deleted, err, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, item1, _item1, key1, value2, deleted1, err;
|
|
802
|
+
return __generator(this, function(_state) {
|
|
803
|
+
switch(_state.label){
|
|
804
|
+
case 0:
|
|
805
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
806
|
+
_state.label = 1;
|
|
807
|
+
case 1:
|
|
808
|
+
_state.trys.push([
|
|
809
|
+
1,
|
|
810
|
+
6,
|
|
811
|
+
7,
|
|
812
|
+
8
|
|
813
|
+
]);
|
|
814
|
+
_iterator = this.cache[Symbol.iterator]();
|
|
815
|
+
_state.label = 2;
|
|
816
|
+
case 2:
|
|
817
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
818
|
+
3,
|
|
819
|
+
5
|
|
820
|
+
];
|
|
821
|
+
item = _step.value;
|
|
822
|
+
_item = _slicedToArray(item, 2), key = _item[0], value1 = _item[1];
|
|
823
|
+
deleted = this._deleteIfExpired(key, value1);
|
|
824
|
+
if (!(deleted === false)) return [
|
|
825
|
+
3,
|
|
826
|
+
4
|
|
827
|
+
];
|
|
828
|
+
return [
|
|
829
|
+
4,
|
|
830
|
+
[
|
|
831
|
+
key,
|
|
832
|
+
value1.value
|
|
833
|
+
]
|
|
834
|
+
];
|
|
835
|
+
case 3:
|
|
836
|
+
_state.sent();
|
|
837
|
+
_state.label = 4;
|
|
838
|
+
case 4:
|
|
839
|
+
_iteratorNormalCompletion = true;
|
|
840
|
+
return [
|
|
841
|
+
3,
|
|
842
|
+
2
|
|
843
|
+
];
|
|
844
|
+
case 5:
|
|
845
|
+
return [
|
|
846
|
+
3,
|
|
847
|
+
8
|
|
848
|
+
];
|
|
849
|
+
case 6:
|
|
850
|
+
err = _state.sent();
|
|
851
|
+
_didIteratorError = true;
|
|
852
|
+
_iteratorError = err;
|
|
853
|
+
return [
|
|
854
|
+
3,
|
|
855
|
+
8
|
|
856
|
+
];
|
|
857
|
+
case 7:
|
|
858
|
+
try {
|
|
859
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
860
|
+
_iterator.return();
|
|
861
|
+
}
|
|
862
|
+
} finally{
|
|
863
|
+
if (_didIteratorError) {
|
|
864
|
+
throw _iteratorError;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
return [
|
|
868
|
+
7
|
|
869
|
+
];
|
|
870
|
+
case 8:
|
|
871
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
872
|
+
_state.label = 9;
|
|
873
|
+
case 9:
|
|
874
|
+
_state.trys.push([
|
|
875
|
+
9,
|
|
876
|
+
14,
|
|
877
|
+
15,
|
|
878
|
+
16
|
|
879
|
+
]);
|
|
880
|
+
_iterator1 = this.oldCache[Symbol.iterator]();
|
|
881
|
+
_state.label = 10;
|
|
882
|
+
case 10:
|
|
883
|
+
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
884
|
+
3,
|
|
885
|
+
13
|
|
886
|
+
];
|
|
887
|
+
item1 = _step1.value;
|
|
888
|
+
_item1 = _slicedToArray(item1, 2), key1 = _item1[0], value2 = _item1[1];
|
|
889
|
+
if (!!this.cache.has(key1)) return [
|
|
890
|
+
3,
|
|
891
|
+
12
|
|
892
|
+
];
|
|
893
|
+
deleted1 = this._deleteIfExpired(key1, value2);
|
|
894
|
+
if (!(deleted1 === false)) return [
|
|
895
|
+
3,
|
|
896
|
+
12
|
|
897
|
+
];
|
|
898
|
+
return [
|
|
899
|
+
4,
|
|
900
|
+
[
|
|
901
|
+
key1,
|
|
902
|
+
value2.value
|
|
903
|
+
]
|
|
904
|
+
];
|
|
905
|
+
case 11:
|
|
906
|
+
_state.sent();
|
|
907
|
+
_state.label = 12;
|
|
908
|
+
case 12:
|
|
909
|
+
_iteratorNormalCompletion1 = true;
|
|
910
|
+
return [
|
|
911
|
+
3,
|
|
912
|
+
10
|
|
913
|
+
];
|
|
914
|
+
case 13:
|
|
915
|
+
return [
|
|
916
|
+
3,
|
|
917
|
+
16
|
|
918
|
+
];
|
|
919
|
+
case 14:
|
|
920
|
+
err = _state.sent();
|
|
921
|
+
_didIteratorError1 = true;
|
|
922
|
+
_iteratorError1 = err;
|
|
923
|
+
return [
|
|
924
|
+
3,
|
|
925
|
+
16
|
|
926
|
+
];
|
|
927
|
+
case 15:
|
|
928
|
+
try {
|
|
929
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
930
|
+
_iterator1.return();
|
|
931
|
+
}
|
|
932
|
+
} finally{
|
|
933
|
+
if (_didIteratorError1) {
|
|
934
|
+
throw _iteratorError1;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
return [
|
|
938
|
+
7
|
|
939
|
+
];
|
|
940
|
+
case 16:
|
|
941
|
+
return [
|
|
942
|
+
2
|
|
943
|
+
];
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
key: "entriesDescending",
|
|
950
|
+
value: function entriesDescending() {
|
|
951
|
+
var items, i, item, _item, key, value, deleted, i1, item1, _item1, key1, value1, deleted1;
|
|
952
|
+
return __generator(this, function(_state) {
|
|
953
|
+
switch(_state.label){
|
|
954
|
+
case 0:
|
|
955
|
+
items = _toConsumableArray(this.cache);
|
|
956
|
+
i = items.length - 1;
|
|
957
|
+
_state.label = 1;
|
|
958
|
+
case 1:
|
|
959
|
+
if (!(i >= 0)) return [
|
|
960
|
+
3,
|
|
961
|
+
4
|
|
962
|
+
];
|
|
963
|
+
item = items[i];
|
|
964
|
+
_item = _slicedToArray(item, 2), key = _item[0], value = _item[1];
|
|
965
|
+
deleted = this._deleteIfExpired(key, value);
|
|
966
|
+
if (!(deleted === false)) return [
|
|
967
|
+
3,
|
|
968
|
+
3
|
|
969
|
+
];
|
|
970
|
+
return [
|
|
971
|
+
4,
|
|
972
|
+
[
|
|
973
|
+
key,
|
|
974
|
+
value.value
|
|
975
|
+
]
|
|
976
|
+
];
|
|
977
|
+
case 2:
|
|
978
|
+
_state.sent();
|
|
979
|
+
_state.label = 3;
|
|
980
|
+
case 3:
|
|
981
|
+
--i;
|
|
982
|
+
return [
|
|
983
|
+
3,
|
|
984
|
+
1
|
|
985
|
+
];
|
|
986
|
+
case 4:
|
|
987
|
+
items = _toConsumableArray(this.oldCache);
|
|
988
|
+
i1 = items.length - 1;
|
|
989
|
+
_state.label = 5;
|
|
990
|
+
case 5:
|
|
991
|
+
if (!(i1 >= 0)) return [
|
|
992
|
+
3,
|
|
993
|
+
8
|
|
994
|
+
];
|
|
995
|
+
item1 = items[i1];
|
|
996
|
+
_item1 = _slicedToArray(item1, 2), key1 = _item1[0], value1 = _item1[1];
|
|
997
|
+
if (!!this.cache.has(key1)) return [
|
|
998
|
+
3,
|
|
999
|
+
7
|
|
1000
|
+
];
|
|
1001
|
+
deleted1 = this._deleteIfExpired(key1, value1);
|
|
1002
|
+
if (!(deleted1 === false)) return [
|
|
1003
|
+
3,
|
|
1004
|
+
7
|
|
1005
|
+
];
|
|
1006
|
+
return [
|
|
1007
|
+
4,
|
|
1008
|
+
[
|
|
1009
|
+
key1,
|
|
1010
|
+
value1.value
|
|
1011
|
+
]
|
|
1012
|
+
];
|
|
1013
|
+
case 6:
|
|
1014
|
+
_state.sent();
|
|
1015
|
+
_state.label = 7;
|
|
1016
|
+
case 7:
|
|
1017
|
+
--i1;
|
|
1018
|
+
return [
|
|
1019
|
+
3,
|
|
1020
|
+
5
|
|
1021
|
+
];
|
|
1022
|
+
case 8:
|
|
1023
|
+
return [
|
|
1024
|
+
2
|
|
1025
|
+
];
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
key: "entriesAscending",
|
|
1032
|
+
value: function entriesAscending() {
|
|
1033
|
+
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, key, value, err;
|
|
1034
|
+
return __generator(this, function(_state) {
|
|
1035
|
+
switch(_state.label){
|
|
1036
|
+
case 0:
|
|
1037
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1038
|
+
_state.label = 1;
|
|
1039
|
+
case 1:
|
|
1040
|
+
_state.trys.push([
|
|
1041
|
+
1,
|
|
1042
|
+
6,
|
|
1043
|
+
7,
|
|
1044
|
+
8
|
|
1045
|
+
]);
|
|
1046
|
+
_iterator = this._entriesAscending()[Symbol.iterator]();
|
|
1047
|
+
_state.label = 2;
|
|
1048
|
+
case 2:
|
|
1049
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
1050
|
+
3,
|
|
1051
|
+
5
|
|
1052
|
+
];
|
|
1053
|
+
_value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
1054
|
+
return [
|
|
1055
|
+
4,
|
|
1056
|
+
[
|
|
1057
|
+
key,
|
|
1058
|
+
value.value
|
|
1059
|
+
]
|
|
1060
|
+
];
|
|
1061
|
+
case 3:
|
|
1062
|
+
_state.sent();
|
|
1063
|
+
_state.label = 4;
|
|
1064
|
+
case 4:
|
|
1065
|
+
_iteratorNormalCompletion = true;
|
|
1066
|
+
return [
|
|
1067
|
+
3,
|
|
1068
|
+
2
|
|
1069
|
+
];
|
|
1070
|
+
case 5:
|
|
1071
|
+
return [
|
|
1072
|
+
3,
|
|
1073
|
+
8
|
|
1074
|
+
];
|
|
1075
|
+
case 6:
|
|
1076
|
+
err = _state.sent();
|
|
1077
|
+
_didIteratorError = true;
|
|
1078
|
+
_iteratorError = err;
|
|
1079
|
+
return [
|
|
1080
|
+
3,
|
|
1081
|
+
8
|
|
1082
|
+
];
|
|
1083
|
+
case 7:
|
|
1084
|
+
try {
|
|
1085
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1086
|
+
_iterator.return();
|
|
1087
|
+
}
|
|
1088
|
+
} finally{
|
|
1089
|
+
if (_didIteratorError) {
|
|
1090
|
+
throw _iteratorError;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return [
|
|
1094
|
+
7
|
|
1095
|
+
];
|
|
1096
|
+
case 8:
|
|
1097
|
+
return [
|
|
1098
|
+
2
|
|
1099
|
+
];
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
key: "size",
|
|
1106
|
+
get: function get() {
|
|
1107
|
+
if (!this._size) {
|
|
1108
|
+
return this.oldCache.size;
|
|
1109
|
+
}
|
|
1110
|
+
var oldCacheSize = 0;
|
|
1111
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1112
|
+
try {
|
|
1113
|
+
for(var _iterator = this.oldCache.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1114
|
+
var key = _step.value;
|
|
1115
|
+
if (!this.cache.has(key)) {
|
|
1116
|
+
oldCacheSize++;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
} catch (err) {
|
|
1120
|
+
_didIteratorError = true;
|
|
1121
|
+
_iteratorError = err;
|
|
1122
|
+
} finally{
|
|
1123
|
+
try {
|
|
1124
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1125
|
+
_iterator.return();
|
|
1126
|
+
}
|
|
1127
|
+
} finally{
|
|
1128
|
+
if (_didIteratorError) {
|
|
1129
|
+
throw _iteratorError;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
return Math.min(this._size + oldCacheSize, this.maxSize);
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
key: "entries",
|
|
1138
|
+
value: function entries() {
|
|
1139
|
+
return this.entriesAscending();
|
|
1140
|
+
}
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
key: "forEach",
|
|
1144
|
+
value: function forEach(callbackFunction) {
|
|
1145
|
+
var thisArgument = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this;
|
|
1146
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1147
|
+
try {
|
|
1148
|
+
for(var _iterator = this.entriesAscending()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1149
|
+
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
1150
|
+
callbackFunction.call(thisArgument, value, key, this);
|
|
1151
|
+
}
|
|
1152
|
+
} catch (err) {
|
|
1153
|
+
_didIteratorError = true;
|
|
1154
|
+
_iteratorError = err;
|
|
1155
|
+
} finally{
|
|
1156
|
+
try {
|
|
1157
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1158
|
+
_iterator.return();
|
|
1159
|
+
}
|
|
1160
|
+
} finally{
|
|
1161
|
+
if (_didIteratorError) {
|
|
1162
|
+
throw _iteratorError;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
key: Symbol.toStringTag,
|
|
1170
|
+
get: function get() {
|
|
1171
|
+
return JSON.stringify(_toConsumableArray(this.entriesAscending()));
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
]);
|
|
1175
|
+
return QuickLRU;
|
|
1176
|
+
}(_wrapNativeSuper(Map));
|