ueberdb2 5.0.2 → 5.0.3
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/dist/index.js +270 -1380
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
/**
|
|
35
35
|
* Cache with Least Recently Used eviction policy.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
class LRU {
|
|
38
38
|
/**
|
|
39
39
|
* @param evictable Optional predicate that dictates whether it is permissable to evict the entry
|
|
40
40
|
* if it is old and the cache is over capacity. The predicate is passed two arguments (key,
|
|
@@ -95,7 +95,7 @@ let LRU$2=class LRU {
|
|
|
95
95
|
this._cache.delete(k);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
}
|
|
98
|
+
}
|
|
99
99
|
// Same as Promise but with a `done` property set to a Node-style callback that resolves/rejects the
|
|
100
100
|
// Promise.
|
|
101
101
|
class SelfContainedPromise extends Promise {
|
|
@@ -155,7 +155,7 @@ const Database$1 = class Database {
|
|
|
155
155
|
// the write to the underlying database returns. If the value has been written this is null.
|
|
156
156
|
// - writingInProgress: Boolean that if true indicates that the value has been sent to the
|
|
157
157
|
// underlying database and we are awaiting commit.
|
|
158
|
-
this.buffer = new LRU
|
|
158
|
+
this.buffer = new LRU(this.settings.cache, (k, v) => !v.dirty && !v.writingInProgress);
|
|
159
159
|
// Either null if flushing is currently allowed, or a Promise that will resolve when it is OK to
|
|
160
160
|
// start flushing. The Promise has a `count` property that tracks the number of operations that
|
|
161
161
|
// are currently preventing flush() from running.
|
|
@@ -40442,7 +40442,7 @@ var parse$h = function (str, opts) {
|
|
|
40442
40442
|
var parse$g = parse$h;
|
|
40443
40443
|
var formats$1 = formats$4;
|
|
40444
40444
|
|
|
40445
|
-
var lib$
|
|
40445
|
+
var lib$a = {
|
|
40446
40446
|
formats: formats$1,
|
|
40447
40447
|
parse: parse$g,
|
|
40448
40448
|
stringify: stringify$2
|
|
@@ -59656,7 +59656,7 @@ var multipart$1 = MultiPartFactory;(function (module, exports) {
|
|
|
59656
59656
|
const http = http$5;
|
|
59657
59657
|
const https = require$$2$2;
|
|
59658
59658
|
const assert = require$$0$i;
|
|
59659
|
-
const querystring = lib$
|
|
59659
|
+
const querystring = lib$a;
|
|
59660
59660
|
const axios = axios_1;
|
|
59661
59661
|
const stream = require$$0$b;
|
|
59662
59662
|
const pkg = require$$7$2;
|
|
@@ -61297,11 +61297,11 @@ class Dirty extends events_1$5.EventEmitter {
|
|
|
61297
61297
|
this._writeStream.uncork();
|
|
61298
61298
|
}
|
|
61299
61299
|
}
|
|
61300
|
-
dirty.default = Dirty;var __importDefault$
|
|
61300
|
+
dirty.default = Dirty;var __importDefault$6 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
61301
61301
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
61302
61302
|
};
|
|
61303
61303
|
Object.defineProperty(dirty$1, "__esModule", { value: true });
|
|
61304
|
-
const dirty_1 = __importDefault$
|
|
61304
|
+
const dirty_1 = __importDefault$6(dirty);
|
|
61305
61305
|
var _default$1 = dirty$1.default = dirty_1.default;/**
|
|
61306
61306
|
* 2011 Peter 'Pita' Martischka
|
|
61307
61307
|
*
|
|
@@ -67748,7 +67748,7 @@ function __importStar$3(mod) {
|
|
|
67748
67748
|
return result;
|
|
67749
67749
|
}
|
|
67750
67750
|
|
|
67751
|
-
function __importDefault$
|
|
67751
|
+
function __importDefault$5(mod) {
|
|
67752
67752
|
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
67753
67753
|
}
|
|
67754
67754
|
|
|
@@ -67839,13 +67839,13 @@ var _tslib = {
|
|
|
67839
67839
|
__asyncValues: __asyncValues,
|
|
67840
67840
|
__makeTemplateObject: __makeTemplateObject,
|
|
67841
67841
|
__importStar: __importStar$3,
|
|
67842
|
-
__importDefault: __importDefault$
|
|
67842
|
+
__importDefault: __importDefault$5,
|
|
67843
67843
|
__classPrivateFieldGet: __classPrivateFieldGet$8,
|
|
67844
67844
|
__classPrivateFieldSet: __classPrivateFieldSet$8,
|
|
67845
67845
|
__classPrivateFieldIn: __classPrivateFieldIn,
|
|
67846
67846
|
__addDisposableResource: __addDisposableResource,
|
|
67847
67847
|
__disposeResources: __disposeResources,
|
|
67848
|
-
};var _tslib$1=/*#__PURE__*/Object.freeze({__proto__:null,__addDisposableResource:__addDisposableResource,get __assign(){return __assign},__asyncDelegator:__asyncDelegator,__asyncGenerator:__asyncGenerator,__asyncValues:__asyncValues,__await:__await,__awaiter:__awaiter,__classPrivateFieldGet:__classPrivateFieldGet$8,__classPrivateFieldIn:__classPrivateFieldIn,__classPrivateFieldSet:__classPrivateFieldSet$8,__createBinding:__createBinding$3,__decorate:__decorate,__disposeResources:__disposeResources,__esDecorate:__esDecorate,__exportStar:__exportStar,__extends:__extends,__generator:__generator,__importDefault:__importDefault$
|
|
67848
|
+
};var _tslib$1=/*#__PURE__*/Object.freeze({__proto__:null,__addDisposableResource:__addDisposableResource,get __assign(){return __assign},__asyncDelegator:__asyncDelegator,__asyncGenerator:__asyncGenerator,__asyncValues:__asyncValues,__await:__await,__awaiter:__awaiter,__classPrivateFieldGet:__classPrivateFieldGet$8,__classPrivateFieldIn:__classPrivateFieldIn,__classPrivateFieldSet:__classPrivateFieldSet$8,__createBinding:__createBinding$3,__decorate:__decorate,__disposeResources:__disposeResources,__esDecorate:__esDecorate,__exportStar:__exportStar,__extends:__extends,__generator:__generator,__importDefault:__importDefault$5,__importStar:__importStar$3,__makeTemplateObject:__makeTemplateObject,__metadata:__metadata,__param:__param,__propKey:__propKey,__read:__read,__rest:__rest,__runInitializers:__runInitializers,__setFunctionName:__setFunctionName,__spread:__spread,__spreadArray:__spreadArray,__spreadArrays:__spreadArrays,__values:__values,default:_tslib});var require$$0$4 = /*@__PURE__*/getAugmentedNamespace(_tslib$1);var Serializer$4 = {};var secureJsonParse = {exports: {}};var hasRequiredSecureJsonParse;
|
|
67849
67849
|
|
|
67850
67850
|
function requireSecureJsonParse () {
|
|
67851
67851
|
if (hasRequiredSecureJsonParse) return secureJsonParse.exports;
|
|
@@ -110178,7 +110178,7 @@ class Elasticsearch_db extends AbstractDatabase {
|
|
|
110178
110178
|
set(key, value, cb) {
|
|
110179
110179
|
this.emit('set', key, value, cb);
|
|
110180
110180
|
}
|
|
110181
|
-
}var lib$
|
|
110181
|
+
}var lib$9 = {};var admin = {};var bson$2 = {};var bson$1 = {};function isAnyArrayBuffer(value) {
|
|
110182
110182
|
return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value));
|
|
110183
110183
|
}
|
|
110184
110184
|
function isUint8Array(value) {
|
|
@@ -127068,7 +127068,7 @@ auth_provider.AuthProvider = AuthProvider;(function (exports) {
|
|
|
127068
127068
|
}
|
|
127069
127069
|
exports.MongoCredentials = MongoCredentials;
|
|
127070
127070
|
|
|
127071
|
-
} (mongo_credentials));var connection_string = {};var lib$
|
|
127071
|
+
} (mongo_credentials));var connection_string = {};var lib$8 = {};var whatwgUrl = {};var webidl2jsWrapper = {};var URL$5 = {};var lib$7 = {};(function (exports) {
|
|
127072
127072
|
|
|
127073
127073
|
function makeException(ErrorType, message, options) {
|
|
127074
127074
|
if (options.globals) {
|
|
@@ -127518,7 +127518,7 @@ auth_provider.AuthProvider = AuthProvider;(function (exports) {
|
|
|
127518
127518
|
};
|
|
127519
127519
|
|
|
127520
127520
|
exports.DOMTimeStamp = exports["unsigned long long"];
|
|
127521
|
-
} (lib$
|
|
127521
|
+
} (lib$7));var utils$a = {exports: {}};(function (module, exports) {
|
|
127522
127522
|
|
|
127523
127523
|
// Returns "Type(value) is Object" in ES terminology.
|
|
127524
127524
|
function isObject(value) {
|
|
@@ -177675,7 +177675,7 @@ function requireUrlencoded () {
|
|
|
177675
177675
|
serializeUrlencoded
|
|
177676
177676
|
};
|
|
177677
177677
|
return urlencoded;
|
|
177678
|
-
}var URLSearchParams$3 = {};var _Function = {};const conversions = lib$
|
|
177678
|
+
}var URLSearchParams$3 = {};var _Function = {};const conversions = lib$7;
|
|
177679
177679
|
const utils$9 = utilsExports$1;
|
|
177680
177680
|
|
|
177681
177681
|
_Function.convert = (globalObject, value, { context = "The provided value" } = {}) => {
|
|
@@ -177860,7 +177860,7 @@ function requireURLSearchParamsImpl () {
|
|
|
177860
177860
|
return URLSearchParamsImpl;
|
|
177861
177861
|
}(function (exports) {
|
|
177862
177862
|
|
|
177863
|
-
const conversions = lib$
|
|
177863
|
+
const conversions = lib$7;
|
|
177864
177864
|
const utils = utilsExports$1;
|
|
177865
177865
|
|
|
177866
177866
|
const Function = _Function;
|
|
@@ -178616,7 +178616,7 @@ function requireURLImpl () {
|
|
|
178616
178616
|
return URLImpl;
|
|
178617
178617
|
}(function (exports) {
|
|
178618
178618
|
|
|
178619
|
-
const conversions = lib$
|
|
178619
|
+
const conversions = lib$7;
|
|
178620
178620
|
const utils = utilsExports$1;
|
|
178621
178621
|
|
|
178622
178622
|
const implSymbol = utils.implSymbol;
|
|
@@ -179207,7 +179207,7 @@ function requireRedact () {
|
|
|
179207
179207
|
}var hasRequiredLib$3;
|
|
179208
179208
|
|
|
179209
179209
|
function requireLib$3 () {
|
|
179210
|
-
if (hasRequiredLib$3) return lib$
|
|
179210
|
+
if (hasRequiredLib$3) return lib$8;
|
|
179211
179211
|
hasRequiredLib$3 = 1;
|
|
179212
179212
|
(function (exports) {
|
|
179213
179213
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -179421,8 +179421,8 @@ function requireLib$3 () {
|
|
|
179421
179421
|
exports.CommaAndColonSeparatedRecord = CommaAndColonSeparatedRecord;
|
|
179422
179422
|
exports.default = ConnectionString;
|
|
179423
179423
|
|
|
179424
|
-
} (lib$
|
|
179425
|
-
return lib$
|
|
179424
|
+
} (lib$8));
|
|
179425
|
+
return lib$8;
|
|
179426
179426
|
}var client_metadata = {};var name$5 = "mongodb";
|
|
179427
179427
|
var version$6 = "6.8.1";
|
|
179428
179428
|
var description$2 = "The official MongoDB driver for Node.js";
|
|
@@ -187466,12 +187466,12 @@ function alloc (n) {
|
|
|
187466
187466
|
|
|
187467
187467
|
function powerOfTwo (x) {
|
|
187468
187468
|
return !(x & (x - 1))
|
|
187469
|
-
}var __importDefault$
|
|
187469
|
+
}var __importDefault$4 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
187470
187470
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
187471
187471
|
};
|
|
187472
187472
|
Object.defineProperty(memoryCodePoints, "__esModule", { value: true });
|
|
187473
187473
|
memoryCodePoints.createMemoryCodePoints = void 0;
|
|
187474
|
-
const sparse_bitfield_1 = __importDefault$
|
|
187474
|
+
const sparse_bitfield_1 = __importDefault$4(sparseBitfield);
|
|
187475
187475
|
function createMemoryCodePoints(data) {
|
|
187476
187476
|
let offset = 0;
|
|
187477
187477
|
function read() {
|
|
@@ -187499,12 +187499,12 @@ function createMemoryCodePoints(data) {
|
|
|
187499
187499
|
memoryCodePoints.createMemoryCodePoints = createMemoryCodePoints;var codePointsData = {};Object.defineProperty(codePointsData, "__esModule", { value: true });
|
|
187500
187500
|
const zlib_1 = require$$0$e;
|
|
187501
187501
|
codePointsData.default = (0, zlib_1.gunzipSync)(Buffer.from('H4sIAAAAAAACA+3dTYgcaRkA4LemO9Mhxm0FITnE9Cwr4jHgwgZ22B6YywqCJ0HQg5CL4sGTuOjCtGSF4CkHEW856MlTQHD3EJnWkU0Owh5VxE3LHlYQdNxd2U6mU59UV/d09fw4M2EySSXPAzNdP1/9fX/99bzVNZEN4jisRDulVFnQmLxm1aXF9Id/2/xMxNJ4XZlg576yuYlGt9gupV6xoFf8jhu9YvulVrFlp5XSx+lfvYhORGPXvqIRWSxERKtIm8bKFd10WNfKDS5Fo9jJWrq2+M2IlW+8uHgl/+BsROfPF4v5L7148Ur68Sha6dqZpYiVVy8tvLCWXo80Sf/lS89dGX2wHGvpzoXVn75/YWH5wmqe8uika82ViJXTy83Ve2k5Urozm38wm4/ls6t5uT6yfsTSJ7J3T0VKt8c5ExEXI8aFkH729c3eT+7EC6ca8cVULZUiYacX0R5PNWNxlh9L1y90q5kyzrpyy+9WcvOV6URntqw7La9sNVstXyczWVaWYbaaTYqzOHpr7pyiNT3/YzKuT63Z/FqKZlFTiuXtFM2vVOtIq7jiyKJbWZaOWD0euz0yoV2Z7kY0xq2x0YhfzVpmM5px9nTEH7JZ0ot5u39p0ma75Z472/s/H+2yr2inYyuq7fMvJivH2rM72N/Z3lyL31F2b1ya1P0zn816k2KP6JU9UzseucdQH5YqVeH/lFajSN2udg+TLJ9rksNxlvV2lki19rXKI43TPLejFu4ov7k3nMbhyhfY3Xb37f8BAGCf0eMTOH5szf154KmnNgKcnLb+Fzi2AfXktbN7fJelwTAiO/W5uQ2KINXRYu+znqo/WTAdLadURHmy3qciazd3bra4T3w16/f7t7Ms9U5gfJu10955sx1r3vmhBAAAAAAAgId20J1iZbDowNvIjuH427Gr5l/eiC+8OplZON8sVjx/qr9y+Pj+YRItT+NqAM+kkZs3AAAAAID6yfx1FwCAI97/dCh1/ub6SA0AAAAAAAAAgNoT/wcAAAAAAACA+hP/BwAAAAAAAID6E/8HAAAAAAAAgPoT/wcAAAAAAACA+hP/BwAAAAAAAID6E/8HAAAAAAAAgPoT/wcAAAAAAACA+hP/BwAAAAAAAID6E/8HAAAAAAAAgPoT/wcAAAAAAACA+hutp5SiQpYAAAAAAAAAQO2MIpZiT804flnAE2fhwjOeAZXr76kOAAAAAAAA8FjNf4N/l0NE3U/vuVQskLpSd4/Yh2xu9xTu0tFeeNYsLI2f/VMdNxTzj6Je9E/+6pp6Nn3awW3A54goe4Bss6v+PGsjQGMAAAAAAOBp5XEgwH6e7J7rwEQHRb/XvAMAAAAAAAA8yzoDeQDwVGjIAgAAAAAAAACoPfF/AAAAAAAAAKg/8X8AAAAAAAAAqD/xfwAAAAAAAACoP/F/AAAAAAAAAKg/8X8AAAAAAAAAqD/xfwAAAAAAAACoP/F/AAAAAAAAAKg/8X8AAAAAAAAAqD/xfwAAAAAAAACoP/F/AAAAAAAAAKg/8X8AAAAAAAAAqL/GSkSkClkCAAAAAAAAALXTSAAAAAAAAABA3Y1kAQAAAAAAAADUX8RSXZ9dsHC9+M8Fg2Ex/em1lAZpEBGttcrVjZqLEa+k0XpKw9mG4zWx4ukPUMhkAQAAAAAAABzBqbSe3//rXOS9HxGdo4TqR2XkutCdBu+LaPZw/lBbO7cbHnh2C7N7AIo4evEznllqLqWUp/LnYOtpM2bnOH66wI1+9GO4sOuISwv/TOlumu56FDv3NZhc4mR9v7zYIrafr40j/Cccvj9Xns3t3mu99E7qxUv3bqS0/ouNH/08++RGemfQ+nsx/5uNXsQPGulynPvv3ZTW37zd+1ovrqaYpP/122X6Xpx779Z3zr/3YOPKW1lkaRDf31pPaf3j/msRsVGkL+d/f+/m4sJsPm1cfSsr16e8m9Ldj/KsnyIuR3nXw83Is3EhxLd/2V773ks3m/cj/THKUummdP9qKhIOImuOU0Xjwb3y+oqt735rpTetVbF9n8R4x9crRfO77TKqVOZpDclv5bfK18lMnk+q0K18UpxF/RrGXE0Zxtqx3tWSj+vxbL4XaasfKb0dRbtLW73JsfPGg177H+OmGKlfvS1msllt7JEJm9XOJqXR+Fkfo1H66uy5H1v3Xx5+uJmGLw9jro2u7Loj4PnuR6+f+e3d261+eazNhzrL7X83MohoHpS4PddV8ki1it61//pw1g7z6p1U/26Nm2llST57B5rUvuG0XqSU/rPd7jYrqWcbd+beJQ77BgPMDwn37/8BAGCf0eMTOH4cPlufv9VGgJOzqf8Fjm1APXkd7B7f5dF57GPMaWy/MTvjvNvtXj6h8W2+GXvnzXaseeeHEgAAAAAAAB7aQXeKlcGiadBoEOeLb2dtpGOL2MyOtf391a3P/zD96c3JzIP3t4oV797vrh8+vn+YRL5bBuj/AQAAAABqJvfHXQAAHkX82zfXAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACeAgkAAAAAAAAAqLuRLAAAAAAAAACA2hv9D1iu/VAYaAYA', 'base64'));
|
|
187502
|
-
var __importDefault$
|
|
187502
|
+
var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
187503
187503
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
187504
187504
|
};
|
|
187505
|
-
const index_1$1 = __importDefault$
|
|
187505
|
+
const index_1$1 = __importDefault$3(dist$b);
|
|
187506
187506
|
const memory_code_points_1 = memoryCodePoints;
|
|
187507
|
-
const code_points_data_1 = __importDefault$
|
|
187507
|
+
const code_points_data_1 = __importDefault$3(codePointsData);
|
|
187508
187508
|
const codePoints = (0, memory_code_points_1.createMemoryCodePoints)(code_points_data_1.default);
|
|
187509
187509
|
function saslprep(input, opts) {
|
|
187510
187510
|
return (0, index_1$1.default)(codePoints, input, opts);
|
|
@@ -190949,7 +190949,7 @@ client_encryption.ClientEncryption = ClientEncryption;(function (exports) {
|
|
|
190949
190949
|
var mongo_client_auth_providers_1 = mongo_client_auth_providers;
|
|
190950
190950
|
Object.defineProperty(exports, "MongoClientAuthProviders", { enumerable: true, get: function () { return mongo_client_auth_providers_1.MongoClientAuthProviders; } });
|
|
190951
190951
|
|
|
190952
|
-
} (lib$
|
|
190952
|
+
} (lib$9));/**
|
|
190953
190953
|
* 2020 Sylchauf
|
|
190954
190954
|
*
|
|
190955
190955
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -190994,7 +190994,7 @@ class Mongodb_db extends AbstractDatabase {
|
|
|
190994
190994
|
}, 10000);
|
|
190995
190995
|
}
|
|
190996
190996
|
init(callback) {
|
|
190997
|
-
lib$
|
|
190997
|
+
lib$9.MongoClient.connect(this.settings.url).then((v) => {
|
|
190998
190998
|
this.client = v;
|
|
190999
190999
|
this.database = v.db(this.settings.database);
|
|
191000
191000
|
this.schedulePing();
|
|
@@ -197020,7 +197020,7 @@ var index = {
|
|
|
197020
197020
|
wrapSync: asyncify,
|
|
197021
197021
|
during: whilst$1,
|
|
197022
197022
|
doDuring: doWhilst$1
|
|
197023
|
-
};var tedious$1 = {exports: {}};var base = {exports: {}};var lib$
|
|
197023
|
+
};var tedious$1 = {exports: {}};var base = {exports: {}};var lib$6 = {};var connectionString = {};Object.defineProperty(connectionString, "__esModule", { value: true });
|
|
197024
197024
|
var CollectionMode;
|
|
197025
197025
|
(function (CollectionMode) {
|
|
197026
197026
|
CollectionMode[CollectionMode["key"] = 0] = "key";
|
|
@@ -197517,7 +197517,7 @@ builder.buildConnectionString = buildConnectionString;(function (exports) {
|
|
|
197517
197517
|
exports.parseSqlConnectionString = sql_connection_string_1.default;
|
|
197518
197518
|
__exportStar(builder, exports);
|
|
197519
197519
|
|
|
197520
|
-
} (lib$
|
|
197520
|
+
} (lib$6));var tarn$1 = {exports: {}};var Pool$3 = {};var PendingOperation$1 = {};var TimeoutError$3 = {};Object.defineProperty(TimeoutError$3, "__esModule", { value: true });
|
|
197521
197521
|
let TimeoutError$2=class TimeoutError extends Error {
|
|
197522
197522
|
};
|
|
197523
197523
|
TimeoutError$3.TimeoutError = TimeoutError$2;var utils$8 = {};var PromiseInspection$1 = {};Object.defineProperty(PromiseInspection$1, "__esModule", { value: true });
|
|
@@ -199076,7 +199076,7 @@ var error$2 = {
|
|
|
199076
199076
|
TransactionError: TransactionError$3
|
|
199077
199077
|
};const { EventEmitter: EventEmitter$a } = require$$0$j;
|
|
199078
199078
|
const debug$c = srcExports('mssql:base');
|
|
199079
|
-
const { parseSqlConnectionString } = lib$
|
|
199079
|
+
const { parseSqlConnectionString } = lib$6;
|
|
199080
199080
|
const tarn = tarnExports;
|
|
199081
199081
|
const { IDS: IDS$6 } = utils$7;
|
|
199082
199082
|
const ConnectionError$3 = connectionError;
|
|
@@ -204899,12 +204899,12 @@ helpers$4.req = req;(function (exports) {
|
|
|
204899
204899
|
}
|
|
204900
204900
|
exports.Agent = Agent;
|
|
204901
204901
|
|
|
204902
|
-
} (dist$9));var parseProxyResponse$1 = {};var __importDefault$
|
|
204902
|
+
} (dist$9));var parseProxyResponse$1 = {};var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
204903
204903
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
204904
204904
|
};
|
|
204905
204905
|
Object.defineProperty(parseProxyResponse$1, "__esModule", { value: true });
|
|
204906
204906
|
parseProxyResponse$1.parseProxyResponse = void 0;
|
|
204907
|
-
const debug_1$3 = __importDefault$
|
|
204907
|
+
const debug_1$3 = __importDefault$2(srcExports);
|
|
204908
204908
|
const debug$8 = (0, debug_1$3.default)('https-proxy-agent:parse-proxy-response');
|
|
204909
204909
|
function parseProxyResponse(socket) {
|
|
204910
204910
|
return new Promise((resolve, reject) => {
|
|
@@ -205020,15 +205020,15 @@ var __importStar$1 = (commonjsGlobal && commonjsGlobal.__importStar) || function
|
|
|
205020
205020
|
__setModuleDefault$1(result, mod);
|
|
205021
205021
|
return result;
|
|
205022
205022
|
};
|
|
205023
|
-
var __importDefault$
|
|
205023
|
+
var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
205024
205024
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
205025
205025
|
};
|
|
205026
205026
|
Object.defineProperty(dist$a, "__esModule", { value: true });
|
|
205027
205027
|
var HttpsProxyAgent_1 = dist$a.HttpsProxyAgent = void 0;
|
|
205028
205028
|
const net$5 = __importStar$1(require$$0$7);
|
|
205029
205029
|
const tls$3 = __importStar$1(require$$1$2);
|
|
205030
|
-
const assert_1 = __importDefault$
|
|
205031
|
-
const debug_1$2 = __importDefault$
|
|
205030
|
+
const assert_1 = __importDefault$1(require$$0$i);
|
|
205031
|
+
const debug_1$2 = __importDefault$1(srcExports);
|
|
205032
205032
|
const agent_base_1$1 = dist$9;
|
|
205033
205033
|
const url_1$2 = require$$0$f;
|
|
205034
205034
|
const parse_proxy_response_1 = parseProxyResponse$1;
|
|
@@ -205192,14 +205192,14 @@ var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (
|
|
|
205192
205192
|
__setModuleDefault(result, mod);
|
|
205193
205193
|
return result;
|
|
205194
205194
|
};
|
|
205195
|
-
var __importDefault
|
|
205195
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
205196
205196
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
205197
205197
|
};
|
|
205198
205198
|
Object.defineProperty(dist$8, "__esModule", { value: true });
|
|
205199
205199
|
var HttpProxyAgent_1 = dist$8.HttpProxyAgent = void 0;
|
|
205200
205200
|
const net$4 = __importStar(require$$0$7);
|
|
205201
205201
|
const tls$2 = __importStar(require$$1$2);
|
|
205202
|
-
const debug_1$1 = __importDefault
|
|
205202
|
+
const debug_1$1 = __importDefault(srcExports);
|
|
205203
205203
|
const events_1$2 = require$$0$8;
|
|
205204
205204
|
const agent_base_1 = dist$9;
|
|
205205
205205
|
const url_1$1 = require$$0$f;
|
|
@@ -219020,7 +219020,7 @@ const coerce$2 = (version, options) => {
|
|
|
219020
219020
|
|
|
219021
219021
|
return parse$7(`${major}.${minor}.${patch}${prerelease}${build}`, options)
|
|
219022
219022
|
};
|
|
219023
|
-
var coerce_1 = coerce$2;
|
|
219023
|
+
var coerce_1 = coerce$2;class LRUCache {
|
|
219024
219024
|
constructor () {
|
|
219025
219025
|
this.max = 1000;
|
|
219026
219026
|
this.map = new Map();
|
|
@@ -219057,9 +219057,9 @@ var coerce_1 = coerce$2;let LRUCache$1=class LRUCache {
|
|
|
219057
219057
|
|
|
219058
219058
|
return this
|
|
219059
219059
|
}
|
|
219060
|
-
}
|
|
219060
|
+
}
|
|
219061
219061
|
|
|
219062
|
-
var lrucache = LRUCache
|
|
219062
|
+
var lrucache = LRUCache;var range;
|
|
219063
219063
|
var hasRequiredRange;
|
|
219064
219064
|
|
|
219065
219065
|
function requireRange () {
|
|
@@ -251785,7 +251785,7 @@ var bigintExports = bigint.exports;var image = {exports: {}};(function (module,
|
|
|
251785
251785
|
|
|
251786
251786
|
} (image, image.exports));
|
|
251787
251787
|
|
|
251788
|
-
var imageExports = image.exports;var text = {exports: {}};var lib$
|
|
251788
|
+
var imageExports = image.exports;var text = {exports: {}};var lib$5 = {exports: {}};/* eslint-disable node/no-deprecated-api */
|
|
251789
251789
|
|
|
251790
251790
|
var buffer$1 = require$$0$k;
|
|
251791
251791
|
var Buffer$1 = buffer$1.Buffer;
|
|
@@ -263020,9 +263020,9 @@ function requireStreams () {
|
|
|
263020
263020
|
throw new Error("iconv-lite Streaming API is not enabled. Use iconv.enableStreamingAPI(require('stream')); to enable it.");
|
|
263021
263021
|
};
|
|
263022
263022
|
}
|
|
263023
|
-
} (lib$
|
|
263023
|
+
} (lib$5));
|
|
263024
263024
|
|
|
263025
|
-
var libExports$2 = lib$
|
|
263025
|
+
var libExports$2 = lib$5.exports;(function (module, exports) {
|
|
263026
263026
|
|
|
263027
263027
|
Object.defineProperty(exports, "__esModule", {
|
|
263028
263028
|
value: true
|
|
@@ -273958,1341 +273958,230 @@ Denque.prototype._nextPowerOf2 = function _nextPowerOf2(num) {
|
|
|
273958
273958
|
return Math.max(nextPow2, 4);
|
|
273959
273959
|
};
|
|
273960
273960
|
|
|
273961
|
-
var denque = Denque;var
|
|
273962
|
-
|
|
273963
|
-
|
|
273964
|
-
|
|
273965
|
-
|
|
273966
|
-
|
|
273967
|
-
|
|
273968
|
-
|
|
273969
|
-
|
|
273970
|
-
|
|
273971
|
-
const
|
|
273972
|
-
const
|
|
273973
|
-
|
|
273974
|
-
|
|
273975
|
-
|
|
273976
|
-
|
|
273977
|
-
|
|
273978
|
-
|
|
273979
|
-
const
|
|
273980
|
-
const
|
|
273981
|
-
|
|
273982
|
-
|
|
273983
|
-
|
|
273984
|
-
|
|
273985
|
-
|
|
273986
|
-
|
|
273987
|
-
|
|
273988
|
-
|
|
273989
|
-
|
|
273990
|
-
|
|
273991
|
-
? null
|
|
273992
|
-
: max <= Math.pow(2, 8)
|
|
273993
|
-
? Uint8Array
|
|
273994
|
-
: max <= Math.pow(2, 16)
|
|
273995
|
-
? Uint16Array
|
|
273996
|
-
: max <= Math.pow(2, 32)
|
|
273997
|
-
? Uint32Array
|
|
273998
|
-
: max <= Number.MAX_SAFE_INTEGER
|
|
273999
|
-
? ZeroArray
|
|
274000
|
-
: null;
|
|
274001
|
-
/* c8 ignore stop */
|
|
274002
|
-
class ZeroArray extends Array {
|
|
274003
|
-
constructor(size) {
|
|
274004
|
-
super(size);
|
|
274005
|
-
this.fill(0);
|
|
274006
|
-
}
|
|
274007
|
-
}
|
|
274008
|
-
class Stack {
|
|
274009
|
-
heap;
|
|
274010
|
-
length;
|
|
274011
|
-
// private constructor
|
|
274012
|
-
static #constructing = false;
|
|
274013
|
-
static create(max) {
|
|
274014
|
-
const HeapCls = getUintArray(max);
|
|
274015
|
-
if (!HeapCls)
|
|
274016
|
-
return [];
|
|
274017
|
-
Stack.#constructing = true;
|
|
274018
|
-
const s = new Stack(max, HeapCls);
|
|
274019
|
-
Stack.#constructing = false;
|
|
274020
|
-
return s;
|
|
274021
|
-
}
|
|
274022
|
-
constructor(max, HeapCls) {
|
|
274023
|
-
/* c8 ignore start */
|
|
274024
|
-
if (!Stack.#constructing) {
|
|
274025
|
-
throw new TypeError('instantiate Stack using Stack.create(n)');
|
|
274026
|
-
}
|
|
274027
|
-
/* c8 ignore stop */
|
|
274028
|
-
this.heap = new HeapCls(max);
|
|
274029
|
-
this.length = 0;
|
|
274030
|
-
}
|
|
274031
|
-
push(n) {
|
|
274032
|
-
this.heap[this.length++] = n;
|
|
274033
|
-
}
|
|
274034
|
-
pop() {
|
|
274035
|
-
return this.heap[--this.length];
|
|
274036
|
-
}
|
|
274037
|
-
}
|
|
274038
|
-
/**
|
|
274039
|
-
* Default export, the thing you're using this module to get.
|
|
274040
|
-
*
|
|
274041
|
-
* All properties from the options object (with the exception of
|
|
274042
|
-
* {@link OptionsBase.max} and {@link OptionsBase.maxSize}) are added as
|
|
274043
|
-
* normal public members. (`max` and `maxBase` are read-only getters.)
|
|
274044
|
-
* Changing any of these will alter the defaults for subsequent method calls,
|
|
274045
|
-
* but is otherwise safe.
|
|
274046
|
-
*/
|
|
274047
|
-
class LRUCache {
|
|
274048
|
-
// properties coming in from the options of these, only max and maxSize
|
|
274049
|
-
// really *need* to be protected. The rest can be modified, as they just
|
|
274050
|
-
// set defaults for various methods.
|
|
274051
|
-
#max;
|
|
274052
|
-
#maxSize;
|
|
274053
|
-
#dispose;
|
|
274054
|
-
#disposeAfter;
|
|
274055
|
-
#fetchMethod;
|
|
274056
|
-
/**
|
|
274057
|
-
* {@link LRUCache.OptionsBase.ttl}
|
|
274058
|
-
*/
|
|
274059
|
-
ttl;
|
|
274060
|
-
/**
|
|
274061
|
-
* {@link LRUCache.OptionsBase.ttlResolution}
|
|
274062
|
-
*/
|
|
274063
|
-
ttlResolution;
|
|
274064
|
-
/**
|
|
274065
|
-
* {@link LRUCache.OptionsBase.ttlAutopurge}
|
|
274066
|
-
*/
|
|
274067
|
-
ttlAutopurge;
|
|
274068
|
-
/**
|
|
274069
|
-
* {@link LRUCache.OptionsBase.updateAgeOnGet}
|
|
274070
|
-
*/
|
|
274071
|
-
updateAgeOnGet;
|
|
274072
|
-
/**
|
|
274073
|
-
* {@link LRUCache.OptionsBase.updateAgeOnHas}
|
|
274074
|
-
*/
|
|
274075
|
-
updateAgeOnHas;
|
|
274076
|
-
/**
|
|
274077
|
-
* {@link LRUCache.OptionsBase.allowStale}
|
|
274078
|
-
*/
|
|
274079
|
-
allowStale;
|
|
274080
|
-
/**
|
|
274081
|
-
* {@link LRUCache.OptionsBase.noDisposeOnSet}
|
|
274082
|
-
*/
|
|
274083
|
-
noDisposeOnSet;
|
|
274084
|
-
/**
|
|
274085
|
-
* {@link LRUCache.OptionsBase.noUpdateTTL}
|
|
274086
|
-
*/
|
|
274087
|
-
noUpdateTTL;
|
|
274088
|
-
/**
|
|
274089
|
-
* {@link LRUCache.OptionsBase.maxEntrySize}
|
|
274090
|
-
*/
|
|
274091
|
-
maxEntrySize;
|
|
274092
|
-
/**
|
|
274093
|
-
* {@link LRUCache.OptionsBase.sizeCalculation}
|
|
274094
|
-
*/
|
|
274095
|
-
sizeCalculation;
|
|
274096
|
-
/**
|
|
274097
|
-
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
|
|
274098
|
-
*/
|
|
274099
|
-
noDeleteOnFetchRejection;
|
|
274100
|
-
/**
|
|
274101
|
-
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
|
|
274102
|
-
*/
|
|
274103
|
-
noDeleteOnStaleGet;
|
|
274104
|
-
/**
|
|
274105
|
-
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
|
|
274106
|
-
*/
|
|
274107
|
-
allowStaleOnFetchAbort;
|
|
274108
|
-
/**
|
|
274109
|
-
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
|
|
274110
|
-
*/
|
|
274111
|
-
allowStaleOnFetchRejection;
|
|
274112
|
-
/**
|
|
274113
|
-
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
|
|
274114
|
-
*/
|
|
274115
|
-
ignoreFetchAbort;
|
|
274116
|
-
// computed properties
|
|
274117
|
-
#size;
|
|
274118
|
-
#calculatedSize;
|
|
274119
|
-
#keyMap;
|
|
274120
|
-
#keyList;
|
|
274121
|
-
#valList;
|
|
274122
|
-
#next;
|
|
274123
|
-
#prev;
|
|
274124
|
-
#head;
|
|
274125
|
-
#tail;
|
|
274126
|
-
#free;
|
|
274127
|
-
#disposed;
|
|
274128
|
-
#sizes;
|
|
274129
|
-
#starts;
|
|
274130
|
-
#ttls;
|
|
274131
|
-
#hasDispose;
|
|
274132
|
-
#hasFetchMethod;
|
|
274133
|
-
#hasDisposeAfter;
|
|
274134
|
-
/**
|
|
274135
|
-
* Do not call this method unless you need to inspect the
|
|
274136
|
-
* inner workings of the cache. If anything returned by this
|
|
274137
|
-
* object is modified in any way, strange breakage may occur.
|
|
274138
|
-
*
|
|
274139
|
-
* These fields are private for a reason!
|
|
274140
|
-
*
|
|
274141
|
-
* @internal
|
|
274142
|
-
*/
|
|
274143
|
-
static unsafeExposeInternals(c) {
|
|
274144
|
-
return {
|
|
274145
|
-
// properties
|
|
274146
|
-
starts: c.#starts,
|
|
274147
|
-
ttls: c.#ttls,
|
|
274148
|
-
sizes: c.#sizes,
|
|
274149
|
-
keyMap: c.#keyMap,
|
|
274150
|
-
keyList: c.#keyList,
|
|
274151
|
-
valList: c.#valList,
|
|
274152
|
-
next: c.#next,
|
|
274153
|
-
prev: c.#prev,
|
|
274154
|
-
get head() {
|
|
274155
|
-
return c.#head;
|
|
274156
|
-
},
|
|
274157
|
-
get tail() {
|
|
274158
|
-
return c.#tail;
|
|
274159
|
-
},
|
|
274160
|
-
free: c.#free,
|
|
274161
|
-
// methods
|
|
274162
|
-
isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
|
|
274163
|
-
backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
|
|
274164
|
-
moveToTail: (index) => c.#moveToTail(index),
|
|
274165
|
-
indexes: (options) => c.#indexes(options),
|
|
274166
|
-
rindexes: (options) => c.#rindexes(options),
|
|
274167
|
-
isStale: (index) => c.#isStale(index),
|
|
274168
|
-
};
|
|
274169
|
-
}
|
|
274170
|
-
// Protected read-only members
|
|
274171
|
-
/**
|
|
274172
|
-
* {@link LRUCache.OptionsBase.max} (read-only)
|
|
274173
|
-
*/
|
|
274174
|
-
get max() {
|
|
274175
|
-
return this.#max;
|
|
274176
|
-
}
|
|
274177
|
-
/**
|
|
274178
|
-
* {@link LRUCache.OptionsBase.maxSize} (read-only)
|
|
274179
|
-
*/
|
|
274180
|
-
get maxSize() {
|
|
274181
|
-
return this.#maxSize;
|
|
274182
|
-
}
|
|
274183
|
-
/**
|
|
274184
|
-
* The total computed size of items in the cache (read-only)
|
|
274185
|
-
*/
|
|
274186
|
-
get calculatedSize() {
|
|
274187
|
-
return this.#calculatedSize;
|
|
274188
|
-
}
|
|
274189
|
-
/**
|
|
274190
|
-
* The number of items stored in the cache (read-only)
|
|
274191
|
-
*/
|
|
274192
|
-
get size() {
|
|
274193
|
-
return this.#size;
|
|
274194
|
-
}
|
|
274195
|
-
/**
|
|
274196
|
-
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
|
|
274197
|
-
*/
|
|
274198
|
-
get fetchMethod() {
|
|
274199
|
-
return this.#fetchMethod;
|
|
274200
|
-
}
|
|
274201
|
-
/**
|
|
274202
|
-
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
|
274203
|
-
*/
|
|
274204
|
-
get dispose() {
|
|
274205
|
-
return this.#dispose;
|
|
274206
|
-
}
|
|
274207
|
-
/**
|
|
274208
|
-
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
|
274209
|
-
*/
|
|
274210
|
-
get disposeAfter() {
|
|
274211
|
-
return this.#disposeAfter;
|
|
274212
|
-
}
|
|
274213
|
-
constructor(options) {
|
|
274214
|
-
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = options;
|
|
274215
|
-
if (max !== 0 && !isPosInt(max)) {
|
|
274216
|
-
throw new TypeError('max option must be a nonnegative integer');
|
|
274217
|
-
}
|
|
274218
|
-
const UintArray = max ? getUintArray(max) : Array;
|
|
274219
|
-
if (!UintArray) {
|
|
274220
|
-
throw new Error('invalid max value: ' + max);
|
|
274221
|
-
}
|
|
274222
|
-
this.#max = max;
|
|
274223
|
-
this.#maxSize = maxSize;
|
|
274224
|
-
this.maxEntrySize = maxEntrySize || this.#maxSize;
|
|
274225
|
-
this.sizeCalculation = sizeCalculation;
|
|
274226
|
-
if (this.sizeCalculation) {
|
|
274227
|
-
if (!this.#maxSize && !this.maxEntrySize) {
|
|
274228
|
-
throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
|
|
274229
|
-
}
|
|
274230
|
-
if (typeof this.sizeCalculation !== 'function') {
|
|
274231
|
-
throw new TypeError('sizeCalculation set to non-function');
|
|
274232
|
-
}
|
|
274233
|
-
}
|
|
274234
|
-
if (fetchMethod !== undefined &&
|
|
274235
|
-
typeof fetchMethod !== 'function') {
|
|
274236
|
-
throw new TypeError('fetchMethod must be a function if specified');
|
|
274237
|
-
}
|
|
274238
|
-
this.#fetchMethod = fetchMethod;
|
|
274239
|
-
this.#hasFetchMethod = !!fetchMethod;
|
|
274240
|
-
this.#keyMap = new Map();
|
|
274241
|
-
this.#keyList = new Array(max).fill(undefined);
|
|
274242
|
-
this.#valList = new Array(max).fill(undefined);
|
|
274243
|
-
this.#next = new UintArray(max);
|
|
274244
|
-
this.#prev = new UintArray(max);
|
|
274245
|
-
this.#head = 0;
|
|
274246
|
-
this.#tail = 0;
|
|
274247
|
-
this.#free = Stack.create(max);
|
|
274248
|
-
this.#size = 0;
|
|
274249
|
-
this.#calculatedSize = 0;
|
|
274250
|
-
if (typeof dispose === 'function') {
|
|
274251
|
-
this.#dispose = dispose;
|
|
274252
|
-
}
|
|
274253
|
-
if (typeof disposeAfter === 'function') {
|
|
274254
|
-
this.#disposeAfter = disposeAfter;
|
|
274255
|
-
this.#disposed = [];
|
|
274256
|
-
}
|
|
274257
|
-
else {
|
|
274258
|
-
this.#disposeAfter = undefined;
|
|
274259
|
-
this.#disposed = undefined;
|
|
274260
|
-
}
|
|
274261
|
-
this.#hasDispose = !!this.#dispose;
|
|
274262
|
-
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
274263
|
-
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
274264
|
-
this.noUpdateTTL = !!noUpdateTTL;
|
|
274265
|
-
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
|
|
274266
|
-
this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
|
|
274267
|
-
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
|
|
274268
|
-
this.ignoreFetchAbort = !!ignoreFetchAbort;
|
|
274269
|
-
// NB: maxEntrySize is set to maxSize if it's set
|
|
274270
|
-
if (this.maxEntrySize !== 0) {
|
|
274271
|
-
if (this.#maxSize !== 0) {
|
|
274272
|
-
if (!isPosInt(this.#maxSize)) {
|
|
274273
|
-
throw new TypeError('maxSize must be a positive integer if specified');
|
|
274274
|
-
}
|
|
274275
|
-
}
|
|
274276
|
-
if (!isPosInt(this.maxEntrySize)) {
|
|
274277
|
-
throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
274278
|
-
}
|
|
274279
|
-
this.#initializeSizeTracking();
|
|
274280
|
-
}
|
|
274281
|
-
this.allowStale = !!allowStale;
|
|
274282
|
-
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
274283
|
-
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
274284
|
-
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
274285
|
-
this.ttlResolution =
|
|
274286
|
-
isPosInt(ttlResolution) || ttlResolution === 0
|
|
274287
|
-
? ttlResolution
|
|
274288
|
-
: 1;
|
|
274289
|
-
this.ttlAutopurge = !!ttlAutopurge;
|
|
274290
|
-
this.ttl = ttl || 0;
|
|
274291
|
-
if (this.ttl) {
|
|
274292
|
-
if (!isPosInt(this.ttl)) {
|
|
274293
|
-
throw new TypeError('ttl must be a positive integer if specified');
|
|
274294
|
-
}
|
|
274295
|
-
this.#initializeTTLTracking();
|
|
274296
|
-
}
|
|
274297
|
-
// do not allow completely unbounded caches
|
|
274298
|
-
if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
|
|
274299
|
-
throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
274300
|
-
}
|
|
274301
|
-
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
274302
|
-
const code = 'LRU_CACHE_UNBOUNDED';
|
|
274303
|
-
if (shouldWarn(code)) {
|
|
274304
|
-
warned.add(code);
|
|
274305
|
-
const msg = 'TTL caching without ttlAutopurge, max, or maxSize can ' +
|
|
274306
|
-
'result in unbounded memory consumption.';
|
|
274307
|
-
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
|
|
274308
|
-
}
|
|
274309
|
-
}
|
|
274310
|
-
}
|
|
274311
|
-
/**
|
|
274312
|
-
* Return the remaining TTL time for a given entry key
|
|
274313
|
-
*/
|
|
274314
|
-
getRemainingTTL(key) {
|
|
274315
|
-
return this.#keyMap.has(key) ? Infinity : 0;
|
|
274316
|
-
}
|
|
274317
|
-
#initializeTTLTracking() {
|
|
274318
|
-
const ttls = new ZeroArray(this.#max);
|
|
274319
|
-
const starts = new ZeroArray(this.#max);
|
|
274320
|
-
this.#ttls = ttls;
|
|
274321
|
-
this.#starts = starts;
|
|
274322
|
-
this.#setItemTTL = (index, ttl, start = perf.now()) => {
|
|
274323
|
-
starts[index] = ttl !== 0 ? start : 0;
|
|
274324
|
-
ttls[index] = ttl;
|
|
274325
|
-
if (ttl !== 0 && this.ttlAutopurge) {
|
|
274326
|
-
const t = setTimeout(() => {
|
|
274327
|
-
if (this.#isStale(index)) {
|
|
274328
|
-
this.delete(this.#keyList[index]);
|
|
274329
|
-
}
|
|
274330
|
-
}, ttl + 1);
|
|
274331
|
-
// unref() not supported on all platforms
|
|
274332
|
-
/* c8 ignore start */
|
|
274333
|
-
if (t.unref) {
|
|
274334
|
-
t.unref();
|
|
274335
|
-
}
|
|
274336
|
-
/* c8 ignore stop */
|
|
274337
|
-
}
|
|
274338
|
-
};
|
|
274339
|
-
this.#updateItemAge = index => {
|
|
274340
|
-
starts[index] = ttls[index] !== 0 ? perf.now() : 0;
|
|
274341
|
-
};
|
|
274342
|
-
this.#statusTTL = (status, index) => {
|
|
274343
|
-
if (ttls[index]) {
|
|
274344
|
-
const ttl = ttls[index];
|
|
274345
|
-
const start = starts[index];
|
|
274346
|
-
status.ttl = ttl;
|
|
274347
|
-
status.start = start;
|
|
274348
|
-
status.now = cachedNow || getNow();
|
|
274349
|
-
status.remainingTTL = status.now + ttl - start;
|
|
274350
|
-
}
|
|
274351
|
-
};
|
|
274352
|
-
// debounce calls to perf.now() to 1s so we're not hitting
|
|
274353
|
-
// that costly call repeatedly.
|
|
274354
|
-
let cachedNow = 0;
|
|
274355
|
-
const getNow = () => {
|
|
274356
|
-
const n = perf.now();
|
|
274357
|
-
if (this.ttlResolution > 0) {
|
|
274358
|
-
cachedNow = n;
|
|
274359
|
-
const t = setTimeout(() => (cachedNow = 0), this.ttlResolution);
|
|
274360
|
-
// not available on all platforms
|
|
274361
|
-
/* c8 ignore start */
|
|
274362
|
-
if (t.unref) {
|
|
274363
|
-
t.unref();
|
|
274364
|
-
}
|
|
274365
|
-
/* c8 ignore stop */
|
|
274366
|
-
}
|
|
274367
|
-
return n;
|
|
274368
|
-
};
|
|
274369
|
-
this.getRemainingTTL = key => {
|
|
274370
|
-
const index = this.#keyMap.get(key);
|
|
274371
|
-
if (index === undefined) {
|
|
274372
|
-
return 0;
|
|
274373
|
-
}
|
|
274374
|
-
return ttls[index] === 0 || starts[index] === 0
|
|
274375
|
-
? Infinity
|
|
274376
|
-
: starts[index] + ttls[index] - (cachedNow || getNow());
|
|
274377
|
-
};
|
|
274378
|
-
this.#isStale = index => {
|
|
274379
|
-
return (ttls[index] !== 0 &&
|
|
274380
|
-
starts[index] !== 0 &&
|
|
274381
|
-
(cachedNow || getNow()) - starts[index] > ttls[index]);
|
|
274382
|
-
};
|
|
274383
|
-
}
|
|
274384
|
-
// conditionally set private methods related to TTL
|
|
274385
|
-
#updateItemAge = () => { };
|
|
274386
|
-
#statusTTL = () => { };
|
|
274387
|
-
#setItemTTL = () => { };
|
|
274388
|
-
/* c8 ignore stop */
|
|
274389
|
-
#isStale = () => false;
|
|
274390
|
-
#initializeSizeTracking() {
|
|
274391
|
-
const sizes = new ZeroArray(this.#max);
|
|
274392
|
-
this.#calculatedSize = 0;
|
|
274393
|
-
this.#sizes = sizes;
|
|
274394
|
-
this.#removeItemSize = index => {
|
|
274395
|
-
this.#calculatedSize -= sizes[index];
|
|
274396
|
-
sizes[index] = 0;
|
|
274397
|
-
};
|
|
274398
|
-
this.#requireSize = (k, v, size, sizeCalculation) => {
|
|
274399
|
-
// provisionally accept background fetches.
|
|
274400
|
-
// actual value size will be checked when they return.
|
|
274401
|
-
if (this.#isBackgroundFetch(v)) {
|
|
274402
|
-
return 0;
|
|
274403
|
-
}
|
|
274404
|
-
if (!isPosInt(size)) {
|
|
274405
|
-
if (sizeCalculation) {
|
|
274406
|
-
if (typeof sizeCalculation !== 'function') {
|
|
274407
|
-
throw new TypeError('sizeCalculation must be a function');
|
|
274408
|
-
}
|
|
274409
|
-
size = sizeCalculation(v, k);
|
|
274410
|
-
if (!isPosInt(size)) {
|
|
274411
|
-
throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
274412
|
-
}
|
|
274413
|
-
}
|
|
274414
|
-
else {
|
|
274415
|
-
throw new TypeError('invalid size value (must be positive integer). ' +
|
|
274416
|
-
'When maxSize or maxEntrySize is used, sizeCalculation ' +
|
|
274417
|
-
'or size must be set.');
|
|
274418
|
-
}
|
|
274419
|
-
}
|
|
274420
|
-
return size;
|
|
274421
|
-
};
|
|
274422
|
-
this.#addItemSize = (index, size, status) => {
|
|
274423
|
-
sizes[index] = size;
|
|
274424
|
-
if (this.#maxSize) {
|
|
274425
|
-
const maxSize = this.#maxSize - sizes[index];
|
|
274426
|
-
while (this.#calculatedSize > maxSize) {
|
|
274427
|
-
this.#evict(true);
|
|
274428
|
-
}
|
|
274429
|
-
}
|
|
274430
|
-
this.#calculatedSize += sizes[index];
|
|
274431
|
-
if (status) {
|
|
274432
|
-
status.entrySize = size;
|
|
274433
|
-
status.totalCalculatedSize = this.#calculatedSize;
|
|
274434
|
-
}
|
|
274435
|
-
};
|
|
274436
|
-
}
|
|
274437
|
-
#removeItemSize = _i => { };
|
|
274438
|
-
#addItemSize = (_i, _s, _st) => { };
|
|
274439
|
-
#requireSize = (_k, _v, size, sizeCalculation) => {
|
|
274440
|
-
if (size || sizeCalculation) {
|
|
274441
|
-
throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
|
|
274442
|
-
}
|
|
274443
|
-
return 0;
|
|
273961
|
+
var denque = Denque;var lib$4 = {};Object.defineProperty(lib$4, "__esModule", { value: true });
|
|
273962
|
+
lib$4.createLRU = void 0;
|
|
273963
|
+
const createLRU$2 = (options) => {
|
|
273964
|
+
let { max, onEviction } = options;
|
|
273965
|
+
if (!(Number.isInteger(max) && max > 0))
|
|
273966
|
+
throw new TypeError('`max` must be a positive integer');
|
|
273967
|
+
let size = 0;
|
|
273968
|
+
let head = 0;
|
|
273969
|
+
let tail = 0;
|
|
273970
|
+
let free = [];
|
|
273971
|
+
const keyMap = new Map();
|
|
273972
|
+
const keyList = new Array(max).fill(undefined);
|
|
273973
|
+
const valList = new Array(max).fill(undefined);
|
|
273974
|
+
const next = new Array(max).fill(0);
|
|
273975
|
+
const prev = new Array(max).fill(0);
|
|
273976
|
+
const setTail = (index, type) => {
|
|
273977
|
+
if (index === tail)
|
|
273978
|
+
return;
|
|
273979
|
+
const nextIndex = next[index];
|
|
273980
|
+
const prevIndex = prev[index];
|
|
273981
|
+
if (index === head)
|
|
273982
|
+
head = nextIndex;
|
|
273983
|
+
else if (type === 'get' || prevIndex !== 0)
|
|
273984
|
+
next[prevIndex] = nextIndex;
|
|
273985
|
+
if (nextIndex !== 0)
|
|
273986
|
+
prev[nextIndex] = prevIndex;
|
|
273987
|
+
next[tail] = index;
|
|
273988
|
+
prev[index] = tail;
|
|
273989
|
+
next[index] = 0;
|
|
273990
|
+
tail = index;
|
|
274444
273991
|
};
|
|
274445
|
-
|
|
274446
|
-
|
|
274447
|
-
|
|
274448
|
-
|
|
274449
|
-
|
|
274450
|
-
|
|
274451
|
-
|
|
274452
|
-
|
|
274453
|
-
|
|
274454
|
-
|
|
274455
|
-
|
|
274456
|
-
|
|
274457
|
-
|
|
274458
|
-
|
|
274459
|
-
|
|
274460
|
-
|
|
274461
|
-
|
|
274462
|
-
|
|
274463
|
-
|
|
274464
|
-
|
|
274465
|
-
|
|
274466
|
-
|
|
274467
|
-
|
|
274468
|
-
|
|
274469
|
-
|
|
274470
|
-
|
|
274471
|
-
|
|
274472
|
-
if (i === this.#tail) {
|
|
274473
|
-
break;
|
|
274474
|
-
}
|
|
274475
|
-
else {
|
|
274476
|
-
i = this.#next[i];
|
|
274477
|
-
}
|
|
274478
|
-
}
|
|
274479
|
-
}
|
|
274480
|
-
}
|
|
274481
|
-
#isValidIndex(index) {
|
|
274482
|
-
return (index !== undefined &&
|
|
274483
|
-
this.#keyMap.get(this.#keyList[index]) === index);
|
|
274484
|
-
}
|
|
274485
|
-
/**
|
|
274486
|
-
* Return a generator yielding `[key, value]` pairs,
|
|
274487
|
-
* in order from most recently used to least recently used.
|
|
274488
|
-
*/
|
|
274489
|
-
*entries() {
|
|
274490
|
-
for (const i of this.#indexes()) {
|
|
274491
|
-
if (this.#valList[i] !== undefined &&
|
|
274492
|
-
this.#keyList[i] !== undefined &&
|
|
274493
|
-
!this.#isBackgroundFetch(this.#valList[i])) {
|
|
274494
|
-
yield [this.#keyList[i], this.#valList[i]];
|
|
274495
|
-
}
|
|
274496
|
-
}
|
|
274497
|
-
}
|
|
274498
|
-
/**
|
|
274499
|
-
* Inverse order version of {@link LRUCache.entries}
|
|
274500
|
-
*
|
|
274501
|
-
* Return a generator yielding `[key, value]` pairs,
|
|
274502
|
-
* in order from least recently used to most recently used.
|
|
274503
|
-
*/
|
|
274504
|
-
*rentries() {
|
|
274505
|
-
for (const i of this.#rindexes()) {
|
|
274506
|
-
if (this.#valList[i] !== undefined &&
|
|
274507
|
-
this.#keyList[i] !== undefined &&
|
|
274508
|
-
!this.#isBackgroundFetch(this.#valList[i])) {
|
|
274509
|
-
yield [this.#keyList[i], this.#valList[i]];
|
|
274510
|
-
}
|
|
274511
|
-
}
|
|
274512
|
-
}
|
|
274513
|
-
/**
|
|
274514
|
-
* Return a generator yielding the keys in the cache,
|
|
274515
|
-
* in order from most recently used to least recently used.
|
|
274516
|
-
*/
|
|
274517
|
-
*keys() {
|
|
274518
|
-
for (const i of this.#indexes()) {
|
|
274519
|
-
const k = this.#keyList[i];
|
|
274520
|
-
if (k !== undefined &&
|
|
274521
|
-
!this.#isBackgroundFetch(this.#valList[i])) {
|
|
274522
|
-
yield k;
|
|
274523
|
-
}
|
|
274524
|
-
}
|
|
274525
|
-
}
|
|
274526
|
-
/**
|
|
274527
|
-
* Inverse order version of {@link LRUCache.keys}
|
|
274528
|
-
*
|
|
274529
|
-
* Return a generator yielding the keys in the cache,
|
|
274530
|
-
* in order from least recently used to most recently used.
|
|
274531
|
-
*/
|
|
274532
|
-
*rkeys() {
|
|
274533
|
-
for (const i of this.#rindexes()) {
|
|
274534
|
-
const k = this.#keyList[i];
|
|
274535
|
-
if (k !== undefined &&
|
|
274536
|
-
!this.#isBackgroundFetch(this.#valList[i])) {
|
|
274537
|
-
yield k;
|
|
274538
|
-
}
|
|
274539
|
-
}
|
|
274540
|
-
}
|
|
274541
|
-
/**
|
|
274542
|
-
* Return a generator yielding the values in the cache,
|
|
274543
|
-
* in order from most recently used to least recently used.
|
|
274544
|
-
*/
|
|
274545
|
-
*values() {
|
|
274546
|
-
for (const i of this.#indexes()) {
|
|
274547
|
-
const v = this.#valList[i];
|
|
274548
|
-
if (v !== undefined &&
|
|
274549
|
-
!this.#isBackgroundFetch(this.#valList[i])) {
|
|
274550
|
-
yield this.#valList[i];
|
|
274551
|
-
}
|
|
274552
|
-
}
|
|
274553
|
-
}
|
|
274554
|
-
/**
|
|
274555
|
-
* Inverse order version of {@link LRUCache.values}
|
|
274556
|
-
*
|
|
274557
|
-
* Return a generator yielding the values in the cache,
|
|
274558
|
-
* in order from least recently used to most recently used.
|
|
274559
|
-
*/
|
|
274560
|
-
*rvalues() {
|
|
274561
|
-
for (const i of this.#rindexes()) {
|
|
274562
|
-
const v = this.#valList[i];
|
|
274563
|
-
if (v !== undefined &&
|
|
274564
|
-
!this.#isBackgroundFetch(this.#valList[i])) {
|
|
274565
|
-
yield this.#valList[i];
|
|
274566
|
-
}
|
|
274567
|
-
}
|
|
274568
|
-
}
|
|
274569
|
-
/**
|
|
274570
|
-
* Iterating over the cache itself yields the same results as
|
|
274571
|
-
* {@link LRUCache.entries}
|
|
274572
|
-
*/
|
|
274573
|
-
[Symbol.iterator]() {
|
|
274574
|
-
return this.entries();
|
|
274575
|
-
}
|
|
274576
|
-
/**
|
|
274577
|
-
* Find a value for which the supplied fn method returns a truthy value,
|
|
274578
|
-
* similar to Array.find(). fn is called as fn(value, key, cache).
|
|
274579
|
-
*/
|
|
274580
|
-
find(fn, getOptions = {}) {
|
|
274581
|
-
for (const i of this.#indexes()) {
|
|
274582
|
-
const v = this.#valList[i];
|
|
274583
|
-
const value = this.#isBackgroundFetch(v)
|
|
274584
|
-
? v.__staleWhileFetching
|
|
274585
|
-
: v;
|
|
274586
|
-
if (value === undefined)
|
|
274587
|
-
continue;
|
|
274588
|
-
if (fn(value, this.#keyList[i], this)) {
|
|
274589
|
-
return this.get(this.#keyList[i], getOptions);
|
|
274590
|
-
}
|
|
274591
|
-
}
|
|
274592
|
-
}
|
|
274593
|
-
/**
|
|
274594
|
-
* Call the supplied function on each item in the cache, in order from
|
|
274595
|
-
* most recently used to least recently used. fn is called as
|
|
274596
|
-
* fn(value, key, cache). Does not update age or recenty of use.
|
|
274597
|
-
* Does not iterate over stale values.
|
|
274598
|
-
*/
|
|
274599
|
-
forEach(fn, thisp = this) {
|
|
274600
|
-
for (const i of this.#indexes()) {
|
|
274601
|
-
const v = this.#valList[i];
|
|
274602
|
-
const value = this.#isBackgroundFetch(v)
|
|
274603
|
-
? v.__staleWhileFetching
|
|
274604
|
-
: v;
|
|
274605
|
-
if (value === undefined)
|
|
274606
|
-
continue;
|
|
274607
|
-
fn.call(thisp, value, this.#keyList[i], this);
|
|
274608
|
-
}
|
|
274609
|
-
}
|
|
274610
|
-
/**
|
|
274611
|
-
* The same as {@link LRUCache.forEach} but items are iterated over in
|
|
274612
|
-
* reverse order. (ie, less recently used items are iterated over first.)
|
|
274613
|
-
*/
|
|
274614
|
-
rforEach(fn, thisp = this) {
|
|
274615
|
-
for (const i of this.#rindexes()) {
|
|
274616
|
-
const v = this.#valList[i];
|
|
274617
|
-
const value = this.#isBackgroundFetch(v)
|
|
274618
|
-
? v.__staleWhileFetching
|
|
274619
|
-
: v;
|
|
274620
|
-
if (value === undefined)
|
|
274621
|
-
continue;
|
|
274622
|
-
fn.call(thisp, value, this.#keyList[i], this);
|
|
274623
|
-
}
|
|
274624
|
-
}
|
|
274625
|
-
/**
|
|
274626
|
-
* Delete any stale entries. Returns true if anything was removed,
|
|
274627
|
-
* false otherwise.
|
|
274628
|
-
*/
|
|
274629
|
-
purgeStale() {
|
|
274630
|
-
let deleted = false;
|
|
274631
|
-
for (const i of this.#rindexes({ allowStale: true })) {
|
|
274632
|
-
if (this.#isStale(i)) {
|
|
274633
|
-
this.delete(this.#keyList[i]);
|
|
274634
|
-
deleted = true;
|
|
274635
|
-
}
|
|
274636
|
-
}
|
|
274637
|
-
return deleted;
|
|
274638
|
-
}
|
|
274639
|
-
/**
|
|
274640
|
-
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
274641
|
-
* passed to cache.load()
|
|
274642
|
-
*/
|
|
274643
|
-
dump() {
|
|
274644
|
-
const arr = [];
|
|
274645
|
-
for (const i of this.#indexes({ allowStale: true })) {
|
|
274646
|
-
const key = this.#keyList[i];
|
|
274647
|
-
const v = this.#valList[i];
|
|
274648
|
-
const value = this.#isBackgroundFetch(v)
|
|
274649
|
-
? v.__staleWhileFetching
|
|
274650
|
-
: v;
|
|
274651
|
-
if (value === undefined || key === undefined)
|
|
274652
|
-
continue;
|
|
274653
|
-
const entry = { value };
|
|
274654
|
-
if (this.#ttls && this.#starts) {
|
|
274655
|
-
entry.ttl = this.#ttls[i];
|
|
274656
|
-
// always dump the start relative to a portable timestamp
|
|
274657
|
-
// it's ok for this to be a bit slow, it's a rare operation.
|
|
274658
|
-
const age = perf.now() - this.#starts[i];
|
|
274659
|
-
entry.start = Math.floor(Date.now() - age);
|
|
274660
|
-
}
|
|
274661
|
-
if (this.#sizes) {
|
|
274662
|
-
entry.size = this.#sizes[i];
|
|
274663
|
-
}
|
|
274664
|
-
arr.unshift([key, entry]);
|
|
274665
|
-
}
|
|
274666
|
-
return arr;
|
|
274667
|
-
}
|
|
274668
|
-
/**
|
|
274669
|
-
* Reset the cache and load in the items in entries in the order listed.
|
|
274670
|
-
* Note that the shape of the resulting cache may be different if the
|
|
274671
|
-
* same options are not used in both caches.
|
|
274672
|
-
*/
|
|
274673
|
-
load(arr) {
|
|
274674
|
-
this.clear();
|
|
274675
|
-
for (const [key, entry] of arr) {
|
|
274676
|
-
if (entry.start) {
|
|
274677
|
-
// entry.start is a portable timestamp, but we may be using
|
|
274678
|
-
// node's performance.now(), so calculate the offset, so that
|
|
274679
|
-
// we get the intended remaining TTL, no matter how long it's
|
|
274680
|
-
// been on ice.
|
|
274681
|
-
//
|
|
274682
|
-
// it's ok for this to be a bit slow, it's a rare operation.
|
|
274683
|
-
const age = Date.now() - entry.start;
|
|
274684
|
-
entry.start = perf.now() - age;
|
|
274685
|
-
}
|
|
274686
|
-
this.set(key, entry.value, entry);
|
|
274687
|
-
}
|
|
274688
|
-
}
|
|
274689
|
-
/**
|
|
274690
|
-
* Add a value to the cache.
|
|
274691
|
-
*/
|
|
274692
|
-
set(k, v, setOptions = {}) {
|
|
274693
|
-
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
|
|
274694
|
-
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
274695
|
-
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
274696
|
-
// if the item doesn't fit, don't do anything
|
|
274697
|
-
// NB: maxEntrySize set to maxSize by default
|
|
274698
|
-
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
274699
|
-
if (status) {
|
|
274700
|
-
status.set = 'miss';
|
|
274701
|
-
status.maxEntrySizeExceeded = true;
|
|
274702
|
-
}
|
|
274703
|
-
// have to delete, in case something is there already.
|
|
274704
|
-
this.delete(k);
|
|
274705
|
-
return this;
|
|
274706
|
-
}
|
|
274707
|
-
let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
|
|
274708
|
-
if (index === undefined) {
|
|
274709
|
-
// addition
|
|
274710
|
-
index = (this.#size === 0
|
|
274711
|
-
? this.#tail
|
|
274712
|
-
: this.#free.length !== 0
|
|
274713
|
-
? this.#free.pop()
|
|
274714
|
-
: this.#size === this.#max
|
|
274715
|
-
? this.#evict(false)
|
|
274716
|
-
: this.#size);
|
|
274717
|
-
this.#keyList[index] = k;
|
|
274718
|
-
this.#valList[index] = v;
|
|
274719
|
-
this.#keyMap.set(k, index);
|
|
274720
|
-
this.#next[this.#tail] = index;
|
|
274721
|
-
this.#prev[index] = this.#tail;
|
|
274722
|
-
this.#tail = index;
|
|
274723
|
-
this.#size++;
|
|
274724
|
-
this.#addItemSize(index, size, status);
|
|
274725
|
-
if (status)
|
|
274726
|
-
status.set = 'add';
|
|
274727
|
-
noUpdateTTL = false;
|
|
274728
|
-
}
|
|
274729
|
-
else {
|
|
274730
|
-
// update
|
|
274731
|
-
this.#moveToTail(index);
|
|
274732
|
-
const oldVal = this.#valList[index];
|
|
274733
|
-
if (v !== oldVal) {
|
|
274734
|
-
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
|
274735
|
-
oldVal.__abortController.abort(new Error('replaced'));
|
|
274736
|
-
}
|
|
274737
|
-
else if (!noDisposeOnSet) {
|
|
274738
|
-
if (this.#hasDispose) {
|
|
274739
|
-
this.#dispose?.(oldVal, k, 'set');
|
|
274740
|
-
}
|
|
274741
|
-
if (this.#hasDisposeAfter) {
|
|
274742
|
-
this.#disposed?.push([oldVal, k, 'set']);
|
|
274743
|
-
}
|
|
274744
|
-
}
|
|
274745
|
-
this.#removeItemSize(index);
|
|
274746
|
-
this.#addItemSize(index, size, status);
|
|
274747
|
-
this.#valList[index] = v;
|
|
274748
|
-
if (status) {
|
|
274749
|
-
status.set = 'replace';
|
|
274750
|
-
const oldValue = oldVal && this.#isBackgroundFetch(oldVal)
|
|
274751
|
-
? oldVal.__staleWhileFetching
|
|
274752
|
-
: oldVal;
|
|
274753
|
-
if (oldValue !== undefined)
|
|
274754
|
-
status.oldValue = oldValue;
|
|
274755
|
-
}
|
|
274756
|
-
}
|
|
274757
|
-
else if (status) {
|
|
274758
|
-
status.set = 'update';
|
|
274759
|
-
}
|
|
274760
|
-
}
|
|
274761
|
-
if (ttl !== 0 && !this.#ttls) {
|
|
274762
|
-
this.#initializeTTLTracking();
|
|
274763
|
-
}
|
|
274764
|
-
if (this.#ttls) {
|
|
274765
|
-
if (!noUpdateTTL) {
|
|
274766
|
-
this.#setItemTTL(index, ttl, start);
|
|
274767
|
-
}
|
|
274768
|
-
if (status)
|
|
274769
|
-
this.#statusTTL(status, index);
|
|
274770
|
-
}
|
|
274771
|
-
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
274772
|
-
const dt = this.#disposed;
|
|
274773
|
-
let task;
|
|
274774
|
-
while ((task = dt?.shift())) {
|
|
274775
|
-
this.#disposeAfter?.(...task);
|
|
273992
|
+
const _evict = () => {
|
|
273993
|
+
const evictHead = head;
|
|
273994
|
+
const key = keyList[evictHead];
|
|
273995
|
+
onEviction === null || onEviction === void 0 ? void 0 : onEviction(key, valList[evictHead]);
|
|
273996
|
+
keyMap.delete(key);
|
|
273997
|
+
keyList[evictHead] = undefined;
|
|
273998
|
+
valList[evictHead] = undefined;
|
|
273999
|
+
head = next[evictHead];
|
|
274000
|
+
if (head !== 0)
|
|
274001
|
+
prev[head] = 0;
|
|
274002
|
+
size--;
|
|
274003
|
+
if (size === 0)
|
|
274004
|
+
head = tail = 0;
|
|
274005
|
+
free.push(evictHead);
|
|
274006
|
+
return evictHead;
|
|
274007
|
+
};
|
|
274008
|
+
return {
|
|
274009
|
+
/** Adds a key-value pair to the cache. Updates the value if the key already exists. */
|
|
274010
|
+
set(key, value) {
|
|
274011
|
+
if (key === undefined)
|
|
274012
|
+
return;
|
|
274013
|
+
let index = keyMap.get(key);
|
|
274014
|
+
if (index === undefined) {
|
|
274015
|
+
index = size === max ? _evict() : free.length > 0 ? free.pop() : size;
|
|
274016
|
+
keyMap.set(key, index);
|
|
274017
|
+
keyList[index] = key;
|
|
274018
|
+
size++;
|
|
274776
274019
|
}
|
|
274777
|
-
|
|
274778
|
-
|
|
274779
|
-
|
|
274780
|
-
|
|
274781
|
-
|
|
274782
|
-
|
|
274783
|
-
|
|
274784
|
-
|
|
274785
|
-
|
|
274786
|
-
|
|
274787
|
-
|
|
274788
|
-
|
|
274789
|
-
|
|
274790
|
-
|
|
274791
|
-
|
|
274792
|
-
|
|
274793
|
-
|
|
274794
|
-
|
|
274795
|
-
|
|
274796
|
-
|
|
274020
|
+
else
|
|
274021
|
+
onEviction === null || onEviction === void 0 ? void 0 : onEviction(key, valList[index]);
|
|
274022
|
+
valList[index] = value;
|
|
274023
|
+
if (size === 1)
|
|
274024
|
+
head = tail = index;
|
|
274025
|
+
else
|
|
274026
|
+
setTail(index, 'set');
|
|
274027
|
+
},
|
|
274028
|
+
/** Retrieves the value for a given key and moves the key to the most recent position. */
|
|
274029
|
+
get(key) {
|
|
274030
|
+
const index = keyMap.get(key);
|
|
274031
|
+
if (index === undefined)
|
|
274032
|
+
return;
|
|
274033
|
+
if (index !== tail)
|
|
274034
|
+
setTail(index, 'get');
|
|
274035
|
+
return valList[index];
|
|
274036
|
+
},
|
|
274037
|
+
/** Retrieves the value for a given key without changing its position. */
|
|
274038
|
+
peek: (key) => {
|
|
274039
|
+
const index = keyMap.get(key);
|
|
274040
|
+
return index !== undefined ? valList[index] : undefined;
|
|
274041
|
+
},
|
|
274042
|
+
/** Checks if a key exists in the cache. */
|
|
274043
|
+
has: (key) => keyMap.has(key),
|
|
274044
|
+
/** Iterates over all keys in the cache, from most recent to least recent. */
|
|
274045
|
+
*keys() {
|
|
274046
|
+
let current = tail;
|
|
274047
|
+
for (let i = 0; i < size; i++) {
|
|
274048
|
+
yield keyList[current];
|
|
274049
|
+
current = prev[current];
|
|
274797
274050
|
}
|
|
274798
|
-
}
|
|
274799
|
-
|
|
274800
|
-
|
|
274801
|
-
|
|
274802
|
-
|
|
274803
|
-
|
|
274804
|
-
|
|
274805
|
-
}
|
|
274051
|
+
},
|
|
274052
|
+
/** Iterates over all values in the cache, from most recent to least recent. */
|
|
274053
|
+
*values() {
|
|
274054
|
+
let current = tail;
|
|
274055
|
+
for (let i = 0; i < size; i++) {
|
|
274056
|
+
yield valList[current];
|
|
274057
|
+
current = prev[current];
|
|
274806
274058
|
}
|
|
274807
|
-
}
|
|
274808
|
-
|
|
274809
|
-
|
|
274810
|
-
|
|
274811
|
-
|
|
274812
|
-
|
|
274813
|
-
|
|
274814
|
-
v.__abortController.abort(new Error('evicted'));
|
|
274815
|
-
}
|
|
274816
|
-
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
274817
|
-
if (this.#hasDispose) {
|
|
274818
|
-
this.#dispose?.(v, k, 'evict');
|
|
274059
|
+
},
|
|
274060
|
+
/** Iterates over `[key, value]` pairs in the cache, from most recent to least recent. */
|
|
274061
|
+
*entries() {
|
|
274062
|
+
let current = tail;
|
|
274063
|
+
for (let i = 0; i < size; i++) {
|
|
274064
|
+
yield [keyList[current], valList[current]];
|
|
274065
|
+
current = prev[current];
|
|
274819
274066
|
}
|
|
274820
|
-
|
|
274821
|
-
|
|
274067
|
+
},
|
|
274068
|
+
/** Iterates over each value-key pair in the cache, from most recent to least recent. */
|
|
274069
|
+
forEach: (callback) => {
|
|
274070
|
+
let current = tail;
|
|
274071
|
+
for (let i = 0; i < size; i++) {
|
|
274072
|
+
const key = keyList[current];
|
|
274073
|
+
const value = valList[current];
|
|
274074
|
+
callback(value, key);
|
|
274075
|
+
current = prev[current];
|
|
274822
274076
|
}
|
|
274823
|
-
}
|
|
274824
|
-
|
|
274825
|
-
|
|
274826
|
-
|
|
274827
|
-
|
|
274828
|
-
this.#valList[head] = undefined;
|
|
274829
|
-
this.#free.push(head);
|
|
274830
|
-
}
|
|
274831
|
-
if (this.#size === 1) {
|
|
274832
|
-
this.#head = this.#tail = 0;
|
|
274833
|
-
this.#free.length = 0;
|
|
274834
|
-
}
|
|
274835
|
-
else {
|
|
274836
|
-
this.#head = this.#next[head];
|
|
274837
|
-
}
|
|
274838
|
-
this.#keyMap.delete(k);
|
|
274839
|
-
this.#size--;
|
|
274840
|
-
return head;
|
|
274841
|
-
}
|
|
274842
|
-
/**
|
|
274843
|
-
* Check if a key is in the cache, without updating the recency of use.
|
|
274844
|
-
* Will return false if the item is stale, even though it is technically
|
|
274845
|
-
* in the cache.
|
|
274846
|
-
*
|
|
274847
|
-
* Will not update item age unless
|
|
274848
|
-
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
274849
|
-
*/
|
|
274850
|
-
has(k, hasOptions = {}) {
|
|
274851
|
-
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
274852
|
-
const index = this.#keyMap.get(k);
|
|
274853
|
-
if (index !== undefined) {
|
|
274854
|
-
const v = this.#valList[index];
|
|
274855
|
-
if (this.#isBackgroundFetch(v) &&
|
|
274856
|
-
v.__staleWhileFetching === undefined) {
|
|
274077
|
+
},
|
|
274078
|
+
/** Deletes a key-value pair from the cache. */
|
|
274079
|
+
delete(key) {
|
|
274080
|
+
const index = keyMap.get(key);
|
|
274081
|
+
if (index === undefined)
|
|
274857
274082
|
return false;
|
|
274083
|
+
onEviction === null || onEviction === void 0 ? void 0 : onEviction(key, valList[index]);
|
|
274084
|
+
keyMap.delete(key);
|
|
274085
|
+
free.push(index);
|
|
274086
|
+
keyList[index] = undefined;
|
|
274087
|
+
valList[index] = undefined;
|
|
274088
|
+
const prevIndex = prev[index];
|
|
274089
|
+
const nextIndex = next[index];
|
|
274090
|
+
if (prevIndex !== 0)
|
|
274091
|
+
next[prevIndex] = nextIndex;
|
|
274092
|
+
if (nextIndex !== 0)
|
|
274093
|
+
prev[nextIndex] = prevIndex;
|
|
274094
|
+
if (index === head)
|
|
274095
|
+
head = nextIndex;
|
|
274096
|
+
if (index === tail)
|
|
274097
|
+
tail = prevIndex;
|
|
274098
|
+
size--;
|
|
274099
|
+
return true;
|
|
274100
|
+
},
|
|
274101
|
+
/** Evicts the oldest item or the specified number of the oldest items from the cache. */
|
|
274102
|
+
evict: (number) => {
|
|
274103
|
+
let toPrune = Math.min(number, size);
|
|
274104
|
+
while (toPrune > 0) {
|
|
274105
|
+
_evict();
|
|
274106
|
+
toPrune--;
|
|
274858
274107
|
}
|
|
274859
|
-
|
|
274860
|
-
|
|
274861
|
-
|
|
274862
|
-
|
|
274863
|
-
|
|
274864
|
-
|
|
274865
|
-
|
|
274866
|
-
|
|
274867
|
-
|
|
274868
|
-
|
|
274869
|
-
|
|
274870
|
-
|
|
274871
|
-
|
|
274872
|
-
|
|
274873
|
-
|
|
274874
|
-
|
|
274875
|
-
|
|
274876
|
-
|
|
274877
|
-
|
|
274878
|
-
|
|
274879
|
-
|
|
274880
|
-
|
|
274881
|
-
|
|
274882
|
-
|
|
274883
|
-
|
|
274884
|
-
|
|
274885
|
-
|
|
274886
|
-
|
|
274887
|
-
|
|
274888
|
-
|
|
274889
|
-
|
|
274890
|
-
|
|
274891
|
-
|
|
274892
|
-
|
|
274893
|
-
|
|
274894
|
-
}
|
|
274895
|
-
}
|
|
274896
|
-
#backgroundFetch(k, index, options, context) {
|
|
274897
|
-
const v = index === undefined ? undefined : this.#valList[index];
|
|
274898
|
-
if (this.#isBackgroundFetch(v)) {
|
|
274899
|
-
return v;
|
|
274900
|
-
}
|
|
274901
|
-
const ac = new AbortController();
|
|
274902
|
-
const { signal } = options;
|
|
274903
|
-
// when/if our AC signals, then stop listening to theirs.
|
|
274904
|
-
signal?.addEventListener('abort', () => ac.abort(signal.reason), {
|
|
274905
|
-
signal: ac.signal,
|
|
274906
|
-
});
|
|
274907
|
-
const fetchOpts = {
|
|
274908
|
-
signal: ac.signal,
|
|
274909
|
-
options,
|
|
274910
|
-
context,
|
|
274911
|
-
};
|
|
274912
|
-
const cb = (v, updateCache = false) => {
|
|
274913
|
-
const { aborted } = ac.signal;
|
|
274914
|
-
const ignoreAbort = options.ignoreFetchAbort && v !== undefined;
|
|
274915
|
-
if (options.status) {
|
|
274916
|
-
if (aborted && !updateCache) {
|
|
274917
|
-
options.status.fetchAborted = true;
|
|
274918
|
-
options.status.fetchError = ac.signal.reason;
|
|
274919
|
-
if (ignoreAbort)
|
|
274920
|
-
options.status.fetchAbortIgnored = true;
|
|
274921
|
-
}
|
|
274922
|
-
else {
|
|
274923
|
-
options.status.fetchResolved = true;
|
|
274924
|
-
}
|
|
274925
|
-
}
|
|
274926
|
-
if (aborted && !ignoreAbort && !updateCache) {
|
|
274927
|
-
return fetchFail(ac.signal.reason);
|
|
274928
|
-
}
|
|
274929
|
-
// either we didn't abort, and are still here, or we did, and ignored
|
|
274930
|
-
const bf = p;
|
|
274931
|
-
if (this.#valList[index] === p) {
|
|
274932
|
-
if (v === undefined) {
|
|
274933
|
-
if (bf.__staleWhileFetching) {
|
|
274934
|
-
this.#valList[index] = bf.__staleWhileFetching;
|
|
274935
|
-
}
|
|
274936
|
-
else {
|
|
274937
|
-
this.delete(k);
|
|
274938
|
-
}
|
|
274939
|
-
}
|
|
274940
|
-
else {
|
|
274941
|
-
if (options.status)
|
|
274942
|
-
options.status.fetchUpdated = true;
|
|
274943
|
-
this.set(k, v, fetchOpts.options);
|
|
274944
|
-
}
|
|
274945
|
-
}
|
|
274946
|
-
return v;
|
|
274947
|
-
};
|
|
274948
|
-
const eb = (er) => {
|
|
274949
|
-
if (options.status) {
|
|
274950
|
-
options.status.fetchRejected = true;
|
|
274951
|
-
options.status.fetchError = er;
|
|
274952
|
-
}
|
|
274953
|
-
return fetchFail(er);
|
|
274954
|
-
};
|
|
274955
|
-
const fetchFail = (er) => {
|
|
274956
|
-
const { aborted } = ac.signal;
|
|
274957
|
-
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
274958
|
-
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
274959
|
-
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
274960
|
-
const bf = p;
|
|
274961
|
-
if (this.#valList[index] === p) {
|
|
274962
|
-
// if we allow stale on fetch rejections, then we need to ensure that
|
|
274963
|
-
// the stale value is not removed from the cache when the fetch fails.
|
|
274964
|
-
const del = !noDelete || bf.__staleWhileFetching === undefined;
|
|
274965
|
-
if (del) {
|
|
274966
|
-
this.delete(k);
|
|
274967
|
-
}
|
|
274968
|
-
else if (!allowStaleAborted) {
|
|
274969
|
-
// still replace the *promise* with the stale value,
|
|
274970
|
-
// since we are done with the promise at this point.
|
|
274971
|
-
// leave it untouched if we're still waiting for an
|
|
274972
|
-
// aborted background fetch that hasn't yet returned.
|
|
274973
|
-
this.#valList[index] = bf.__staleWhileFetching;
|
|
274974
|
-
}
|
|
274975
|
-
}
|
|
274976
|
-
if (allowStale) {
|
|
274977
|
-
if (options.status && bf.__staleWhileFetching !== undefined) {
|
|
274978
|
-
options.status.returnedStale = true;
|
|
274979
|
-
}
|
|
274980
|
-
return bf.__staleWhileFetching;
|
|
274981
|
-
}
|
|
274982
|
-
else if (bf.__returned === bf) {
|
|
274983
|
-
throw er;
|
|
274984
|
-
}
|
|
274985
|
-
};
|
|
274986
|
-
const pcall = (res, rej) => {
|
|
274987
|
-
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
274988
|
-
if (fmp && fmp instanceof Promise) {
|
|
274989
|
-
fmp.then(v => res(v), rej);
|
|
274990
|
-
}
|
|
274991
|
-
// ignored, we go until we finish, regardless.
|
|
274992
|
-
// defer check until we are actually aborting,
|
|
274993
|
-
// so fetchMethod can override.
|
|
274994
|
-
ac.signal.addEventListener('abort', () => {
|
|
274995
|
-
if (!options.ignoreFetchAbort ||
|
|
274996
|
-
options.allowStaleOnFetchAbort) {
|
|
274997
|
-
res();
|
|
274998
|
-
// when it eventually resolves, update the cache.
|
|
274999
|
-
if (options.allowStaleOnFetchAbort) {
|
|
275000
|
-
res = v => cb(v, true);
|
|
275001
|
-
}
|
|
275002
|
-
}
|
|
275003
|
-
});
|
|
275004
|
-
};
|
|
275005
|
-
if (options.status)
|
|
275006
|
-
options.status.fetchDispatched = true;
|
|
275007
|
-
const p = new Promise(pcall).then(cb, eb);
|
|
275008
|
-
const bf = Object.assign(p, {
|
|
275009
|
-
__abortController: ac,
|
|
275010
|
-
__staleWhileFetching: v,
|
|
275011
|
-
__returned: undefined,
|
|
275012
|
-
});
|
|
275013
|
-
if (index === undefined) {
|
|
275014
|
-
// internal, don't expose status.
|
|
275015
|
-
this.set(k, bf, { ...fetchOpts.options, status: undefined });
|
|
275016
|
-
index = this.#keyMap.get(k);
|
|
275017
|
-
}
|
|
275018
|
-
else {
|
|
275019
|
-
this.#valList[index] = bf;
|
|
275020
|
-
}
|
|
275021
|
-
return bf;
|
|
275022
|
-
}
|
|
275023
|
-
#isBackgroundFetch(p) {
|
|
275024
|
-
if (!this.#hasFetchMethod)
|
|
275025
|
-
return false;
|
|
275026
|
-
const b = p;
|
|
275027
|
-
return (!!b &&
|
|
275028
|
-
b instanceof Promise &&
|
|
275029
|
-
b.hasOwnProperty('__staleWhileFetching') &&
|
|
275030
|
-
b.__abortController instanceof AbortController);
|
|
275031
|
-
}
|
|
275032
|
-
async fetch(k, fetchOptions = {}) {
|
|
275033
|
-
const {
|
|
275034
|
-
// get options
|
|
275035
|
-
allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
|
275036
|
-
// set options
|
|
275037
|
-
ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
|
|
275038
|
-
// fetch exclusive options
|
|
275039
|
-
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
|
|
275040
|
-
if (!this.#hasFetchMethod) {
|
|
275041
|
-
if (status)
|
|
275042
|
-
status.fetch = 'get';
|
|
275043
|
-
return this.get(k, {
|
|
275044
|
-
allowStale,
|
|
275045
|
-
updateAgeOnGet,
|
|
275046
|
-
noDeleteOnStaleGet,
|
|
275047
|
-
status,
|
|
275048
|
-
});
|
|
275049
|
-
}
|
|
275050
|
-
const options = {
|
|
275051
|
-
allowStale,
|
|
275052
|
-
updateAgeOnGet,
|
|
275053
|
-
noDeleteOnStaleGet,
|
|
275054
|
-
ttl,
|
|
275055
|
-
noDisposeOnSet,
|
|
275056
|
-
size,
|
|
275057
|
-
sizeCalculation,
|
|
275058
|
-
noUpdateTTL,
|
|
275059
|
-
noDeleteOnFetchRejection,
|
|
275060
|
-
allowStaleOnFetchRejection,
|
|
275061
|
-
allowStaleOnFetchAbort,
|
|
275062
|
-
ignoreFetchAbort,
|
|
275063
|
-
status,
|
|
275064
|
-
signal,
|
|
275065
|
-
};
|
|
275066
|
-
let index = this.#keyMap.get(k);
|
|
275067
|
-
if (index === undefined) {
|
|
275068
|
-
if (status)
|
|
275069
|
-
status.fetch = 'miss';
|
|
275070
|
-
const p = this.#backgroundFetch(k, index, options, context);
|
|
275071
|
-
return (p.__returned = p);
|
|
275072
|
-
}
|
|
275073
|
-
else {
|
|
275074
|
-
// in cache, maybe already fetching
|
|
275075
|
-
const v = this.#valList[index];
|
|
275076
|
-
if (this.#isBackgroundFetch(v)) {
|
|
275077
|
-
const stale = allowStale && v.__staleWhileFetching !== undefined;
|
|
275078
|
-
if (status) {
|
|
275079
|
-
status.fetch = 'inflight';
|
|
275080
|
-
if (stale)
|
|
275081
|
-
status.returnedStale = true;
|
|
275082
|
-
}
|
|
275083
|
-
return stale ? v.__staleWhileFetching : (v.__returned = v);
|
|
275084
|
-
}
|
|
275085
|
-
// if we force a refresh, that means do NOT serve the cached value,
|
|
275086
|
-
// unless we are already in the process of refreshing the cache.
|
|
275087
|
-
const isStale = this.#isStale(index);
|
|
275088
|
-
if (!forceRefresh && !isStale) {
|
|
275089
|
-
if (status)
|
|
275090
|
-
status.fetch = 'hit';
|
|
275091
|
-
this.#moveToTail(index);
|
|
275092
|
-
if (updateAgeOnGet) {
|
|
275093
|
-
this.#updateItemAge(index);
|
|
275094
|
-
}
|
|
275095
|
-
if (status)
|
|
275096
|
-
this.#statusTTL(status, index);
|
|
275097
|
-
return v;
|
|
275098
|
-
}
|
|
275099
|
-
// ok, it is stale or a forced refresh, and not already fetching.
|
|
275100
|
-
// refresh the cache.
|
|
275101
|
-
const p = this.#backgroundFetch(k, index, options, context);
|
|
275102
|
-
const hasStale = p.__staleWhileFetching !== undefined;
|
|
275103
|
-
const staleVal = hasStale && allowStale;
|
|
275104
|
-
if (status) {
|
|
275105
|
-
status.fetch = isStale ? 'stale' : 'refresh';
|
|
275106
|
-
if (staleVal && isStale)
|
|
275107
|
-
status.returnedStale = true;
|
|
275108
|
-
}
|
|
275109
|
-
return staleVal ? p.__staleWhileFetching : (p.__returned = p);
|
|
275110
|
-
}
|
|
275111
|
-
}
|
|
275112
|
-
/**
|
|
275113
|
-
* Return a value from the cache. Will update the recency of the cache
|
|
275114
|
-
* entry found.
|
|
275115
|
-
*
|
|
275116
|
-
* If the key is not found, get() will return `undefined`.
|
|
275117
|
-
*/
|
|
275118
|
-
get(k, getOptions = {}) {
|
|
275119
|
-
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status, } = getOptions;
|
|
275120
|
-
const index = this.#keyMap.get(k);
|
|
275121
|
-
if (index !== undefined) {
|
|
275122
|
-
const value = this.#valList[index];
|
|
275123
|
-
const fetching = this.#isBackgroundFetch(value);
|
|
275124
|
-
if (status)
|
|
275125
|
-
this.#statusTTL(status, index);
|
|
275126
|
-
if (this.#isStale(index)) {
|
|
275127
|
-
if (status)
|
|
275128
|
-
status.get = 'stale';
|
|
275129
|
-
// delete only if not an in-flight background fetch
|
|
275130
|
-
if (!fetching) {
|
|
275131
|
-
if (!noDeleteOnStaleGet) {
|
|
275132
|
-
this.delete(k);
|
|
275133
|
-
}
|
|
275134
|
-
if (status && allowStale)
|
|
275135
|
-
status.returnedStale = true;
|
|
275136
|
-
return allowStale ? value : undefined;
|
|
275137
|
-
}
|
|
275138
|
-
else {
|
|
275139
|
-
if (status &&
|
|
275140
|
-
allowStale &&
|
|
275141
|
-
value.__staleWhileFetching !== undefined) {
|
|
275142
|
-
status.returnedStale = true;
|
|
275143
|
-
}
|
|
275144
|
-
return allowStale ? value.__staleWhileFetching : undefined;
|
|
275145
|
-
}
|
|
275146
|
-
}
|
|
275147
|
-
else {
|
|
275148
|
-
if (status)
|
|
275149
|
-
status.get = 'hit';
|
|
275150
|
-
// if we're currently fetching it, we don't actually have it yet
|
|
275151
|
-
// it's not stale, which means this isn't a staleWhileRefetching.
|
|
275152
|
-
// If it's not stale, and fetching, AND has a __staleWhileFetching
|
|
275153
|
-
// value, then that means the user fetched with {forceRefresh:true},
|
|
275154
|
-
// so it's safe to return that value.
|
|
275155
|
-
if (fetching) {
|
|
275156
|
-
return value.__staleWhileFetching;
|
|
275157
|
-
}
|
|
275158
|
-
this.#moveToTail(index);
|
|
275159
|
-
if (updateAgeOnGet) {
|
|
275160
|
-
this.#updateItemAge(index);
|
|
275161
|
-
}
|
|
275162
|
-
return value;
|
|
275163
|
-
}
|
|
275164
|
-
}
|
|
275165
|
-
else if (status) {
|
|
275166
|
-
status.get = 'miss';
|
|
275167
|
-
}
|
|
275168
|
-
}
|
|
275169
|
-
#connect(p, n) {
|
|
275170
|
-
this.#prev[n] = p;
|
|
275171
|
-
this.#next[p] = n;
|
|
275172
|
-
}
|
|
275173
|
-
#moveToTail(index) {
|
|
275174
|
-
// if tail already, nothing to do
|
|
275175
|
-
// if head, move head to next[index]
|
|
275176
|
-
// else
|
|
275177
|
-
// move next[prev[index]] to next[index] (head has no prev)
|
|
275178
|
-
// move prev[next[index]] to prev[index]
|
|
275179
|
-
// prev[index] = tail
|
|
275180
|
-
// next[tail] = index
|
|
275181
|
-
// tail = index
|
|
275182
|
-
if (index !== this.#tail) {
|
|
275183
|
-
if (index === this.#head) {
|
|
275184
|
-
this.#head = this.#next[index];
|
|
275185
|
-
}
|
|
275186
|
-
else {
|
|
275187
|
-
this.#connect(this.#prev[index], this.#next[index]);
|
|
275188
|
-
}
|
|
275189
|
-
this.#connect(this.#tail, index);
|
|
275190
|
-
this.#tail = index;
|
|
275191
|
-
}
|
|
275192
|
-
}
|
|
275193
|
-
/**
|
|
275194
|
-
* Deletes a key out of the cache.
|
|
275195
|
-
* Returns true if the key was deleted, false otherwise.
|
|
275196
|
-
*/
|
|
275197
|
-
delete(k) {
|
|
275198
|
-
let deleted = false;
|
|
275199
|
-
if (this.#size !== 0) {
|
|
275200
|
-
const index = this.#keyMap.get(k);
|
|
275201
|
-
if (index !== undefined) {
|
|
275202
|
-
deleted = true;
|
|
275203
|
-
if (this.#size === 1) {
|
|
275204
|
-
this.clear();
|
|
274108
|
+
},
|
|
274109
|
+
/** Clears all key-value pairs from the cache. */
|
|
274110
|
+
clear() {
|
|
274111
|
+
for (const index of keyMap.values())
|
|
274112
|
+
onEviction === null || onEviction === void 0 ? void 0 : onEviction(keyList[index], valList[index]);
|
|
274113
|
+
keyMap.clear();
|
|
274114
|
+
keyList.fill(undefined);
|
|
274115
|
+
valList.fill(undefined);
|
|
274116
|
+
free = [];
|
|
274117
|
+
size = 0;
|
|
274118
|
+
head = tail = 0;
|
|
274119
|
+
},
|
|
274120
|
+
/** Resizes the cache to a new maximum size, evicting items if necessary. */
|
|
274121
|
+
resize: (newMax) => {
|
|
274122
|
+
if (!(Number.isInteger(newMax) && newMax > 0))
|
|
274123
|
+
throw new TypeError('`max` must be a positive integer');
|
|
274124
|
+
if (newMax === max)
|
|
274125
|
+
return;
|
|
274126
|
+
if (newMax < max) {
|
|
274127
|
+
let current = tail;
|
|
274128
|
+
const preserve = Math.min(size, newMax);
|
|
274129
|
+
const remove = size - preserve;
|
|
274130
|
+
const newKeyList = new Array(newMax);
|
|
274131
|
+
const newValList = new Array(newMax);
|
|
274132
|
+
const newNext = new Array(newMax);
|
|
274133
|
+
const newPrev = new Array(newMax);
|
|
274134
|
+
for (let i = 1; i <= remove; i++)
|
|
274135
|
+
onEviction === null || onEviction === void 0 ? void 0 : onEviction(keyList[i], valList[i]);
|
|
274136
|
+
for (let i = preserve - 1; i >= 0; i--) {
|
|
274137
|
+
newKeyList[i] = keyList[current];
|
|
274138
|
+
newValList[i] = valList[current];
|
|
274139
|
+
newNext[i] = i + 1;
|
|
274140
|
+
newPrev[i] = i - 1;
|
|
274141
|
+
keyMap.set(newKeyList[i], i);
|
|
274142
|
+
current = prev[current];
|
|
275205
274143
|
}
|
|
275206
|
-
|
|
275207
|
-
|
|
275208
|
-
|
|
275209
|
-
|
|
275210
|
-
|
|
275211
|
-
|
|
275212
|
-
|
|
275213
|
-
|
|
275214
|
-
|
|
275215
|
-
|
|
275216
|
-
|
|
275217
|
-
|
|
275218
|
-
}
|
|
275219
|
-
}
|
|
275220
|
-
this.#keyMap.delete(k);
|
|
275221
|
-
this.#keyList[index] = undefined;
|
|
275222
|
-
this.#valList[index] = undefined;
|
|
275223
|
-
if (index === this.#tail) {
|
|
275224
|
-
this.#tail = this.#prev[index];
|
|
275225
|
-
}
|
|
275226
|
-
else if (index === this.#head) {
|
|
275227
|
-
this.#head = this.#next[index];
|
|
275228
|
-
}
|
|
275229
|
-
else {
|
|
275230
|
-
this.#next[this.#prev[index]] = this.#next[index];
|
|
275231
|
-
this.#prev[this.#next[index]] = this.#prev[index];
|
|
275232
|
-
}
|
|
275233
|
-
this.#size--;
|
|
275234
|
-
this.#free.push(index);
|
|
274144
|
+
head = 0;
|
|
274145
|
+
tail = preserve - 1;
|
|
274146
|
+
size = preserve;
|
|
274147
|
+
keyList.length = newMax;
|
|
274148
|
+
valList.length = newMax;
|
|
274149
|
+
next.length = newMax;
|
|
274150
|
+
prev.length = newMax;
|
|
274151
|
+
for (let i = 0; i < preserve; i++) {
|
|
274152
|
+
keyList[i] = newKeyList[i];
|
|
274153
|
+
valList[i] = newValList[i];
|
|
274154
|
+
next[i] = newNext[i];
|
|
274155
|
+
prev[i] = newPrev[i];
|
|
275235
274156
|
}
|
|
275236
|
-
|
|
275237
|
-
|
|
275238
|
-
|
|
275239
|
-
const dt = this.#disposed;
|
|
275240
|
-
let task;
|
|
275241
|
-
while ((task = dt?.shift())) {
|
|
275242
|
-
this.#disposeAfter?.(...task);
|
|
275243
|
-
}
|
|
275244
|
-
}
|
|
275245
|
-
return deleted;
|
|
275246
|
-
}
|
|
275247
|
-
/**
|
|
275248
|
-
* Clear the cache entirely, throwing away all values.
|
|
275249
|
-
*/
|
|
275250
|
-
clear() {
|
|
275251
|
-
for (const index of this.#rindexes({ allowStale: true })) {
|
|
275252
|
-
const v = this.#valList[index];
|
|
275253
|
-
if (this.#isBackgroundFetch(v)) {
|
|
275254
|
-
v.__abortController.abort(new Error('deleted'));
|
|
274157
|
+
free = [];
|
|
274158
|
+
for (let i = preserve; i < newMax; i++)
|
|
274159
|
+
free.push(i);
|
|
275255
274160
|
}
|
|
275256
274161
|
else {
|
|
275257
|
-
const
|
|
275258
|
-
|
|
275259
|
-
|
|
275260
|
-
|
|
275261
|
-
|
|
275262
|
-
this.#disposed?.push([v, k, 'delete']);
|
|
275263
|
-
}
|
|
274162
|
+
const fill = newMax - max;
|
|
274163
|
+
keyList.push(...new Array(fill).fill(undefined));
|
|
274164
|
+
valList.push(...new Array(fill).fill(undefined));
|
|
274165
|
+
next.push(...new Array(fill).fill(0));
|
|
274166
|
+
prev.push(...new Array(fill).fill(0));
|
|
275264
274167
|
}
|
|
275265
|
-
|
|
275266
|
-
|
|
275267
|
-
|
|
275268
|
-
|
|
275269
|
-
|
|
275270
|
-
|
|
275271
|
-
|
|
275272
|
-
|
|
275273
|
-
|
|
275274
|
-
|
|
275275
|
-
|
|
275276
|
-
|
|
275277
|
-
|
|
275278
|
-
|
|
275279
|
-
|
|
275280
|
-
this.#size = 0;
|
|
275281
|
-
if (this.#hasDisposeAfter && this.#disposed) {
|
|
275282
|
-
const dt = this.#disposed;
|
|
275283
|
-
let task;
|
|
275284
|
-
while ((task = dt?.shift())) {
|
|
275285
|
-
this.#disposeAfter?.(...task);
|
|
275286
|
-
}
|
|
275287
|
-
}
|
|
275288
|
-
}
|
|
275289
|
-
}
|
|
275290
|
-
cjs.LRUCache = LRUCache;
|
|
275291
|
-
cjs.default = LRUCache;var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
275292
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
274168
|
+
max = newMax;
|
|
274169
|
+
},
|
|
274170
|
+
/** Returns the maximum number of items that can be stored in the cache. */
|
|
274171
|
+
get max() {
|
|
274172
|
+
return max;
|
|
274173
|
+
},
|
|
274174
|
+
/** Returns the number of items currently stored in the cache. */
|
|
274175
|
+
get size() {
|
|
274176
|
+
return size;
|
|
274177
|
+
},
|
|
274178
|
+
/** Returns the number of currently available slots in the cache before reaching the maximum size. */
|
|
274179
|
+
get available() {
|
|
274180
|
+
return max - size;
|
|
274181
|
+
},
|
|
274182
|
+
};
|
|
275293
274183
|
};
|
|
275294
|
-
|
|
275295
|
-
var indexCjs = Object.assign(index_js_1.default, { default: index_js_1.default, LRUCache: index_js_1.default });var errors$5 = {};(function (exports) {
|
|
274184
|
+
lib$4.createLRU = createLRU$2;var errors$5 = {};(function (exports) {
|
|
275296
274185
|
|
|
275297
274186
|
// originally copied from https://raw.githubusercontent.com/mysqljs/mysql/7770ee5bb13260c56a160b91fe480d9165dbeeba/lib/protocol/constants/errors.js
|
|
275298
274187
|
// (c) node-mysql authors
|
|
@@ -279256,9 +278145,9 @@ var indexCjs = Object.assign(index_js_1.default, { default: index_js_1.default,
|
|
|
279256
278145
|
exports[4161] = 'ER_INSTALL_COMPONENT_SET_UNUSED_VALUE';
|
|
279257
278146
|
exports[4162] = 'ER_WARN_DEPRECATED_USER_DEFINED_COLLATIONS';
|
|
279258
278147
|
} (errors$5));var string$1 = {};const Iconv = libExports$2;
|
|
279259
|
-
const
|
|
278148
|
+
const { createLRU: createLRU$1 } = lib$4;
|
|
279260
278149
|
|
|
279261
|
-
const decoderCache =
|
|
278150
|
+
const decoderCache = createLRU$1({
|
|
279262
278151
|
max: 500,
|
|
279263
278152
|
});
|
|
279264
278153
|
|
|
@@ -284308,9 +283197,9 @@ var genfun = function() {
|
|
|
284308
283197
|
};
|
|
284309
283198
|
|
|
284310
283199
|
genfun.formats = formats;
|
|
284311
|
-
var generateFunction = genfun;const
|
|
283200
|
+
var generateFunction = genfun;const { createLRU } = lib$4;
|
|
284312
283201
|
|
|
284313
|
-
|
|
283202
|
+
const parserCache$2 = createLRU({
|
|
284314
283203
|
max: 15000,
|
|
284315
283204
|
});
|
|
284316
283205
|
|
|
@@ -284359,7 +283248,7 @@ function getParser(type, fields, options, config, compiler) {
|
|
|
284359
283248
|
}
|
|
284360
283249
|
|
|
284361
283250
|
function setMaxCache(max) {
|
|
284362
|
-
parserCache$2
|
|
283251
|
+
parserCache$2.resize(max);
|
|
284363
283252
|
}
|
|
284364
283253
|
|
|
284365
283254
|
function clearCache() {
|
|
@@ -285777,7 +284666,7 @@ var commands$7 = {
|
|
|
285777
284666
|
ChangeUser,
|
|
285778
284667
|
Quit
|
|
285779
284668
|
};var name$1 = "mysql2";
|
|
285780
|
-
var version$2 = "3.11.
|
|
284669
|
+
var version$2 = "3.11.3";
|
|
285781
284670
|
var description = "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS";
|
|
285782
284671
|
var main$1 = "index.js";
|
|
285783
284672
|
var typings = "typings/mysql/index";
|
|
@@ -285834,13 +284723,13 @@ var dependencies$1 = {
|
|
|
285834
284723
|
"generate-function": "^2.3.1",
|
|
285835
284724
|
"iconv-lite": "^0.6.3",
|
|
285836
284725
|
long: "^5.2.1",
|
|
285837
|
-
"lru
|
|
284726
|
+
"lru.min": "^1.0.0",
|
|
285838
284727
|
"named-placeholders": "^1.1.3",
|
|
285839
284728
|
"seq-queue": "^0.0.5",
|
|
285840
284729
|
sqlstring: "^2.3.2"
|
|
285841
284730
|
};
|
|
285842
284731
|
var devDependencies$1 = {
|
|
285843
|
-
"@types/node": "^
|
|
284732
|
+
"@types/node": "^22.0.0",
|
|
285844
284733
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
285845
284734
|
"@typescript-eslint/parser": "^5.42.1",
|
|
285846
284735
|
"assert-diff": "^3.0.2",
|
|
@@ -289660,10 +288549,10 @@ function requirePromise () {
|
|
|
289660
288549
|
inheritEvents(poolCluster, this, ['warn', 'remove']);
|
|
289661
288550
|
}
|
|
289662
288551
|
|
|
289663
|
-
getConnection() {
|
|
288552
|
+
getConnection(pattern, selector) {
|
|
289664
288553
|
const corePoolCluster = this.poolCluster;
|
|
289665
288554
|
return new this.Promise((resolve, reject) => {
|
|
289666
|
-
corePoolCluster.getConnection((err, coreConnection) => {
|
|
288555
|
+
corePoolCluster.getConnection(pattern, selector, (err, coreConnection) => {
|
|
289667
288556
|
if (err) {
|
|
289668
288557
|
reject(err);
|
|
289669
288558
|
} else {
|
|
@@ -291224,7 +290113,7 @@ function requireConnection () {
|
|
|
291224
290113
|
const Readable = require$$0$b.Readable;
|
|
291225
290114
|
const Queue = denque;
|
|
291226
290115
|
const SqlString = sqlstring;
|
|
291227
|
-
const
|
|
290116
|
+
const { createLRU } = lib$4;
|
|
291228
290117
|
|
|
291229
290118
|
const PacketParser = packet_parser;
|
|
291230
290119
|
const Packets = packetsExports;
|
|
@@ -291277,9 +290166,9 @@ function requireConnection () {
|
|
|
291277
290166
|
this._command = null;
|
|
291278
290167
|
this._paused = false;
|
|
291279
290168
|
this._paused_packets = new Queue();
|
|
291280
|
-
this._statements =
|
|
290169
|
+
this._statements = createLRU({
|
|
291281
290170
|
max: this.config.maxPreparedStatements,
|
|
291282
|
-
|
|
290171
|
+
onEviction: function(_, statement) {
|
|
291283
290172
|
statement.close();
|
|
291284
290173
|
}
|
|
291285
290174
|
});
|
|
@@ -291613,7 +290502,7 @@ function requireConnection () {
|
|
|
291613
290502
|
err.code = code || 'PROTOCOL_ERROR';
|
|
291614
290503
|
this.emit('error', err);
|
|
291615
290504
|
}
|
|
291616
|
-
|
|
290505
|
+
|
|
291617
290506
|
get fatalError() {
|
|
291618
290507
|
return this._fatalError;
|
|
291619
290508
|
}
|
|
@@ -292431,9 +291320,10 @@ function requirePool () {
|
|
|
292431
291320
|
this._removeIdleTimeoutConnectionsTimer = setTimeout(() => {
|
|
292432
291321
|
try {
|
|
292433
291322
|
while (
|
|
292434
|
-
this._freeConnections.length > this.config.maxIdle
|
|
292435
|
-
|
|
292436
|
-
this.
|
|
291323
|
+
this._freeConnections.length > this.config.maxIdle ||
|
|
291324
|
+
(this._freeConnections.length > 0 &&
|
|
291325
|
+
Date.now() - this._freeConnections.get(0).lastActiveTime >
|
|
291326
|
+
this.config.idleTimeout)
|
|
292437
291327
|
) {
|
|
292438
291328
|
this._freeConnections.get(0).destroy();
|
|
292439
291329
|
}
|