html-validate-vue 4.2.2 → 4.2.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 +596 -658
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -358,7 +358,7 @@ var require_semver = __commonJS({
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
if (identifier) {
|
|
361
|
-
if (this.prerelease[0] ===
|
|
361
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
362
362
|
if (isNaN(this.prerelease[1])) {
|
|
363
363
|
this.prerelease = [identifier, 0];
|
|
364
364
|
}
|
|
@@ -445,7 +445,7 @@ var require_inc = __commonJS({
|
|
|
445
445
|
options = void 0;
|
|
446
446
|
}
|
|
447
447
|
try {
|
|
448
|
-
return new SemVer(version, options).inc(release, identifier).version;
|
|
448
|
+
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier).version;
|
|
449
449
|
} catch (er) {
|
|
450
450
|
return null;
|
|
451
451
|
}
|
|
@@ -721,715 +721,653 @@ var require_coerce = __commonJS({
|
|
|
721
721
|
}
|
|
722
722
|
});
|
|
723
723
|
|
|
724
|
-
// node_modules/
|
|
725
|
-
var
|
|
726
|
-
"node_modules/
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
warn(code, `${field} property`, `cache.${instead}`, get);
|
|
762
|
-
}
|
|
763
|
-
};
|
|
764
|
-
var emitWarning = (...a) => {
|
|
765
|
-
typeof process === "object" && process && typeof process.emitWarning === "function" ? process.emitWarning(...a) : console.error(...a);
|
|
766
|
-
};
|
|
767
|
-
var shouldWarn = (code) => !warned.has(code);
|
|
768
|
-
var warn = (code, what, instead, fn) => {
|
|
769
|
-
warned.add(code);
|
|
770
|
-
const msg = `The ${what} is deprecated. Please use ${instead} instead.`;
|
|
771
|
-
emitWarning(msg, "DeprecationWarning", code, fn);
|
|
772
|
-
};
|
|
773
|
-
var isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
774
|
-
var getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null;
|
|
775
|
-
var ZeroArray = class extends Array {
|
|
776
|
-
constructor(size) {
|
|
777
|
-
super(size);
|
|
778
|
-
this.fill(0);
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
var Stack = class {
|
|
782
|
-
constructor(max) {
|
|
783
|
-
const UintArray = max ? getUintArray(max) : Array;
|
|
784
|
-
this.heap = new UintArray(max);
|
|
785
|
-
this.length = 0;
|
|
786
|
-
}
|
|
787
|
-
push(n) {
|
|
788
|
-
this.heap[this.length++] = n;
|
|
724
|
+
// node_modules/yallist/iterator.js
|
|
725
|
+
var require_iterator = __commonJS({
|
|
726
|
+
"node_modules/yallist/iterator.js"(exports2, module2) {
|
|
727
|
+
"use strict";
|
|
728
|
+
module2.exports = function(Yallist) {
|
|
729
|
+
Yallist.prototype[Symbol.iterator] = function* () {
|
|
730
|
+
for (let walker = this.head; walker; walker = walker.next) {
|
|
731
|
+
yield walker.value;
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
// node_modules/yallist/yallist.js
|
|
739
|
+
var require_yallist = __commonJS({
|
|
740
|
+
"node_modules/yallist/yallist.js"(exports2, module2) {
|
|
741
|
+
"use strict";
|
|
742
|
+
module2.exports = Yallist;
|
|
743
|
+
Yallist.Node = Node;
|
|
744
|
+
Yallist.create = Yallist;
|
|
745
|
+
function Yallist(list) {
|
|
746
|
+
var self = this;
|
|
747
|
+
if (!(self instanceof Yallist)) {
|
|
748
|
+
self = new Yallist();
|
|
749
|
+
}
|
|
750
|
+
self.tail = null;
|
|
751
|
+
self.head = null;
|
|
752
|
+
self.length = 0;
|
|
753
|
+
if (list && typeof list.forEach === "function") {
|
|
754
|
+
list.forEach(function(item) {
|
|
755
|
+
self.push(item);
|
|
756
|
+
});
|
|
757
|
+
} else if (arguments.length > 0) {
|
|
758
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
759
|
+
self.push(arguments[i]);
|
|
760
|
+
}
|
|
789
761
|
}
|
|
790
|
-
|
|
791
|
-
|
|
762
|
+
return self;
|
|
763
|
+
}
|
|
764
|
+
Yallist.prototype.removeNode = function(node) {
|
|
765
|
+
if (node.list !== this) {
|
|
766
|
+
throw new Error("removing node which does not belong to this list");
|
|
767
|
+
}
|
|
768
|
+
var next = node.next;
|
|
769
|
+
var prev = node.prev;
|
|
770
|
+
if (next) {
|
|
771
|
+
next.prev = prev;
|
|
772
|
+
}
|
|
773
|
+
if (prev) {
|
|
774
|
+
prev.next = next;
|
|
775
|
+
}
|
|
776
|
+
if (node === this.head) {
|
|
777
|
+
this.head = next;
|
|
792
778
|
}
|
|
779
|
+
if (node === this.tail) {
|
|
780
|
+
this.tail = prev;
|
|
781
|
+
}
|
|
782
|
+
node.list.length--;
|
|
783
|
+
node.next = null;
|
|
784
|
+
node.prev = null;
|
|
785
|
+
node.list = null;
|
|
786
|
+
return next;
|
|
793
787
|
};
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
max = 0,
|
|
798
|
-
ttl,
|
|
799
|
-
ttlResolution = 1,
|
|
800
|
-
ttlAutopurge,
|
|
801
|
-
updateAgeOnGet,
|
|
802
|
-
updateAgeOnHas,
|
|
803
|
-
allowStale,
|
|
804
|
-
dispose,
|
|
805
|
-
disposeAfter,
|
|
806
|
-
noDisposeOnSet,
|
|
807
|
-
noUpdateTTL,
|
|
808
|
-
maxSize = 0,
|
|
809
|
-
sizeCalculation,
|
|
810
|
-
fetchMethod
|
|
811
|
-
} = options;
|
|
812
|
-
const {
|
|
813
|
-
length,
|
|
814
|
-
maxAge,
|
|
815
|
-
stale
|
|
816
|
-
} = options instanceof LRUCache ? {} : options;
|
|
817
|
-
if (max !== 0 && !isPosInt(max)) {
|
|
818
|
-
throw new TypeError("max option must be a nonnegative integer");
|
|
819
|
-
}
|
|
820
|
-
const UintArray = max ? getUintArray(max) : Array;
|
|
821
|
-
if (!UintArray) {
|
|
822
|
-
throw new Error("invalid max value: " + max);
|
|
823
|
-
}
|
|
824
|
-
this.max = max;
|
|
825
|
-
this.maxSize = maxSize;
|
|
826
|
-
this.sizeCalculation = sizeCalculation || length;
|
|
827
|
-
if (this.sizeCalculation) {
|
|
828
|
-
if (!this.maxSize) {
|
|
829
|
-
throw new TypeError("cannot set sizeCalculation without setting maxSize");
|
|
830
|
-
}
|
|
831
|
-
if (typeof this.sizeCalculation !== "function") {
|
|
832
|
-
throw new TypeError("sizeCalculation set to non-function");
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
this.fetchMethod = fetchMethod || null;
|
|
836
|
-
if (this.fetchMethod && typeof this.fetchMethod !== "function") {
|
|
837
|
-
throw new TypeError("fetchMethod must be a function if specified");
|
|
838
|
-
}
|
|
839
|
-
this.keyMap = /* @__PURE__ */ new Map();
|
|
840
|
-
this.keyList = new Array(max).fill(null);
|
|
841
|
-
this.valList = new Array(max).fill(null);
|
|
842
|
-
this.next = new UintArray(max);
|
|
843
|
-
this.prev = new UintArray(max);
|
|
844
|
-
this.head = 0;
|
|
845
|
-
this.tail = 0;
|
|
846
|
-
this.free = new Stack(max);
|
|
847
|
-
this.initialFill = 1;
|
|
848
|
-
this.size = 0;
|
|
849
|
-
if (typeof dispose === "function") {
|
|
850
|
-
this.dispose = dispose;
|
|
851
|
-
}
|
|
852
|
-
if (typeof disposeAfter === "function") {
|
|
853
|
-
this.disposeAfter = disposeAfter;
|
|
854
|
-
this.disposed = [];
|
|
855
|
-
} else {
|
|
856
|
-
this.disposeAfter = null;
|
|
857
|
-
this.disposed = null;
|
|
858
|
-
}
|
|
859
|
-
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
860
|
-
this.noUpdateTTL = !!noUpdateTTL;
|
|
861
|
-
if (this.maxSize !== 0) {
|
|
862
|
-
if (!isPosInt(this.maxSize)) {
|
|
863
|
-
throw new TypeError("maxSize must be a positive integer if specified");
|
|
864
|
-
}
|
|
865
|
-
this.initializeSizeTracking();
|
|
866
|
-
}
|
|
867
|
-
this.allowStale = !!allowStale || !!stale;
|
|
868
|
-
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
869
|
-
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
870
|
-
this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
|
|
871
|
-
this.ttlAutopurge = !!ttlAutopurge;
|
|
872
|
-
this.ttl = ttl || maxAge || 0;
|
|
873
|
-
if (this.ttl) {
|
|
874
|
-
if (!isPosInt(this.ttl)) {
|
|
875
|
-
throw new TypeError("ttl must be a positive integer if specified");
|
|
876
|
-
}
|
|
877
|
-
this.initializeTTLTracking();
|
|
878
|
-
}
|
|
879
|
-
if (this.max === 0 && this.ttl === 0 && this.maxSize === 0) {
|
|
880
|
-
throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
881
|
-
}
|
|
882
|
-
if (!this.ttlAutopurge && !this.max && !this.maxSize) {
|
|
883
|
-
const code = "LRU_CACHE_UNBOUNDED";
|
|
884
|
-
if (shouldWarn(code)) {
|
|
885
|
-
warned.add(code);
|
|
886
|
-
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
887
|
-
emitWarning(msg, "UnboundedCacheWarning", code, LRUCache);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
if (stale) {
|
|
891
|
-
deprecatedOption("stale", "allowStale");
|
|
892
|
-
}
|
|
893
|
-
if (maxAge) {
|
|
894
|
-
deprecatedOption("maxAge", "ttl");
|
|
895
|
-
}
|
|
896
|
-
if (length) {
|
|
897
|
-
deprecatedOption("length", "sizeCalculation");
|
|
898
|
-
}
|
|
788
|
+
Yallist.prototype.unshiftNode = function(node) {
|
|
789
|
+
if (node === this.head) {
|
|
790
|
+
return;
|
|
899
791
|
}
|
|
900
|
-
|
|
901
|
-
|
|
792
|
+
if (node.list) {
|
|
793
|
+
node.list.removeNode(node);
|
|
902
794
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
this.ttls[index] = ttl;
|
|
909
|
-
if (ttl !== 0 && this.ttlAutopurge) {
|
|
910
|
-
const t = setTimeout(() => {
|
|
911
|
-
if (this.isStale(index)) {
|
|
912
|
-
this.delete(this.keyList[index]);
|
|
913
|
-
}
|
|
914
|
-
}, ttl + 1);
|
|
915
|
-
if (t.unref) {
|
|
916
|
-
t.unref();
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
};
|
|
920
|
-
this.updateItemAge = (index) => {
|
|
921
|
-
this.starts[index] = this.ttls[index] !== 0 ? perf.now() : 0;
|
|
922
|
-
};
|
|
923
|
-
let cachedNow = 0;
|
|
924
|
-
const getNow = () => {
|
|
925
|
-
const n = perf.now();
|
|
926
|
-
if (this.ttlResolution > 0) {
|
|
927
|
-
cachedNow = n;
|
|
928
|
-
const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
|
|
929
|
-
if (t.unref) {
|
|
930
|
-
t.unref();
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
return n;
|
|
934
|
-
};
|
|
935
|
-
this.getRemainingTTL = (key) => {
|
|
936
|
-
const index = this.keyMap.get(key);
|
|
937
|
-
if (index === void 0) {
|
|
938
|
-
return 0;
|
|
939
|
-
}
|
|
940
|
-
return this.ttls[index] === 0 || this.starts[index] === 0 ? Infinity : this.starts[index] + this.ttls[index] - (cachedNow || getNow());
|
|
941
|
-
};
|
|
942
|
-
this.isStale = (index) => {
|
|
943
|
-
return this.ttls[index] !== 0 && this.starts[index] !== 0 && (cachedNow || getNow()) - this.starts[index] > this.ttls[index];
|
|
944
|
-
};
|
|
795
|
+
var head = this.head;
|
|
796
|
+
node.list = this;
|
|
797
|
+
node.next = head;
|
|
798
|
+
if (head) {
|
|
799
|
+
head.prev = node;
|
|
945
800
|
}
|
|
946
|
-
|
|
801
|
+
this.head = node;
|
|
802
|
+
if (!this.tail) {
|
|
803
|
+
this.tail = node;
|
|
947
804
|
}
|
|
948
|
-
|
|
805
|
+
this.length++;
|
|
806
|
+
};
|
|
807
|
+
Yallist.prototype.pushNode = function(node) {
|
|
808
|
+
if (node === this.tail) {
|
|
809
|
+
return;
|
|
949
810
|
}
|
|
950
|
-
|
|
951
|
-
|
|
811
|
+
if (node.list) {
|
|
812
|
+
node.list.removeNode(node);
|
|
952
813
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
if (!isPosInt(size)) {
|
|
959
|
-
if (sizeCalculation) {
|
|
960
|
-
if (typeof sizeCalculation !== "function") {
|
|
961
|
-
throw new TypeError("sizeCalculation must be a function");
|
|
962
|
-
}
|
|
963
|
-
size = sizeCalculation(v, k);
|
|
964
|
-
if (!isPosInt(size)) {
|
|
965
|
-
throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
966
|
-
}
|
|
967
|
-
} else {
|
|
968
|
-
throw new TypeError("invalid size value (must be positive integer)");
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
return size;
|
|
972
|
-
};
|
|
973
|
-
this.addItemSize = (index, v, k, size) => {
|
|
974
|
-
this.sizes[index] = size;
|
|
975
|
-
const maxSize = this.maxSize - this.sizes[index];
|
|
976
|
-
while (this.calculatedSize > maxSize) {
|
|
977
|
-
this.evict();
|
|
978
|
-
}
|
|
979
|
-
this.calculatedSize += this.sizes[index];
|
|
980
|
-
};
|
|
981
|
-
this.delete = (k) => {
|
|
982
|
-
if (this.size !== 0) {
|
|
983
|
-
const index = this.keyMap.get(k);
|
|
984
|
-
if (index !== void 0) {
|
|
985
|
-
this.calculatedSize -= this.sizes[index];
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
return LRUCache.prototype.delete.call(this, k);
|
|
989
|
-
};
|
|
814
|
+
var tail = this.tail;
|
|
815
|
+
node.list = this;
|
|
816
|
+
node.prev = tail;
|
|
817
|
+
if (tail) {
|
|
818
|
+
tail.next = node;
|
|
990
819
|
}
|
|
991
|
-
|
|
820
|
+
this.tail = node;
|
|
821
|
+
if (!this.head) {
|
|
822
|
+
this.head = node;
|
|
992
823
|
}
|
|
993
|
-
|
|
824
|
+
this.length++;
|
|
825
|
+
};
|
|
826
|
+
Yallist.prototype.push = function() {
|
|
827
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
828
|
+
push(this, arguments[i]);
|
|
994
829
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
830
|
+
return this.length;
|
|
831
|
+
};
|
|
832
|
+
Yallist.prototype.unshift = function() {
|
|
833
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
834
|
+
unshift(this, arguments[i]);
|
|
999
835
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
i = this.prev[i];
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
836
|
+
return this.length;
|
|
837
|
+
};
|
|
838
|
+
Yallist.prototype.pop = function() {
|
|
839
|
+
if (!this.tail) {
|
|
840
|
+
return void 0;
|
|
841
|
+
}
|
|
842
|
+
var res = this.tail.value;
|
|
843
|
+
this.tail = this.tail.prev;
|
|
844
|
+
if (this.tail) {
|
|
845
|
+
this.tail.next = null;
|
|
846
|
+
} else {
|
|
847
|
+
this.head = null;
|
|
1016
848
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
849
|
+
this.length--;
|
|
850
|
+
return res;
|
|
851
|
+
};
|
|
852
|
+
Yallist.prototype.shift = function() {
|
|
853
|
+
if (!this.head) {
|
|
854
|
+
return void 0;
|
|
855
|
+
}
|
|
856
|
+
var res = this.head.value;
|
|
857
|
+
this.head = this.head.next;
|
|
858
|
+
if (this.head) {
|
|
859
|
+
this.head.prev = null;
|
|
860
|
+
} else {
|
|
861
|
+
this.tail = null;
|
|
1033
862
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
863
|
+
this.length--;
|
|
864
|
+
return res;
|
|
865
|
+
};
|
|
866
|
+
Yallist.prototype.forEach = function(fn, thisp) {
|
|
867
|
+
thisp = thisp || this;
|
|
868
|
+
for (var walker = this.head, i = 0; walker !== null; i++) {
|
|
869
|
+
fn.call(thisp, walker.value, i, this);
|
|
870
|
+
walker = walker.next;
|
|
1036
871
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
872
|
+
};
|
|
873
|
+
Yallist.prototype.forEachReverse = function(fn, thisp) {
|
|
874
|
+
thisp = thisp || this;
|
|
875
|
+
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
|
876
|
+
fn.call(thisp, walker.value, i, this);
|
|
877
|
+
walker = walker.prev;
|
|
1041
878
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
879
|
+
};
|
|
880
|
+
Yallist.prototype.get = function(n) {
|
|
881
|
+
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
|
882
|
+
walker = walker.next;
|
|
1046
883
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
yield this.keyList[i];
|
|
1050
|
-
}
|
|
884
|
+
if (i === n && walker !== null) {
|
|
885
|
+
return walker.value;
|
|
1051
886
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
887
|
+
};
|
|
888
|
+
Yallist.prototype.getReverse = function(n) {
|
|
889
|
+
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
|
890
|
+
walker = walker.prev;
|
|
1056
891
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
yield this.valList[i];
|
|
1060
|
-
}
|
|
892
|
+
if (i === n && walker !== null) {
|
|
893
|
+
return walker.value;
|
|
1061
894
|
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
895
|
+
};
|
|
896
|
+
Yallist.prototype.map = function(fn, thisp) {
|
|
897
|
+
thisp = thisp || this;
|
|
898
|
+
var res = new Yallist();
|
|
899
|
+
for (var walker = this.head; walker !== null; ) {
|
|
900
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
901
|
+
walker = walker.next;
|
|
902
|
+
}
|
|
903
|
+
return res;
|
|
904
|
+
};
|
|
905
|
+
Yallist.prototype.mapReverse = function(fn, thisp) {
|
|
906
|
+
thisp = thisp || this;
|
|
907
|
+
var res = new Yallist();
|
|
908
|
+
for (var walker = this.tail; walker !== null; ) {
|
|
909
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
910
|
+
walker = walker.prev;
|
|
911
|
+
}
|
|
912
|
+
return res;
|
|
913
|
+
};
|
|
914
|
+
Yallist.prototype.reduce = function(fn, initial) {
|
|
915
|
+
var acc;
|
|
916
|
+
var walker = this.head;
|
|
917
|
+
if (arguments.length > 1) {
|
|
918
|
+
acc = initial;
|
|
919
|
+
} else if (this.head) {
|
|
920
|
+
walker = this.head.next;
|
|
921
|
+
acc = this.head.value;
|
|
922
|
+
} else {
|
|
923
|
+
throw new TypeError("Reduce of empty list with no initial value");
|
|
1066
924
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
925
|
+
for (var i = 0; walker !== null; i++) {
|
|
926
|
+
acc = fn(acc, walker.value, i);
|
|
927
|
+
walker = walker.next;
|
|
1069
928
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
929
|
+
return acc;
|
|
930
|
+
};
|
|
931
|
+
Yallist.prototype.reduceReverse = function(fn, initial) {
|
|
932
|
+
var acc;
|
|
933
|
+
var walker = this.tail;
|
|
934
|
+
if (arguments.length > 1) {
|
|
935
|
+
acc = initial;
|
|
936
|
+
} else if (this.tail) {
|
|
937
|
+
walker = this.tail.prev;
|
|
938
|
+
acc = this.tail.value;
|
|
939
|
+
} else {
|
|
940
|
+
throw new TypeError("Reduce of empty list with no initial value");
|
|
941
|
+
}
|
|
942
|
+
for (var i = this.length - 1; walker !== null; i--) {
|
|
943
|
+
acc = fn(acc, walker.value, i);
|
|
944
|
+
walker = walker.prev;
|
|
945
|
+
}
|
|
946
|
+
return acc;
|
|
947
|
+
};
|
|
948
|
+
Yallist.prototype.toArray = function() {
|
|
949
|
+
var arr = new Array(this.length);
|
|
950
|
+
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
951
|
+
arr[i] = walker.value;
|
|
952
|
+
walker = walker.next;
|
|
953
|
+
}
|
|
954
|
+
return arr;
|
|
955
|
+
};
|
|
956
|
+
Yallist.prototype.toArrayReverse = function() {
|
|
957
|
+
var arr = new Array(this.length);
|
|
958
|
+
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
|
959
|
+
arr[i] = walker.value;
|
|
960
|
+
walker = walker.prev;
|
|
961
|
+
}
|
|
962
|
+
return arr;
|
|
963
|
+
};
|
|
964
|
+
Yallist.prototype.slice = function(from, to) {
|
|
965
|
+
to = to || this.length;
|
|
966
|
+
if (to < 0) {
|
|
967
|
+
to += this.length;
|
|
968
|
+
}
|
|
969
|
+
from = from || 0;
|
|
970
|
+
if (from < 0) {
|
|
971
|
+
from += this.length;
|
|
972
|
+
}
|
|
973
|
+
var ret = new Yallist();
|
|
974
|
+
if (to < from || to < 0) {
|
|
975
|
+
return ret;
|
|
976
|
+
}
|
|
977
|
+
if (from < 0) {
|
|
978
|
+
from = 0;
|
|
979
|
+
}
|
|
980
|
+
if (to > this.length) {
|
|
981
|
+
to = this.length;
|
|
982
|
+
}
|
|
983
|
+
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
984
|
+
walker = walker.next;
|
|
985
|
+
}
|
|
986
|
+
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
987
|
+
ret.push(walker.value);
|
|
988
|
+
}
|
|
989
|
+
return ret;
|
|
990
|
+
};
|
|
991
|
+
Yallist.prototype.sliceReverse = function(from, to) {
|
|
992
|
+
to = to || this.length;
|
|
993
|
+
if (to < 0) {
|
|
994
|
+
to += this.length;
|
|
995
|
+
}
|
|
996
|
+
from = from || 0;
|
|
997
|
+
if (from < 0) {
|
|
998
|
+
from += this.length;
|
|
999
|
+
}
|
|
1000
|
+
var ret = new Yallist();
|
|
1001
|
+
if (to < from || to < 0) {
|
|
1002
|
+
return ret;
|
|
1003
|
+
}
|
|
1004
|
+
if (from < 0) {
|
|
1005
|
+
from = 0;
|
|
1006
|
+
}
|
|
1007
|
+
if (to > this.length) {
|
|
1008
|
+
to = this.length;
|
|
1009
|
+
}
|
|
1010
|
+
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
|
1011
|
+
walker = walker.prev;
|
|
1012
|
+
}
|
|
1013
|
+
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
|
1014
|
+
ret.push(walker.value);
|
|
1015
|
+
}
|
|
1016
|
+
return ret;
|
|
1017
|
+
};
|
|
1018
|
+
Yallist.prototype.splice = function(start, deleteCount, ...nodes) {
|
|
1019
|
+
if (start > this.length) {
|
|
1020
|
+
start = this.length - 1;
|
|
1021
|
+
}
|
|
1022
|
+
if (start < 0) {
|
|
1023
|
+
start = this.length + start;
|
|
1024
|
+
}
|
|
1025
|
+
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
|
1026
|
+
walker = walker.next;
|
|
1027
|
+
}
|
|
1028
|
+
var ret = [];
|
|
1029
|
+
for (var i = 0; walker && i < deleteCount; i++) {
|
|
1030
|
+
ret.push(walker.value);
|
|
1031
|
+
walker = this.removeNode(walker);
|
|
1032
|
+
}
|
|
1033
|
+
if (walker === null) {
|
|
1034
|
+
walker = this.tail;
|
|
1035
|
+
}
|
|
1036
|
+
if (walker !== this.head && walker !== this.tail) {
|
|
1037
|
+
walker = walker.prev;
|
|
1038
|
+
}
|
|
1039
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
1040
|
+
walker = insert(this, walker, nodes[i]);
|
|
1041
|
+
}
|
|
1042
|
+
return ret;
|
|
1043
|
+
};
|
|
1044
|
+
Yallist.prototype.reverse = function() {
|
|
1045
|
+
var head = this.head;
|
|
1046
|
+
var tail = this.tail;
|
|
1047
|
+
for (var walker = head; walker !== null; walker = walker.prev) {
|
|
1048
|
+
var p = walker.prev;
|
|
1049
|
+
walker.prev = walker.next;
|
|
1050
|
+
walker.next = p;
|
|
1051
|
+
}
|
|
1052
|
+
this.head = tail;
|
|
1053
|
+
this.tail = head;
|
|
1054
|
+
return this;
|
|
1055
|
+
};
|
|
1056
|
+
function insert(self, node, value) {
|
|
1057
|
+
var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self);
|
|
1058
|
+
if (inserted.next === null) {
|
|
1059
|
+
self.tail = inserted;
|
|
1060
|
+
}
|
|
1061
|
+
if (inserted.prev === null) {
|
|
1062
|
+
self.head = inserted;
|
|
1063
|
+
}
|
|
1064
|
+
self.length++;
|
|
1065
|
+
return inserted;
|
|
1066
|
+
}
|
|
1067
|
+
function push(self, item) {
|
|
1068
|
+
self.tail = new Node(item, self.tail, null, self);
|
|
1069
|
+
if (!self.head) {
|
|
1070
|
+
self.head = self.tail;
|
|
1071
|
+
}
|
|
1072
|
+
self.length++;
|
|
1073
|
+
}
|
|
1074
|
+
function unshift(self, item) {
|
|
1075
|
+
self.head = new Node(item, null, self.head, self);
|
|
1076
|
+
if (!self.tail) {
|
|
1077
|
+
self.tail = self.head;
|
|
1078
|
+
}
|
|
1079
|
+
self.length++;
|
|
1080
|
+
}
|
|
1081
|
+
function Node(value, prev, next, list) {
|
|
1082
|
+
if (!(this instanceof Node)) {
|
|
1083
|
+
return new Node(value, prev, next, list);
|
|
1084
|
+
}
|
|
1085
|
+
this.list = list;
|
|
1086
|
+
this.value = value;
|
|
1087
|
+
if (prev) {
|
|
1088
|
+
prev.next = this;
|
|
1089
|
+
this.prev = prev;
|
|
1090
|
+
} else {
|
|
1091
|
+
this.prev = null;
|
|
1092
|
+
}
|
|
1093
|
+
if (next) {
|
|
1094
|
+
next.prev = this;
|
|
1095
|
+
this.next = next;
|
|
1096
|
+
} else {
|
|
1097
|
+
this.next = null;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
try {
|
|
1101
|
+
require_iterator()(Yallist);
|
|
1102
|
+
} catch (er) {
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
// node_modules/lru-cache/index.js
|
|
1108
|
+
var require_lru_cache = __commonJS({
|
|
1109
|
+
"node_modules/lru-cache/index.js"(exports2, module2) {
|
|
1110
|
+
"use strict";
|
|
1111
|
+
var Yallist = require_yallist();
|
|
1112
|
+
var MAX = Symbol("max");
|
|
1113
|
+
var LENGTH = Symbol("length");
|
|
1114
|
+
var LENGTH_CALCULATOR = Symbol("lengthCalculator");
|
|
1115
|
+
var ALLOW_STALE = Symbol("allowStale");
|
|
1116
|
+
var MAX_AGE = Symbol("maxAge");
|
|
1117
|
+
var DISPOSE = Symbol("dispose");
|
|
1118
|
+
var NO_DISPOSE_ON_SET = Symbol("noDisposeOnSet");
|
|
1119
|
+
var LRU_LIST = Symbol("lruList");
|
|
1120
|
+
var CACHE = Symbol("cache");
|
|
1121
|
+
var UPDATE_AGE_ON_GET = Symbol("updateAgeOnGet");
|
|
1122
|
+
var naiveLength = () => 1;
|
|
1123
|
+
var LRUCache = class {
|
|
1124
|
+
constructor(options) {
|
|
1125
|
+
if (typeof options === "number")
|
|
1126
|
+
options = { max: options };
|
|
1127
|
+
if (!options)
|
|
1128
|
+
options = {};
|
|
1129
|
+
if (options.max && (typeof options.max !== "number" || options.max < 0))
|
|
1130
|
+
throw new TypeError("max must be a non-negative number");
|
|
1131
|
+
const max = this[MAX] = options.max || Infinity;
|
|
1132
|
+
const lc = options.length || naiveLength;
|
|
1133
|
+
this[LENGTH_CALCULATOR] = typeof lc !== "function" ? naiveLength : lc;
|
|
1134
|
+
this[ALLOW_STALE] = options.stale || false;
|
|
1135
|
+
if (options.maxAge && typeof options.maxAge !== "number")
|
|
1136
|
+
throw new TypeError("maxAge must be a number");
|
|
1137
|
+
this[MAX_AGE] = options.maxAge || 0;
|
|
1138
|
+
this[DISPOSE] = options.dispose;
|
|
1139
|
+
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
|
|
1140
|
+
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
|
|
1141
|
+
this.reset();
|
|
1142
|
+
}
|
|
1143
|
+
set max(mL) {
|
|
1144
|
+
if (typeof mL !== "number" || mL < 0)
|
|
1145
|
+
throw new TypeError("max must be a non-negative number");
|
|
1146
|
+
this[MAX] = mL || Infinity;
|
|
1147
|
+
trim(this);
|
|
1148
|
+
}
|
|
1149
|
+
get max() {
|
|
1150
|
+
return this[MAX];
|
|
1151
|
+
}
|
|
1152
|
+
set allowStale(allowStale) {
|
|
1153
|
+
this[ALLOW_STALE] = !!allowStale;
|
|
1154
|
+
}
|
|
1155
|
+
get allowStale() {
|
|
1156
|
+
return this[ALLOW_STALE];
|
|
1157
|
+
}
|
|
1158
|
+
set maxAge(mA) {
|
|
1159
|
+
if (typeof mA !== "number")
|
|
1160
|
+
throw new TypeError("maxAge must be a non-negative number");
|
|
1161
|
+
this[MAX_AGE] = mA;
|
|
1162
|
+
trim(this);
|
|
1163
|
+
}
|
|
1164
|
+
get maxAge() {
|
|
1165
|
+
return this[MAX_AGE];
|
|
1166
|
+
}
|
|
1167
|
+
set lengthCalculator(lC) {
|
|
1168
|
+
if (typeof lC !== "function")
|
|
1169
|
+
lC = naiveLength;
|
|
1170
|
+
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
1171
|
+
this[LENGTH_CALCULATOR] = lC;
|
|
1172
|
+
this[LENGTH] = 0;
|
|
1173
|
+
this[LRU_LIST].forEach((hit) => {
|
|
1174
|
+
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
|
|
1175
|
+
this[LENGTH] += hit.length;
|
|
1176
|
+
});
|
|
1075
1177
|
}
|
|
1178
|
+
trim(this);
|
|
1179
|
+
}
|
|
1180
|
+
get lengthCalculator() {
|
|
1181
|
+
return this[LENGTH_CALCULATOR];
|
|
1182
|
+
}
|
|
1183
|
+
get length() {
|
|
1184
|
+
return this[LENGTH];
|
|
1076
1185
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1186
|
+
get itemCount() {
|
|
1187
|
+
return this[LRU_LIST].length;
|
|
1188
|
+
}
|
|
1189
|
+
rforEach(fn, thisp) {
|
|
1190
|
+
thisp = thisp || this;
|
|
1191
|
+
for (let walker = this[LRU_LIST].tail; walker !== null; ) {
|
|
1192
|
+
const prev = walker.prev;
|
|
1193
|
+
forEachStep(this, fn, walker, thisp);
|
|
1194
|
+
walker = prev;
|
|
1080
1195
|
}
|
|
1081
1196
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1197
|
+
forEach(fn, thisp) {
|
|
1198
|
+
thisp = thisp || this;
|
|
1199
|
+
for (let walker = this[LRU_LIST].head; walker !== null; ) {
|
|
1200
|
+
const next = walker.next;
|
|
1201
|
+
forEachStep(this, fn, walker, thisp);
|
|
1202
|
+
walker = next;
|
|
1085
1203
|
}
|
|
1086
1204
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
return this.purgeStale;
|
|
1205
|
+
keys() {
|
|
1206
|
+
return this[LRU_LIST].toArray().map((k) => k.key);
|
|
1090
1207
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
for (const i of this.rindexes({ allowStale: true })) {
|
|
1094
|
-
if (this.isStale(i)) {
|
|
1095
|
-
this.delete(this.keyList[i]);
|
|
1096
|
-
deleted = true;
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
return deleted;
|
|
1208
|
+
values() {
|
|
1209
|
+
return this[LRU_LIST].toArray().map((k) => k.value);
|
|
1100
1210
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
const key = this.keyList[i];
|
|
1105
|
-
const value = this.valList[i];
|
|
1106
|
-
const entry = { value };
|
|
1107
|
-
if (this.ttls) {
|
|
1108
|
-
entry.ttl = this.ttls[i];
|
|
1109
|
-
}
|
|
1110
|
-
if (this.sizes) {
|
|
1111
|
-
entry.size = this.sizes[i];
|
|
1112
|
-
}
|
|
1113
|
-
arr.unshift([key, entry]);
|
|
1211
|
+
reset() {
|
|
1212
|
+
if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
|
|
1213
|
+
this[LRU_LIST].forEach((hit) => this[DISPOSE](hit.key, hit.value));
|
|
1114
1214
|
}
|
|
1115
|
-
|
|
1215
|
+
this[CACHE] = /* @__PURE__ */ new Map();
|
|
1216
|
+
this[LRU_LIST] = new Yallist();
|
|
1217
|
+
this[LENGTH] = 0;
|
|
1116
1218
|
}
|
|
1117
|
-
|
|
1118
|
-
this.
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
this.valList[index] = v;
|
|
1138
|
-
this.keyMap.set(k, index);
|
|
1139
|
-
this.next[this.tail] = index;
|
|
1140
|
-
this.prev[index] = this.tail;
|
|
1141
|
-
this.tail = index;
|
|
1142
|
-
this.size++;
|
|
1143
|
-
this.addItemSize(index, v, k, size);
|
|
1144
|
-
noUpdateTTL = false;
|
|
1145
|
-
} else {
|
|
1146
|
-
const oldVal = this.valList[index];
|
|
1147
|
-
if (v !== oldVal) {
|
|
1148
|
-
if (this.isBackgroundFetch(oldVal)) {
|
|
1149
|
-
oldVal.__abortController.abort();
|
|
1150
|
-
} else {
|
|
1151
|
-
if (!noDisposeOnSet) {
|
|
1152
|
-
this.dispose(oldVal, k, "set");
|
|
1153
|
-
if (this.disposeAfter) {
|
|
1154
|
-
this.disposed.push([oldVal, k, "set"]);
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
this.removeItemSize(index);
|
|
1159
|
-
this.valList[index] = v;
|
|
1160
|
-
this.addItemSize(index, v, k, size);
|
|
1219
|
+
dump() {
|
|
1220
|
+
return this[LRU_LIST].map((hit) => isStale(this, hit) ? false : {
|
|
1221
|
+
k: hit.key,
|
|
1222
|
+
v: hit.value,
|
|
1223
|
+
e: hit.now + (hit.maxAge || 0)
|
|
1224
|
+
}).toArray().filter((h) => h);
|
|
1225
|
+
}
|
|
1226
|
+
dumpLru() {
|
|
1227
|
+
return this[LRU_LIST];
|
|
1228
|
+
}
|
|
1229
|
+
set(key, value, maxAge) {
|
|
1230
|
+
maxAge = maxAge || this[MAX_AGE];
|
|
1231
|
+
if (maxAge && typeof maxAge !== "number")
|
|
1232
|
+
throw new TypeError("maxAge must be a number");
|
|
1233
|
+
const now = maxAge ? Date.now() : 0;
|
|
1234
|
+
const len = this[LENGTH_CALCULATOR](value, key);
|
|
1235
|
+
if (this[CACHE].has(key)) {
|
|
1236
|
+
if (len > this[MAX]) {
|
|
1237
|
+
del(this, this[CACHE].get(key));
|
|
1238
|
+
return false;
|
|
1161
1239
|
}
|
|
1162
|
-
this.
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1240
|
+
const node = this[CACHE].get(key);
|
|
1241
|
+
const item = node.value;
|
|
1242
|
+
if (this[DISPOSE]) {
|
|
1243
|
+
if (!this[NO_DISPOSE_ON_SET])
|
|
1244
|
+
this[DISPOSE](key, item.value);
|
|
1245
|
+
}
|
|
1246
|
+
item.now = now;
|
|
1247
|
+
item.maxAge = maxAge;
|
|
1248
|
+
item.value = value;
|
|
1249
|
+
this[LENGTH] += len - item.length;
|
|
1250
|
+
item.length = len;
|
|
1251
|
+
this.get(key);
|
|
1252
|
+
trim(this);
|
|
1253
|
+
return true;
|
|
1169
1254
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1255
|
+
const hit = new Entry(key, value, len, now, maxAge);
|
|
1256
|
+
if (hit.length > this[MAX]) {
|
|
1257
|
+
if (this[DISPOSE])
|
|
1258
|
+
this[DISPOSE](key, value);
|
|
1259
|
+
return false;
|
|
1174
1260
|
}
|
|
1175
|
-
|
|
1261
|
+
this[LENGTH] += hit.length;
|
|
1262
|
+
this[LRU_LIST].unshift(hit);
|
|
1263
|
+
this[CACHE].set(key, this[LRU_LIST].head);
|
|
1264
|
+
trim(this);
|
|
1265
|
+
return true;
|
|
1176
1266
|
}
|
|
1177
|
-
|
|
1178
|
-
if (this.
|
|
1179
|
-
return
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
return this
|
|
1267
|
+
has(key) {
|
|
1268
|
+
if (!this[CACHE].has(key))
|
|
1269
|
+
return false;
|
|
1270
|
+
const hit = this[CACHE].get(key).value;
|
|
1271
|
+
return !isStale(this, hit);
|
|
1272
|
+
}
|
|
1273
|
+
get(key) {
|
|
1274
|
+
return get(this, key, true);
|
|
1275
|
+
}
|
|
1276
|
+
peek(key) {
|
|
1277
|
+
return get(this, key, false);
|
|
1188
1278
|
}
|
|
1189
1279
|
pop() {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
}
|
|
1196
|
-
evict() {
|
|
1197
|
-
const head = this.head;
|
|
1198
|
-
const k = this.keyList[head];
|
|
1199
|
-
const v = this.valList[head];
|
|
1200
|
-
if (this.isBackgroundFetch(v)) {
|
|
1201
|
-
v.__abortController.abort();
|
|
1202
|
-
} else {
|
|
1203
|
-
this.dispose(v, k, "evict");
|
|
1204
|
-
if (this.disposeAfter) {
|
|
1205
|
-
this.disposed.push([v, k, "evict"]);
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
this.removeItemSize(head);
|
|
1209
|
-
this.head = this.next[head];
|
|
1210
|
-
this.keyMap.delete(k);
|
|
1211
|
-
this.size--;
|
|
1212
|
-
return head;
|
|
1213
|
-
}
|
|
1214
|
-
has(k, { updateAgeOnHas = this.updateAgeOnHas } = {}) {
|
|
1215
|
-
const index = this.keyMap.get(k);
|
|
1216
|
-
if (index !== void 0) {
|
|
1217
|
-
if (!this.isStale(index)) {
|
|
1218
|
-
if (updateAgeOnHas) {
|
|
1219
|
-
this.updateItemAge(index);
|
|
1220
|
-
}
|
|
1221
|
-
return true;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
return false;
|
|
1280
|
+
const node = this[LRU_LIST].tail;
|
|
1281
|
+
if (!node)
|
|
1282
|
+
return null;
|
|
1283
|
+
del(this, node);
|
|
1284
|
+
return node.value;
|
|
1225
1285
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
};
|
|
1242
|
-
const p = Promise.resolve(this.fetchMethod(k, v, fetchOpts)).then((v2) => {
|
|
1243
|
-
if (!ac.signal.aborted) {
|
|
1244
|
-
this.set(k, v2, fetchOpts.options);
|
|
1245
|
-
}
|
|
1246
|
-
return v2;
|
|
1247
|
-
});
|
|
1248
|
-
p.__abortController = ac;
|
|
1249
|
-
p.__staleWhileFetching = v;
|
|
1250
|
-
if (index === void 0) {
|
|
1251
|
-
this.set(k, p, fetchOpts.options);
|
|
1252
|
-
index = this.keyMap.get(k);
|
|
1253
|
-
} else {
|
|
1254
|
-
this.valList[index] = p;
|
|
1255
|
-
}
|
|
1256
|
-
return p;
|
|
1257
|
-
}
|
|
1258
|
-
isBackgroundFetch(p) {
|
|
1259
|
-
return p && typeof p === "object" && typeof p.then === "function" && Object.prototype.hasOwnProperty.call(p, "__staleWhileFetching");
|
|
1260
|
-
}
|
|
1261
|
-
async fetch(k, {
|
|
1262
|
-
allowStale = this.allowStale,
|
|
1263
|
-
updateAgeOnGet = this.updateAgeOnGet,
|
|
1264
|
-
ttl = this.ttl,
|
|
1265
|
-
noDisposeOnSet = this.noDisposeOnSet,
|
|
1266
|
-
size = 0,
|
|
1267
|
-
sizeCalculation = this.sizeCalculation,
|
|
1268
|
-
noUpdateTTL = this.noUpdateTTL
|
|
1269
|
-
} = {}) {
|
|
1270
|
-
if (!this.fetchMethod) {
|
|
1271
|
-
return this.get(k, { allowStale, updateAgeOnGet });
|
|
1272
|
-
}
|
|
1273
|
-
const options = {
|
|
1274
|
-
allowStale,
|
|
1275
|
-
updateAgeOnGet,
|
|
1276
|
-
ttl,
|
|
1277
|
-
noDisposeOnSet,
|
|
1278
|
-
size,
|
|
1279
|
-
sizeCalculation,
|
|
1280
|
-
noUpdateTTL
|
|
1281
|
-
};
|
|
1282
|
-
let index = this.keyMap.get(k);
|
|
1283
|
-
if (index === void 0) {
|
|
1284
|
-
return this.backgroundFetch(k, index, options);
|
|
1285
|
-
} else {
|
|
1286
|
-
const v = this.valList[index];
|
|
1287
|
-
if (this.isBackgroundFetch(v)) {
|
|
1288
|
-
return allowStale && v.__staleWhileFetching !== void 0 ? v.__staleWhileFetching : v;
|
|
1289
|
-
}
|
|
1290
|
-
if (!this.isStale(index)) {
|
|
1291
|
-
this.moveToTail(index);
|
|
1292
|
-
if (updateAgeOnGet) {
|
|
1293
|
-
this.updateItemAge(index);
|
|
1294
|
-
}
|
|
1295
|
-
return v;
|
|
1296
|
-
}
|
|
1297
|
-
const p = this.backgroundFetch(k, index, options);
|
|
1298
|
-
return allowStale && p.__staleWhileFetching !== void 0 ? p.__staleWhileFetching : p;
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
get(k, {
|
|
1302
|
-
allowStale = this.allowStale,
|
|
1303
|
-
updateAgeOnGet = this.updateAgeOnGet
|
|
1304
|
-
} = {}) {
|
|
1305
|
-
const index = this.keyMap.get(k);
|
|
1306
|
-
if (index !== void 0) {
|
|
1307
|
-
const value = this.valList[index];
|
|
1308
|
-
const fetching = this.isBackgroundFetch(value);
|
|
1309
|
-
if (this.isStale(index)) {
|
|
1310
|
-
if (!fetching) {
|
|
1311
|
-
this.delete(k);
|
|
1312
|
-
return allowStale ? value : void 0;
|
|
1313
|
-
} else {
|
|
1314
|
-
return allowStale ? value.__staleWhileFetching : void 0;
|
|
1315
|
-
}
|
|
1316
|
-
} else {
|
|
1317
|
-
if (fetching) {
|
|
1318
|
-
return void 0;
|
|
1319
|
-
}
|
|
1320
|
-
this.moveToTail(index);
|
|
1321
|
-
if (updateAgeOnGet) {
|
|
1322
|
-
this.updateItemAge(index);
|
|
1286
|
+
del(key) {
|
|
1287
|
+
del(this, this[CACHE].get(key));
|
|
1288
|
+
}
|
|
1289
|
+
load(arr) {
|
|
1290
|
+
this.reset();
|
|
1291
|
+
const now = Date.now();
|
|
1292
|
+
for (let l = arr.length - 1; l >= 0; l--) {
|
|
1293
|
+
const hit = arr[l];
|
|
1294
|
+
const expiresAt = hit.e || 0;
|
|
1295
|
+
if (expiresAt === 0)
|
|
1296
|
+
this.set(hit.k, hit.v);
|
|
1297
|
+
else {
|
|
1298
|
+
const maxAge = expiresAt - now;
|
|
1299
|
+
if (maxAge > 0) {
|
|
1300
|
+
this.set(hit.k, hit.v, maxAge);
|
|
1323
1301
|
}
|
|
1324
|
-
return value;
|
|
1325
1302
|
}
|
|
1326
1303
|
}
|
|
1327
1304
|
}
|
|
1328
|
-
|
|
1329
|
-
this
|
|
1330
|
-
this.next[p] = n;
|
|
1305
|
+
prune() {
|
|
1306
|
+
this[CACHE].forEach((value, key) => get(this, key, false));
|
|
1331
1307
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
}
|
|
1347
|
-
delete(k) {
|
|
1348
|
-
let deleted = false;
|
|
1349
|
-
if (this.size !== 0) {
|
|
1350
|
-
const index = this.keyMap.get(k);
|
|
1351
|
-
if (index !== void 0) {
|
|
1352
|
-
deleted = true;
|
|
1353
|
-
if (this.size === 1) {
|
|
1354
|
-
this.clear();
|
|
1355
|
-
} else {
|
|
1356
|
-
this.removeItemSize(index);
|
|
1357
|
-
const v = this.valList[index];
|
|
1358
|
-
if (this.isBackgroundFetch(v)) {
|
|
1359
|
-
v.__abortController.abort();
|
|
1360
|
-
} else {
|
|
1361
|
-
this.dispose(v, k, "delete");
|
|
1362
|
-
if (this.disposeAfter) {
|
|
1363
|
-
this.disposed.push([v, k, "delete"]);
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
this.keyMap.delete(k);
|
|
1367
|
-
this.keyList[index] = null;
|
|
1368
|
-
this.valList[index] = null;
|
|
1369
|
-
if (index === this.tail) {
|
|
1370
|
-
this.tail = this.prev[index];
|
|
1371
|
-
} else if (index === this.head) {
|
|
1372
|
-
this.head = this.next[index];
|
|
1373
|
-
} else {
|
|
1374
|
-
this.next[this.prev[index]] = this.next[index];
|
|
1375
|
-
this.prev[this.next[index]] = this.prev[index];
|
|
1376
|
-
}
|
|
1377
|
-
this.size--;
|
|
1378
|
-
this.free.push(index);
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
if (this.disposed) {
|
|
1383
|
-
while (this.disposed.length) {
|
|
1384
|
-
this.disposeAfter(...this.disposed.shift());
|
|
1308
|
+
};
|
|
1309
|
+
var get = (self, key, doUse) => {
|
|
1310
|
+
const node = self[CACHE].get(key);
|
|
1311
|
+
if (node) {
|
|
1312
|
+
const hit = node.value;
|
|
1313
|
+
if (isStale(self, hit)) {
|
|
1314
|
+
del(self, node);
|
|
1315
|
+
if (!self[ALLOW_STALE])
|
|
1316
|
+
return void 0;
|
|
1317
|
+
} else {
|
|
1318
|
+
if (doUse) {
|
|
1319
|
+
if (self[UPDATE_AGE_ON_GET])
|
|
1320
|
+
node.value.now = Date.now();
|
|
1321
|
+
self[LRU_LIST].unshiftNode(node);
|
|
1385
1322
|
}
|
|
1386
1323
|
}
|
|
1387
|
-
return
|
|
1324
|
+
return hit.value;
|
|
1388
1325
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
this.keyMap.clear();
|
|
1403
|
-
this.valList.fill(null);
|
|
1404
|
-
this.keyList.fill(null);
|
|
1405
|
-
if (this.ttls) {
|
|
1406
|
-
this.ttls.fill(0);
|
|
1407
|
-
this.starts.fill(0);
|
|
1408
|
-
}
|
|
1409
|
-
if (this.sizes) {
|
|
1410
|
-
this.sizes.fill(0);
|
|
1411
|
-
}
|
|
1412
|
-
this.head = 0;
|
|
1413
|
-
this.tail = 0;
|
|
1414
|
-
this.initialFill = 1;
|
|
1415
|
-
this.free.length = 0;
|
|
1416
|
-
this.calculatedSize = 0;
|
|
1417
|
-
this.size = 0;
|
|
1418
|
-
if (this.disposed) {
|
|
1419
|
-
while (this.disposed.length) {
|
|
1420
|
-
this.disposeAfter(...this.disposed.shift());
|
|
1421
|
-
}
|
|
1326
|
+
};
|
|
1327
|
+
var isStale = (self, hit) => {
|
|
1328
|
+
if (!hit || !hit.maxAge && !self[MAX_AGE])
|
|
1329
|
+
return false;
|
|
1330
|
+
const diff = Date.now() - hit.now;
|
|
1331
|
+
return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && diff > self[MAX_AGE];
|
|
1332
|
+
};
|
|
1333
|
+
var trim = (self) => {
|
|
1334
|
+
if (self[LENGTH] > self[MAX]) {
|
|
1335
|
+
for (let walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null; ) {
|
|
1336
|
+
const prev = walker.prev;
|
|
1337
|
+
del(self, walker);
|
|
1338
|
+
walker = prev;
|
|
1422
1339
|
}
|
|
1423
1340
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1341
|
+
};
|
|
1342
|
+
var del = (self, node) => {
|
|
1343
|
+
if (node) {
|
|
1344
|
+
const hit = node.value;
|
|
1345
|
+
if (self[DISPOSE])
|
|
1346
|
+
self[DISPOSE](hit.key, hit.value);
|
|
1347
|
+
self[LENGTH] -= hit.length;
|
|
1348
|
+
self[CACHE].delete(hit.key);
|
|
1349
|
+
self[LRU_LIST].removeNode(node);
|
|
1427
1350
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1351
|
+
};
|
|
1352
|
+
var Entry = class {
|
|
1353
|
+
constructor(key, value, length, now, maxAge) {
|
|
1354
|
+
this.key = key;
|
|
1355
|
+
this.value = value;
|
|
1356
|
+
this.length = length;
|
|
1357
|
+
this.now = now;
|
|
1358
|
+
this.maxAge = maxAge || 0;
|
|
1431
1359
|
}
|
|
1432
1360
|
};
|
|
1361
|
+
var forEachStep = (self, fn, node, thisp) => {
|
|
1362
|
+
let hit = node.value;
|
|
1363
|
+
if (isStale(self, hit)) {
|
|
1364
|
+
del(self, node);
|
|
1365
|
+
if (!self[ALLOW_STALE])
|
|
1366
|
+
hit = void 0;
|
|
1367
|
+
}
|
|
1368
|
+
if (hit)
|
|
1369
|
+
fn.call(thisp, hit.value, hit.key, self);
|
|
1370
|
+
};
|
|
1433
1371
|
module2.exports = LRUCache;
|
|
1434
1372
|
}
|
|
1435
1373
|
});
|