@m2c2kit/build-helpers 0.3.14 → 0.3.15
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 +136 -863
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -6557,21 +6557,29 @@ class MagicString {
|
|
|
6557
6557
|
if (searchValue.global) {
|
|
6558
6558
|
const matches = matchAll(searchValue, this.original);
|
|
6559
6559
|
matches.forEach((match) => {
|
|
6560
|
-
if (match.index != null)
|
|
6560
|
+
if (match.index != null) {
|
|
6561
|
+
const replacement = getReplacement(match, this.original);
|
|
6562
|
+
if (replacement !== match[0]) {
|
|
6563
|
+
this.overwrite(
|
|
6564
|
+
match.index,
|
|
6565
|
+
match.index + match[0].length,
|
|
6566
|
+
replacement
|
|
6567
|
+
);
|
|
6568
|
+
}
|
|
6569
|
+
}
|
|
6570
|
+
});
|
|
6571
|
+
} else {
|
|
6572
|
+
const match = this.original.match(searchValue);
|
|
6573
|
+
if (match && match.index != null) {
|
|
6574
|
+
const replacement = getReplacement(match, this.original);
|
|
6575
|
+
if (replacement !== match[0]) {
|
|
6561
6576
|
this.overwrite(
|
|
6562
6577
|
match.index,
|
|
6563
6578
|
match.index + match[0].length,
|
|
6564
|
-
|
|
6579
|
+
replacement
|
|
6565
6580
|
);
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
const match = this.original.match(searchValue);
|
|
6569
|
-
if (match && match.index != null)
|
|
6570
|
-
this.overwrite(
|
|
6571
|
-
match.index,
|
|
6572
|
-
match.index + match[0].length,
|
|
6573
|
-
getReplacement(match, this.original),
|
|
6574
|
-
);
|
|
6581
|
+
}
|
|
6582
|
+
}
|
|
6575
6583
|
}
|
|
6576
6584
|
return this;
|
|
6577
6585
|
}
|
|
@@ -6603,7 +6611,9 @@ class MagicString {
|
|
|
6603
6611
|
index !== -1;
|
|
6604
6612
|
index = original.indexOf(string, index + stringLength)
|
|
6605
6613
|
) {
|
|
6606
|
-
|
|
6614
|
+
const previous = original.slice(index, index + stringLength);
|
|
6615
|
+
if (previous !== replacement)
|
|
6616
|
+
this.overwrite(index, index + stringLength, replacement);
|
|
6607
6617
|
}
|
|
6608
6618
|
|
|
6609
6619
|
return this;
|
|
@@ -7039,7 +7049,7 @@ var concatty = function concatty(a, b) {
|
|
|
7039
7049
|
|
|
7040
7050
|
var slicy = function slicy(arrLike, offset) {
|
|
7041
7051
|
var arr = [];
|
|
7042
|
-
for (var i = offset
|
|
7052
|
+
for (var i = offset , j = 0; i < arrLike.length; i += 1, j += 1) {
|
|
7043
7053
|
arr[j] = arrLike[i];
|
|
7044
7054
|
}
|
|
7045
7055
|
return arr;
|
|
@@ -8897,17 +8907,8 @@ function pTimeout(promise, milliseconds, fallback, options) {
|
|
|
8897
8907
|
}
|
|
8898
8908
|
|
|
8899
8909
|
timer = options.customTimers.setTimeout.call(undefined, () => {
|
|
8900
|
-
if (typeof fallback === 'function') {
|
|
8901
|
-
try {
|
|
8902
|
-
resolve(fallback());
|
|
8903
|
-
} catch (error) {
|
|
8904
|
-
reject(error);
|
|
8905
|
-
}
|
|
8906
8910
|
|
|
8907
|
-
|
|
8908
|
-
}
|
|
8909
|
-
|
|
8910
|
-
const message = typeof fallback === 'string' ? fallback : `Promise timed out after ${milliseconds} milliseconds`;
|
|
8911
|
+
const message = `Promise timed out after ${milliseconds} milliseconds`;
|
|
8911
8912
|
const timeoutError = fallback instanceof Error ? fallback : new TimeoutError(message);
|
|
8912
8913
|
|
|
8913
8914
|
if (typeof promise.cancel === 'function') {
|
|
@@ -11045,7 +11046,7 @@ var utils$j = {};
|
|
|
11045
11046
|
*/
|
|
11046
11047
|
|
|
11047
11048
|
exports.escapeNode = (block, n = 0, type) => {
|
|
11048
|
-
|
|
11049
|
+
const node = block.nodes[n];
|
|
11049
11050
|
if (!node) return;
|
|
11050
11051
|
|
|
11051
11052
|
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
|
@@ -11114,13 +11115,23 @@ var utils$j = {};
|
|
|
11114
11115
|
|
|
11115
11116
|
exports.flatten = (...args) => {
|
|
11116
11117
|
const result = [];
|
|
11118
|
+
|
|
11117
11119
|
const flat = arr => {
|
|
11118
11120
|
for (let i = 0; i < arr.length; i++) {
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
+
const ele = arr[i];
|
|
11122
|
+
|
|
11123
|
+
if (Array.isArray(ele)) {
|
|
11124
|
+
flat(ele);
|
|
11125
|
+
continue;
|
|
11126
|
+
}
|
|
11127
|
+
|
|
11128
|
+
if (ele !== undefined) {
|
|
11129
|
+
result.push(ele);
|
|
11130
|
+
}
|
|
11121
11131
|
}
|
|
11122
11132
|
return result;
|
|
11123
11133
|
};
|
|
11134
|
+
|
|
11124
11135
|
flat(args);
|
|
11125
11136
|
return result;
|
|
11126
11137
|
};
|
|
@@ -11129,9 +11140,9 @@ var utils$j = {};
|
|
|
11129
11140
|
const utils$i = utils$j;
|
|
11130
11141
|
|
|
11131
11142
|
var stringify$4 = (ast, options = {}) => {
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11143
|
+
const stringify = (node, parent = {}) => {
|
|
11144
|
+
const invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
|
|
11145
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
11135
11146
|
let output = '';
|
|
11136
11147
|
|
|
11137
11148
|
if (node.value) {
|
|
@@ -11146,7 +11157,7 @@ var stringify$4 = (ast, options = {}) => {
|
|
|
11146
11157
|
}
|
|
11147
11158
|
|
|
11148
11159
|
if (node.nodes) {
|
|
11149
|
-
for (
|
|
11160
|
+
for (const child of node.nodes) {
|
|
11150
11161
|
output += stringify(child);
|
|
11151
11162
|
}
|
|
11152
11163
|
}
|
|
@@ -11520,7 +11531,7 @@ const toMaxLen = (input, maxLength) => {
|
|
|
11520
11531
|
return negative ? ('-' + input) : input;
|
|
11521
11532
|
};
|
|
11522
11533
|
|
|
11523
|
-
const toSequence = (parts, options) => {
|
|
11534
|
+
const toSequence = (parts, options, maxLen) => {
|
|
11524
11535
|
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
11525
11536
|
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
11526
11537
|
|
|
@@ -11530,11 +11541,11 @@ const toSequence = (parts, options) => {
|
|
|
11530
11541
|
let result;
|
|
11531
11542
|
|
|
11532
11543
|
if (parts.positives.length) {
|
|
11533
|
-
positives = parts.positives.join('|');
|
|
11544
|
+
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
|
|
11534
11545
|
}
|
|
11535
11546
|
|
|
11536
11547
|
if (parts.negatives.length) {
|
|
11537
|
-
negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
|
11548
|
+
negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
|
|
11538
11549
|
}
|
|
11539
11550
|
|
|
11540
11551
|
if (positives && negatives) {
|
|
@@ -11632,7 +11643,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
|
|
|
11632
11643
|
|
|
11633
11644
|
if (options.toRegex === true) {
|
|
11634
11645
|
return step > 1
|
|
11635
|
-
? toSequence(parts, options)
|
|
11646
|
+
? toSequence(parts, options, maxLen)
|
|
11636
11647
|
: toRegex(range, null, { wrap: false, ...options });
|
|
11637
11648
|
}
|
|
11638
11649
|
|
|
@@ -11644,7 +11655,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
|
|
|
11644
11655
|
return invalidRange(start, end, options);
|
|
11645
11656
|
}
|
|
11646
11657
|
|
|
11647
|
-
|
|
11648
11658
|
let format = options.transform || (val => String.fromCharCode(val));
|
|
11649
11659
|
let a = `${start}`.charCodeAt(0);
|
|
11650
11660
|
let b = `${end}`.charCodeAt(0);
|
|
@@ -11712,30 +11722,32 @@ const fill$1 = fillRange;
|
|
|
11712
11722
|
const utils$h = utils$j;
|
|
11713
11723
|
|
|
11714
11724
|
const compile$1 = (ast, options = {}) => {
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11725
|
+
const walk = (node, parent = {}) => {
|
|
11726
|
+
const invalidBlock = utils$h.isInvalidBrace(parent);
|
|
11727
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
11728
|
+
const invalid = invalidBlock === true || invalidNode === true;
|
|
11729
|
+
const prefix = options.escapeInvalid === true ? '\\' : '';
|
|
11720
11730
|
let output = '';
|
|
11721
11731
|
|
|
11722
11732
|
if (node.isOpen === true) {
|
|
11723
11733
|
return prefix + node.value;
|
|
11724
11734
|
}
|
|
11735
|
+
|
|
11725
11736
|
if (node.isClose === true) {
|
|
11737
|
+
console.log('node.isClose', prefix, node.value);
|
|
11726
11738
|
return prefix + node.value;
|
|
11727
11739
|
}
|
|
11728
11740
|
|
|
11729
11741
|
if (node.type === 'open') {
|
|
11730
|
-
return invalid ?
|
|
11742
|
+
return invalid ? prefix + node.value : '(';
|
|
11731
11743
|
}
|
|
11732
11744
|
|
|
11733
11745
|
if (node.type === 'close') {
|
|
11734
|
-
return invalid ?
|
|
11746
|
+
return invalid ? prefix + node.value : ')';
|
|
11735
11747
|
}
|
|
11736
11748
|
|
|
11737
11749
|
if (node.type === 'comma') {
|
|
11738
|
-
return node.prev.type === 'comma' ? '' :
|
|
11750
|
+
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
|
|
11739
11751
|
}
|
|
11740
11752
|
|
|
11741
11753
|
if (node.value) {
|
|
@@ -11743,8 +11755,8 @@ const compile$1 = (ast, options = {}) => {
|
|
|
11743
11755
|
}
|
|
11744
11756
|
|
|
11745
11757
|
if (node.nodes && node.ranges > 0) {
|
|
11746
|
-
|
|
11747
|
-
|
|
11758
|
+
const args = utils$h.reduce(node.nodes);
|
|
11759
|
+
const range = fill$1(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
|
|
11748
11760
|
|
|
11749
11761
|
if (range.length !== 0) {
|
|
11750
11762
|
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
|
@@ -11752,10 +11764,11 @@ const compile$1 = (ast, options = {}) => {
|
|
|
11752
11764
|
}
|
|
11753
11765
|
|
|
11754
11766
|
if (node.nodes) {
|
|
11755
|
-
for (
|
|
11767
|
+
for (const child of node.nodes) {
|
|
11756
11768
|
output += walk(child, node);
|
|
11757
11769
|
}
|
|
11758
11770
|
}
|
|
11771
|
+
|
|
11759
11772
|
return output;
|
|
11760
11773
|
};
|
|
11761
11774
|
|
|
@@ -11769,7 +11782,7 @@ const stringify$2 = stringify$4;
|
|
|
11769
11782
|
const utils$g = utils$j;
|
|
11770
11783
|
|
|
11771
11784
|
const append = (queue = '', stash = '', enclose = false) => {
|
|
11772
|
-
|
|
11785
|
+
const result = [];
|
|
11773
11786
|
|
|
11774
11787
|
queue = [].concat(queue);
|
|
11775
11788
|
stash = [].concat(stash);
|
|
@@ -11779,15 +11792,15 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
11779
11792
|
return enclose ? utils$g.flatten(stash).map(ele => `{${ele}}`) : stash;
|
|
11780
11793
|
}
|
|
11781
11794
|
|
|
11782
|
-
for (
|
|
11795
|
+
for (const item of queue) {
|
|
11783
11796
|
if (Array.isArray(item)) {
|
|
11784
|
-
for (
|
|
11797
|
+
for (const value of item) {
|
|
11785
11798
|
result.push(append(value, stash, enclose));
|
|
11786
11799
|
}
|
|
11787
11800
|
} else {
|
|
11788
11801
|
for (let ele of stash) {
|
|
11789
11802
|
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
|
11790
|
-
result.push(Array.isArray(ele) ? append(item, ele, enclose) :
|
|
11803
|
+
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
|
11791
11804
|
}
|
|
11792
11805
|
}
|
|
11793
11806
|
}
|
|
@@ -11795,9 +11808,9 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
11795
11808
|
};
|
|
11796
11809
|
|
|
11797
11810
|
const expand$1 = (ast, options = {}) => {
|
|
11798
|
-
|
|
11811
|
+
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
|
|
11799
11812
|
|
|
11800
|
-
|
|
11813
|
+
const walk = (node, parent = {}) => {
|
|
11801
11814
|
node.queue = [];
|
|
11802
11815
|
|
|
11803
11816
|
let p = parent;
|
|
@@ -11819,7 +11832,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
11819
11832
|
}
|
|
11820
11833
|
|
|
11821
11834
|
if (node.nodes && node.ranges > 0) {
|
|
11822
|
-
|
|
11835
|
+
const args = utils$g.reduce(node.nodes);
|
|
11823
11836
|
|
|
11824
11837
|
if (utils$g.exceedsLimit(...args, options.step, rangeLimit)) {
|
|
11825
11838
|
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
|
@@ -11835,7 +11848,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
11835
11848
|
return;
|
|
11836
11849
|
}
|
|
11837
11850
|
|
|
11838
|
-
|
|
11851
|
+
const enclose = utils$g.encloseBrace(node);
|
|
11839
11852
|
let queue = node.queue;
|
|
11840
11853
|
let block = node;
|
|
11841
11854
|
|
|
@@ -11845,7 +11858,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
11845
11858
|
}
|
|
11846
11859
|
|
|
11847
11860
|
for (let i = 0; i < node.nodes.length; i++) {
|
|
11848
|
-
|
|
11861
|
+
const child = node.nodes[i];
|
|
11849
11862
|
|
|
11850
11863
|
if (child.type === 'comma' && node.type === 'brace') {
|
|
11851
11864
|
if (i === 1) queue.push('');
|
|
@@ -11877,7 +11890,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
11877
11890
|
var expand_1 = expand$1;
|
|
11878
11891
|
|
|
11879
11892
|
var constants$6 = {
|
|
11880
|
-
MAX_LENGTH:
|
|
11893
|
+
MAX_LENGTH: 10000,
|
|
11881
11894
|
|
|
11882
11895
|
// Digits
|
|
11883
11896
|
CHAR_0: '0', /* 0 */
|
|
@@ -11965,18 +11978,18 @@ const parse$a = (input, options = {}) => {
|
|
|
11965
11978
|
throw new TypeError('Expected a string');
|
|
11966
11979
|
}
|
|
11967
11980
|
|
|
11968
|
-
|
|
11969
|
-
|
|
11981
|
+
const opts = options || {};
|
|
11982
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$3, opts.maxLength) : MAX_LENGTH$3;
|
|
11970
11983
|
if (input.length > max) {
|
|
11971
11984
|
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
|
11972
11985
|
}
|
|
11973
11986
|
|
|
11974
|
-
|
|
11975
|
-
|
|
11987
|
+
const ast = { type: 'root', input, nodes: [] };
|
|
11988
|
+
const stack = [ast];
|
|
11976
11989
|
let block = ast;
|
|
11977
11990
|
let prev = ast;
|
|
11978
11991
|
let brackets = 0;
|
|
11979
|
-
|
|
11992
|
+
const length = input.length;
|
|
11980
11993
|
let index = 0;
|
|
11981
11994
|
let depth = 0;
|
|
11982
11995
|
let value;
|
|
@@ -12041,6 +12054,7 @@ const parse$a = (input, options = {}) => {
|
|
|
12041
12054
|
|
|
12042
12055
|
if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
|
|
12043
12056
|
brackets++;
|
|
12057
|
+
|
|
12044
12058
|
let next;
|
|
12045
12059
|
|
|
12046
12060
|
while (index < length && (next = advance())) {
|
|
@@ -12096,7 +12110,7 @@ const parse$a = (input, options = {}) => {
|
|
|
12096
12110
|
*/
|
|
12097
12111
|
|
|
12098
12112
|
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
|
12099
|
-
|
|
12113
|
+
const open = value;
|
|
12100
12114
|
let next;
|
|
12101
12115
|
|
|
12102
12116
|
if (options.keepQuotes !== true) {
|
|
@@ -12128,8 +12142,8 @@ const parse$a = (input, options = {}) => {
|
|
|
12128
12142
|
if (value === CHAR_LEFT_CURLY_BRACE$1) {
|
|
12129
12143
|
depth++;
|
|
12130
12144
|
|
|
12131
|
-
|
|
12132
|
-
|
|
12145
|
+
const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
|
12146
|
+
const brace = {
|
|
12133
12147
|
type: 'brace',
|
|
12134
12148
|
open: true,
|
|
12135
12149
|
close: false,
|
|
@@ -12156,7 +12170,7 @@ const parse$a = (input, options = {}) => {
|
|
|
12156
12170
|
continue;
|
|
12157
12171
|
}
|
|
12158
12172
|
|
|
12159
|
-
|
|
12173
|
+
const type = 'close';
|
|
12160
12174
|
block = stack.pop();
|
|
12161
12175
|
block.close = true;
|
|
12162
12176
|
|
|
@@ -12174,7 +12188,7 @@ const parse$a = (input, options = {}) => {
|
|
|
12174
12188
|
if (value === CHAR_COMMA$1 && depth > 0) {
|
|
12175
12189
|
if (block.ranges > 0) {
|
|
12176
12190
|
block.ranges = 0;
|
|
12177
|
-
|
|
12191
|
+
const open = block.nodes.shift();
|
|
12178
12192
|
block.nodes = [open, { type: 'text', value: stringify$1(block) }];
|
|
12179
12193
|
}
|
|
12180
12194
|
|
|
@@ -12188,7 +12202,7 @@ const parse$a = (input, options = {}) => {
|
|
|
12188
12202
|
*/
|
|
12189
12203
|
|
|
12190
12204
|
if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
|
|
12191
|
-
|
|
12205
|
+
const siblings = block.nodes;
|
|
12192
12206
|
|
|
12193
12207
|
if (depth === 0 || siblings.length === 0) {
|
|
12194
12208
|
push({ type: 'text', value });
|
|
@@ -12215,7 +12229,7 @@ const parse$a = (input, options = {}) => {
|
|
|
12215
12229
|
if (prev.type === 'range') {
|
|
12216
12230
|
siblings.pop();
|
|
12217
12231
|
|
|
12218
|
-
|
|
12232
|
+
const before = siblings[siblings.length - 1];
|
|
12219
12233
|
before.value += prev.value + value;
|
|
12220
12234
|
prev = before;
|
|
12221
12235
|
block.ranges--;
|
|
@@ -12248,8 +12262,8 @@ const parse$a = (input, options = {}) => {
|
|
|
12248
12262
|
});
|
|
12249
12263
|
|
|
12250
12264
|
// get the location of the block on parent.nodes (block's siblings)
|
|
12251
|
-
|
|
12252
|
-
|
|
12265
|
+
const parent = stack[stack.length - 1];
|
|
12266
|
+
const index = parent.nodes.indexOf(block);
|
|
12253
12267
|
// replace the (invalid) block with it's nodes
|
|
12254
12268
|
parent.nodes.splice(index, 1, ...block.nodes);
|
|
12255
12269
|
}
|
|
@@ -12284,8 +12298,8 @@ const braces$1 = (input, options = {}) => {
|
|
|
12284
12298
|
let output = [];
|
|
12285
12299
|
|
|
12286
12300
|
if (Array.isArray(input)) {
|
|
12287
|
-
for (
|
|
12288
|
-
|
|
12301
|
+
for (const pattern of input) {
|
|
12302
|
+
const result = braces$1.create(pattern, options);
|
|
12289
12303
|
if (Array.isArray(result)) {
|
|
12290
12304
|
output.push(...result);
|
|
12291
12305
|
} else {
|
|
@@ -12419,7 +12433,7 @@ braces$1.create = (input, options = {}) => {
|
|
|
12419
12433
|
return [input];
|
|
12420
12434
|
}
|
|
12421
12435
|
|
|
12422
|
-
|
|
12436
|
+
return options.expand !== true
|
|
12423
12437
|
? braces$1.compile(input, options)
|
|
12424
12438
|
: braces$1.expand(input, options);
|
|
12425
12439
|
};
|
|
@@ -17410,6 +17424,14 @@ const cleanRangeBackSlash = slashes => {
|
|
|
17410
17424
|
// '`foo/`' should not continue with the '`..`'
|
|
17411
17425
|
const REPLACERS = [
|
|
17412
17426
|
|
|
17427
|
+
[
|
|
17428
|
+
// remove BOM
|
|
17429
|
+
// TODO:
|
|
17430
|
+
// Other similar zero-width characters?
|
|
17431
|
+
/^\uFEFF/,
|
|
17432
|
+
() => EMPTY
|
|
17433
|
+
],
|
|
17434
|
+
|
|
17413
17435
|
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
17414
17436
|
[
|
|
17415
17437
|
// (a\ ) -> (a )
|
|
@@ -19312,7 +19334,7 @@ let SemVer$d = class SemVer {
|
|
|
19312
19334
|
do {
|
|
19313
19335
|
const a = this.build[i];
|
|
19314
19336
|
const b = other.build[i];
|
|
19315
|
-
debug('
|
|
19337
|
+
debug('build compare', i, a, b);
|
|
19316
19338
|
if (a === undefined && b === undefined) {
|
|
19317
19339
|
return 0
|
|
19318
19340
|
} else if (b === undefined) {
|
|
@@ -19759,798 +19781,47 @@ const coerce$1 = (version, options) => {
|
|
|
19759
19781
|
};
|
|
19760
19782
|
var coerce_1 = coerce$1;
|
|
19761
19783
|
|
|
19762
|
-
|
|
19763
|
-
|
|
19764
|
-
|
|
19765
|
-
|
|
19766
|
-
|
|
19767
|
-
hasRequiredIterator = 1;
|
|
19768
|
-
iterator = function (Yallist) {
|
|
19769
|
-
Yallist.prototype[Symbol.iterator] = function* () {
|
|
19770
|
-
for (let walker = this.head; walker; walker = walker.next) {
|
|
19771
|
-
yield walker.value;
|
|
19772
|
-
}
|
|
19773
|
-
};
|
|
19774
|
-
};
|
|
19775
|
-
return iterator;
|
|
19776
|
-
}
|
|
19777
|
-
|
|
19778
|
-
var yallist;
|
|
19779
|
-
var hasRequiredYallist;
|
|
19780
|
-
|
|
19781
|
-
function requireYallist () {
|
|
19782
|
-
if (hasRequiredYallist) return yallist;
|
|
19783
|
-
hasRequiredYallist = 1;
|
|
19784
|
-
yallist = Yallist;
|
|
19785
|
-
|
|
19786
|
-
Yallist.Node = Node;
|
|
19787
|
-
Yallist.create = Yallist;
|
|
19788
|
-
|
|
19789
|
-
function Yallist (list) {
|
|
19790
|
-
var self = this;
|
|
19791
|
-
if (!(self instanceof Yallist)) {
|
|
19792
|
-
self = new Yallist();
|
|
19793
|
-
}
|
|
19794
|
-
|
|
19795
|
-
self.tail = null;
|
|
19796
|
-
self.head = null;
|
|
19797
|
-
self.length = 0;
|
|
19798
|
-
|
|
19799
|
-
if (list && typeof list.forEach === 'function') {
|
|
19800
|
-
list.forEach(function (item) {
|
|
19801
|
-
self.push(item);
|
|
19802
|
-
});
|
|
19803
|
-
} else if (arguments.length > 0) {
|
|
19804
|
-
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
19805
|
-
self.push(arguments[i]);
|
|
19806
|
-
}
|
|
19807
|
-
}
|
|
19808
|
-
|
|
19809
|
-
return self
|
|
19810
|
-
}
|
|
19811
|
-
|
|
19812
|
-
Yallist.prototype.removeNode = function (node) {
|
|
19813
|
-
if (node.list !== this) {
|
|
19814
|
-
throw new Error('removing node which does not belong to this list')
|
|
19815
|
-
}
|
|
19816
|
-
|
|
19817
|
-
var next = node.next;
|
|
19818
|
-
var prev = node.prev;
|
|
19819
|
-
|
|
19820
|
-
if (next) {
|
|
19821
|
-
next.prev = prev;
|
|
19822
|
-
}
|
|
19823
|
-
|
|
19824
|
-
if (prev) {
|
|
19825
|
-
prev.next = next;
|
|
19826
|
-
}
|
|
19827
|
-
|
|
19828
|
-
if (node === this.head) {
|
|
19829
|
-
this.head = next;
|
|
19830
|
-
}
|
|
19831
|
-
if (node === this.tail) {
|
|
19832
|
-
this.tail = prev;
|
|
19833
|
-
}
|
|
19834
|
-
|
|
19835
|
-
node.list.length--;
|
|
19836
|
-
node.next = null;
|
|
19837
|
-
node.prev = null;
|
|
19838
|
-
node.list = null;
|
|
19839
|
-
|
|
19840
|
-
return next
|
|
19841
|
-
};
|
|
19842
|
-
|
|
19843
|
-
Yallist.prototype.unshiftNode = function (node) {
|
|
19844
|
-
if (node === this.head) {
|
|
19845
|
-
return
|
|
19846
|
-
}
|
|
19847
|
-
|
|
19848
|
-
if (node.list) {
|
|
19849
|
-
node.list.removeNode(node);
|
|
19850
|
-
}
|
|
19851
|
-
|
|
19852
|
-
var head = this.head;
|
|
19853
|
-
node.list = this;
|
|
19854
|
-
node.next = head;
|
|
19855
|
-
if (head) {
|
|
19856
|
-
head.prev = node;
|
|
19857
|
-
}
|
|
19858
|
-
|
|
19859
|
-
this.head = node;
|
|
19860
|
-
if (!this.tail) {
|
|
19861
|
-
this.tail = node;
|
|
19862
|
-
}
|
|
19863
|
-
this.length++;
|
|
19864
|
-
};
|
|
19865
|
-
|
|
19866
|
-
Yallist.prototype.pushNode = function (node) {
|
|
19867
|
-
if (node === this.tail) {
|
|
19868
|
-
return
|
|
19869
|
-
}
|
|
19870
|
-
|
|
19871
|
-
if (node.list) {
|
|
19872
|
-
node.list.removeNode(node);
|
|
19873
|
-
}
|
|
19874
|
-
|
|
19875
|
-
var tail = this.tail;
|
|
19876
|
-
node.list = this;
|
|
19877
|
-
node.prev = tail;
|
|
19878
|
-
if (tail) {
|
|
19879
|
-
tail.next = node;
|
|
19880
|
-
}
|
|
19881
|
-
|
|
19882
|
-
this.tail = node;
|
|
19883
|
-
if (!this.head) {
|
|
19884
|
-
this.head = node;
|
|
19885
|
-
}
|
|
19886
|
-
this.length++;
|
|
19887
|
-
};
|
|
19888
|
-
|
|
19889
|
-
Yallist.prototype.push = function () {
|
|
19890
|
-
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
19891
|
-
push(this, arguments[i]);
|
|
19892
|
-
}
|
|
19893
|
-
return this.length
|
|
19894
|
-
};
|
|
19895
|
-
|
|
19896
|
-
Yallist.prototype.unshift = function () {
|
|
19897
|
-
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
19898
|
-
unshift(this, arguments[i]);
|
|
19899
|
-
}
|
|
19900
|
-
return this.length
|
|
19901
|
-
};
|
|
19902
|
-
|
|
19903
|
-
Yallist.prototype.pop = function () {
|
|
19904
|
-
if (!this.tail) {
|
|
19905
|
-
return undefined
|
|
19906
|
-
}
|
|
19907
|
-
|
|
19908
|
-
var res = this.tail.value;
|
|
19909
|
-
this.tail = this.tail.prev;
|
|
19910
|
-
if (this.tail) {
|
|
19911
|
-
this.tail.next = null;
|
|
19912
|
-
} else {
|
|
19913
|
-
this.head = null;
|
|
19914
|
-
}
|
|
19915
|
-
this.length--;
|
|
19916
|
-
return res
|
|
19917
|
-
};
|
|
19918
|
-
|
|
19919
|
-
Yallist.prototype.shift = function () {
|
|
19920
|
-
if (!this.head) {
|
|
19921
|
-
return undefined
|
|
19922
|
-
}
|
|
19923
|
-
|
|
19924
|
-
var res = this.head.value;
|
|
19925
|
-
this.head = this.head.next;
|
|
19926
|
-
if (this.head) {
|
|
19927
|
-
this.head.prev = null;
|
|
19928
|
-
} else {
|
|
19929
|
-
this.tail = null;
|
|
19930
|
-
}
|
|
19931
|
-
this.length--;
|
|
19932
|
-
return res
|
|
19933
|
-
};
|
|
19934
|
-
|
|
19935
|
-
Yallist.prototype.forEach = function (fn, thisp) {
|
|
19936
|
-
thisp = thisp || this;
|
|
19937
|
-
for (var walker = this.head, i = 0; walker !== null; i++) {
|
|
19938
|
-
fn.call(thisp, walker.value, i, this);
|
|
19939
|
-
walker = walker.next;
|
|
19940
|
-
}
|
|
19941
|
-
};
|
|
19942
|
-
|
|
19943
|
-
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
|
19944
|
-
thisp = thisp || this;
|
|
19945
|
-
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
|
19946
|
-
fn.call(thisp, walker.value, i, this);
|
|
19947
|
-
walker = walker.prev;
|
|
19948
|
-
}
|
|
19949
|
-
};
|
|
19950
|
-
|
|
19951
|
-
Yallist.prototype.get = function (n) {
|
|
19952
|
-
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
|
19953
|
-
// abort out of the list early if we hit a cycle
|
|
19954
|
-
walker = walker.next;
|
|
19955
|
-
}
|
|
19956
|
-
if (i === n && walker !== null) {
|
|
19957
|
-
return walker.value
|
|
19958
|
-
}
|
|
19959
|
-
};
|
|
19960
|
-
|
|
19961
|
-
Yallist.prototype.getReverse = function (n) {
|
|
19962
|
-
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
|
19963
|
-
// abort out of the list early if we hit a cycle
|
|
19964
|
-
walker = walker.prev;
|
|
19965
|
-
}
|
|
19966
|
-
if (i === n && walker !== null) {
|
|
19967
|
-
return walker.value
|
|
19968
|
-
}
|
|
19969
|
-
};
|
|
19970
|
-
|
|
19971
|
-
Yallist.prototype.map = function (fn, thisp) {
|
|
19972
|
-
thisp = thisp || this;
|
|
19973
|
-
var res = new Yallist();
|
|
19974
|
-
for (var walker = this.head; walker !== null;) {
|
|
19975
|
-
res.push(fn.call(thisp, walker.value, this));
|
|
19976
|
-
walker = walker.next;
|
|
19977
|
-
}
|
|
19978
|
-
return res
|
|
19979
|
-
};
|
|
19980
|
-
|
|
19981
|
-
Yallist.prototype.mapReverse = function (fn, thisp) {
|
|
19982
|
-
thisp = thisp || this;
|
|
19983
|
-
var res = new Yallist();
|
|
19984
|
-
for (var walker = this.tail; walker !== null;) {
|
|
19985
|
-
res.push(fn.call(thisp, walker.value, this));
|
|
19986
|
-
walker = walker.prev;
|
|
19987
|
-
}
|
|
19988
|
-
return res
|
|
19989
|
-
};
|
|
19990
|
-
|
|
19991
|
-
Yallist.prototype.reduce = function (fn, initial) {
|
|
19992
|
-
var acc;
|
|
19993
|
-
var walker = this.head;
|
|
19994
|
-
if (arguments.length > 1) {
|
|
19995
|
-
acc = initial;
|
|
19996
|
-
} else if (this.head) {
|
|
19997
|
-
walker = this.head.next;
|
|
19998
|
-
acc = this.head.value;
|
|
19999
|
-
} else {
|
|
20000
|
-
throw new TypeError('Reduce of empty list with no initial value')
|
|
20001
|
-
}
|
|
20002
|
-
|
|
20003
|
-
for (var i = 0; walker !== null; i++) {
|
|
20004
|
-
acc = fn(acc, walker.value, i);
|
|
20005
|
-
walker = walker.next;
|
|
20006
|
-
}
|
|
20007
|
-
|
|
20008
|
-
return acc
|
|
20009
|
-
};
|
|
20010
|
-
|
|
20011
|
-
Yallist.prototype.reduceReverse = function (fn, initial) {
|
|
20012
|
-
var acc;
|
|
20013
|
-
var walker = this.tail;
|
|
20014
|
-
if (arguments.length > 1) {
|
|
20015
|
-
acc = initial;
|
|
20016
|
-
} else if (this.tail) {
|
|
20017
|
-
walker = this.tail.prev;
|
|
20018
|
-
acc = this.tail.value;
|
|
20019
|
-
} else {
|
|
20020
|
-
throw new TypeError('Reduce of empty list with no initial value')
|
|
20021
|
-
}
|
|
20022
|
-
|
|
20023
|
-
for (var i = this.length - 1; walker !== null; i--) {
|
|
20024
|
-
acc = fn(acc, walker.value, i);
|
|
20025
|
-
walker = walker.prev;
|
|
20026
|
-
}
|
|
20027
|
-
|
|
20028
|
-
return acc
|
|
20029
|
-
};
|
|
20030
|
-
|
|
20031
|
-
Yallist.prototype.toArray = function () {
|
|
20032
|
-
var arr = new Array(this.length);
|
|
20033
|
-
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
20034
|
-
arr[i] = walker.value;
|
|
20035
|
-
walker = walker.next;
|
|
20036
|
-
}
|
|
20037
|
-
return arr
|
|
20038
|
-
};
|
|
20039
|
-
|
|
20040
|
-
Yallist.prototype.toArrayReverse = function () {
|
|
20041
|
-
var arr = new Array(this.length);
|
|
20042
|
-
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
|
20043
|
-
arr[i] = walker.value;
|
|
20044
|
-
walker = walker.prev;
|
|
20045
|
-
}
|
|
20046
|
-
return arr
|
|
20047
|
-
};
|
|
20048
|
-
|
|
20049
|
-
Yallist.prototype.slice = function (from, to) {
|
|
20050
|
-
to = to || this.length;
|
|
20051
|
-
if (to < 0) {
|
|
20052
|
-
to += this.length;
|
|
20053
|
-
}
|
|
20054
|
-
from = from || 0;
|
|
20055
|
-
if (from < 0) {
|
|
20056
|
-
from += this.length;
|
|
20057
|
-
}
|
|
20058
|
-
var ret = new Yallist();
|
|
20059
|
-
if (to < from || to < 0) {
|
|
20060
|
-
return ret
|
|
20061
|
-
}
|
|
20062
|
-
if (from < 0) {
|
|
20063
|
-
from = 0;
|
|
20064
|
-
}
|
|
20065
|
-
if (to > this.length) {
|
|
20066
|
-
to = this.length;
|
|
20067
|
-
}
|
|
20068
|
-
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
20069
|
-
walker = walker.next;
|
|
20070
|
-
}
|
|
20071
|
-
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
20072
|
-
ret.push(walker.value);
|
|
20073
|
-
}
|
|
20074
|
-
return ret
|
|
20075
|
-
};
|
|
20076
|
-
|
|
20077
|
-
Yallist.prototype.sliceReverse = function (from, to) {
|
|
20078
|
-
to = to || this.length;
|
|
20079
|
-
if (to < 0) {
|
|
20080
|
-
to += this.length;
|
|
20081
|
-
}
|
|
20082
|
-
from = from || 0;
|
|
20083
|
-
if (from < 0) {
|
|
20084
|
-
from += this.length;
|
|
20085
|
-
}
|
|
20086
|
-
var ret = new Yallist();
|
|
20087
|
-
if (to < from || to < 0) {
|
|
20088
|
-
return ret
|
|
20089
|
-
}
|
|
20090
|
-
if (from < 0) {
|
|
20091
|
-
from = 0;
|
|
20092
|
-
}
|
|
20093
|
-
if (to > this.length) {
|
|
20094
|
-
to = this.length;
|
|
20095
|
-
}
|
|
20096
|
-
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
|
20097
|
-
walker = walker.prev;
|
|
20098
|
-
}
|
|
20099
|
-
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
|
20100
|
-
ret.push(walker.value);
|
|
20101
|
-
}
|
|
20102
|
-
return ret
|
|
20103
|
-
};
|
|
20104
|
-
|
|
20105
|
-
Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
|
|
20106
|
-
if (start > this.length) {
|
|
20107
|
-
start = this.length - 1;
|
|
20108
|
-
}
|
|
20109
|
-
if (start < 0) {
|
|
20110
|
-
start = this.length + start;
|
|
20111
|
-
}
|
|
20112
|
-
|
|
20113
|
-
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
|
20114
|
-
walker = walker.next;
|
|
20115
|
-
}
|
|
20116
|
-
|
|
20117
|
-
var ret = [];
|
|
20118
|
-
for (var i = 0; walker && i < deleteCount; i++) {
|
|
20119
|
-
ret.push(walker.value);
|
|
20120
|
-
walker = this.removeNode(walker);
|
|
20121
|
-
}
|
|
20122
|
-
if (walker === null) {
|
|
20123
|
-
walker = this.tail;
|
|
20124
|
-
}
|
|
20125
|
-
|
|
20126
|
-
if (walker !== this.head && walker !== this.tail) {
|
|
20127
|
-
walker = walker.prev;
|
|
20128
|
-
}
|
|
20129
|
-
|
|
20130
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
20131
|
-
walker = insert(this, walker, nodes[i]);
|
|
20132
|
-
}
|
|
20133
|
-
return ret;
|
|
20134
|
-
};
|
|
20135
|
-
|
|
20136
|
-
Yallist.prototype.reverse = function () {
|
|
20137
|
-
var head = this.head;
|
|
20138
|
-
var tail = this.tail;
|
|
20139
|
-
for (var walker = head; walker !== null; walker = walker.prev) {
|
|
20140
|
-
var p = walker.prev;
|
|
20141
|
-
walker.prev = walker.next;
|
|
20142
|
-
walker.next = p;
|
|
20143
|
-
}
|
|
20144
|
-
this.head = tail;
|
|
20145
|
-
this.tail = head;
|
|
20146
|
-
return this
|
|
20147
|
-
};
|
|
20148
|
-
|
|
20149
|
-
function insert (self, node, value) {
|
|
20150
|
-
var inserted = node === self.head ?
|
|
20151
|
-
new Node(value, null, node, self) :
|
|
20152
|
-
new Node(value, node, node.next, self);
|
|
20153
|
-
|
|
20154
|
-
if (inserted.next === null) {
|
|
20155
|
-
self.tail = inserted;
|
|
20156
|
-
}
|
|
20157
|
-
if (inserted.prev === null) {
|
|
20158
|
-
self.head = inserted;
|
|
20159
|
-
}
|
|
20160
|
-
|
|
20161
|
-
self.length++;
|
|
20162
|
-
|
|
20163
|
-
return inserted
|
|
20164
|
-
}
|
|
20165
|
-
|
|
20166
|
-
function push (self, item) {
|
|
20167
|
-
self.tail = new Node(item, self.tail, null, self);
|
|
20168
|
-
if (!self.head) {
|
|
20169
|
-
self.head = self.tail;
|
|
20170
|
-
}
|
|
20171
|
-
self.length++;
|
|
20172
|
-
}
|
|
20173
|
-
|
|
20174
|
-
function unshift (self, item) {
|
|
20175
|
-
self.head = new Node(item, null, self.head, self);
|
|
20176
|
-
if (!self.tail) {
|
|
20177
|
-
self.tail = self.head;
|
|
20178
|
-
}
|
|
20179
|
-
self.length++;
|
|
20180
|
-
}
|
|
20181
|
-
|
|
20182
|
-
function Node (value, prev, next, list) {
|
|
20183
|
-
if (!(this instanceof Node)) {
|
|
20184
|
-
return new Node(value, prev, next, list)
|
|
20185
|
-
}
|
|
20186
|
-
|
|
20187
|
-
this.list = list;
|
|
20188
|
-
this.value = value;
|
|
20189
|
-
|
|
20190
|
-
if (prev) {
|
|
20191
|
-
prev.next = this;
|
|
20192
|
-
this.prev = prev;
|
|
20193
|
-
} else {
|
|
20194
|
-
this.prev = null;
|
|
20195
|
-
}
|
|
20196
|
-
|
|
20197
|
-
if (next) {
|
|
20198
|
-
next.prev = this;
|
|
20199
|
-
this.next = next;
|
|
20200
|
-
} else {
|
|
20201
|
-
this.next = null;
|
|
20202
|
-
}
|
|
20203
|
-
}
|
|
20204
|
-
|
|
20205
|
-
try {
|
|
20206
|
-
// add if support for Symbol.iterator is present
|
|
20207
|
-
requireIterator()(Yallist);
|
|
20208
|
-
} catch (er) {}
|
|
20209
|
-
return yallist;
|
|
20210
|
-
}
|
|
20211
|
-
|
|
20212
|
-
var lruCache;
|
|
20213
|
-
var hasRequiredLruCache;
|
|
20214
|
-
|
|
20215
|
-
function requireLruCache () {
|
|
20216
|
-
if (hasRequiredLruCache) return lruCache;
|
|
20217
|
-
hasRequiredLruCache = 1;
|
|
20218
|
-
|
|
20219
|
-
// A linked list to keep track of recently-used-ness
|
|
20220
|
-
const Yallist = requireYallist();
|
|
20221
|
-
|
|
20222
|
-
const MAX = Symbol('max');
|
|
20223
|
-
const LENGTH = Symbol('length');
|
|
20224
|
-
const LENGTH_CALCULATOR = Symbol('lengthCalculator');
|
|
20225
|
-
const ALLOW_STALE = Symbol('allowStale');
|
|
20226
|
-
const MAX_AGE = Symbol('maxAge');
|
|
20227
|
-
const DISPOSE = Symbol('dispose');
|
|
20228
|
-
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
|
|
20229
|
-
const LRU_LIST = Symbol('lruList');
|
|
20230
|
-
const CACHE = Symbol('cache');
|
|
20231
|
-
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
|
|
20232
|
-
|
|
20233
|
-
const naiveLength = () => 1;
|
|
20234
|
-
|
|
20235
|
-
// lruList is a yallist where the head is the youngest
|
|
20236
|
-
// item, and the tail is the oldest. the list contains the Hit
|
|
20237
|
-
// objects as the entries.
|
|
20238
|
-
// Each Hit object has a reference to its Yallist.Node. This
|
|
20239
|
-
// never changes.
|
|
20240
|
-
//
|
|
20241
|
-
// cache is a Map (or PseudoMap) that matches the keys to
|
|
20242
|
-
// the Yallist.Node object.
|
|
20243
|
-
class LRUCache {
|
|
20244
|
-
constructor (options) {
|
|
20245
|
-
if (typeof options === 'number')
|
|
20246
|
-
options = { max: options };
|
|
20247
|
-
|
|
20248
|
-
if (!options)
|
|
20249
|
-
options = {};
|
|
20250
|
-
|
|
20251
|
-
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
|
20252
|
-
throw new TypeError('max must be a non-negative number')
|
|
20253
|
-
// Kind of weird to have a default max of Infinity, but oh well.
|
|
20254
|
-
this[MAX] = options.max || Infinity;
|
|
20255
|
-
|
|
20256
|
-
const lc = options.length || naiveLength;
|
|
20257
|
-
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
|
|
20258
|
-
this[ALLOW_STALE] = options.stale || false;
|
|
20259
|
-
if (options.maxAge && typeof options.maxAge !== 'number')
|
|
20260
|
-
throw new TypeError('maxAge must be a number')
|
|
20261
|
-
this[MAX_AGE] = options.maxAge || 0;
|
|
20262
|
-
this[DISPOSE] = options.dispose;
|
|
20263
|
-
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
|
|
20264
|
-
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
|
|
20265
|
-
this.reset();
|
|
20266
|
-
}
|
|
20267
|
-
|
|
20268
|
-
// resize the cache when the max changes.
|
|
20269
|
-
set max (mL) {
|
|
20270
|
-
if (typeof mL !== 'number' || mL < 0)
|
|
20271
|
-
throw new TypeError('max must be a non-negative number')
|
|
20272
|
-
|
|
20273
|
-
this[MAX] = mL || Infinity;
|
|
20274
|
-
trim(this);
|
|
20275
|
-
}
|
|
20276
|
-
get max () {
|
|
20277
|
-
return this[MAX]
|
|
20278
|
-
}
|
|
20279
|
-
|
|
20280
|
-
set allowStale (allowStale) {
|
|
20281
|
-
this[ALLOW_STALE] = !!allowStale;
|
|
20282
|
-
}
|
|
20283
|
-
get allowStale () {
|
|
20284
|
-
return this[ALLOW_STALE]
|
|
20285
|
-
}
|
|
20286
|
-
|
|
20287
|
-
set maxAge (mA) {
|
|
20288
|
-
if (typeof mA !== 'number')
|
|
20289
|
-
throw new TypeError('maxAge must be a non-negative number')
|
|
20290
|
-
|
|
20291
|
-
this[MAX_AGE] = mA;
|
|
20292
|
-
trim(this);
|
|
20293
|
-
}
|
|
20294
|
-
get maxAge () {
|
|
20295
|
-
return this[MAX_AGE]
|
|
20296
|
-
}
|
|
20297
|
-
|
|
20298
|
-
// resize the cache when the lengthCalculator changes.
|
|
20299
|
-
set lengthCalculator (lC) {
|
|
20300
|
-
if (typeof lC !== 'function')
|
|
20301
|
-
lC = naiveLength;
|
|
20302
|
-
|
|
20303
|
-
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
20304
|
-
this[LENGTH_CALCULATOR] = lC;
|
|
20305
|
-
this[LENGTH] = 0;
|
|
20306
|
-
this[LRU_LIST].forEach(hit => {
|
|
20307
|
-
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
|
|
20308
|
-
this[LENGTH] += hit.length;
|
|
20309
|
-
});
|
|
20310
|
-
}
|
|
20311
|
-
trim(this);
|
|
20312
|
-
}
|
|
20313
|
-
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
|
20314
|
-
|
|
20315
|
-
get length () { return this[LENGTH] }
|
|
20316
|
-
get itemCount () { return this[LRU_LIST].length }
|
|
20317
|
-
|
|
20318
|
-
rforEach (fn, thisp) {
|
|
20319
|
-
thisp = thisp || this;
|
|
20320
|
-
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
|
20321
|
-
const prev = walker.prev;
|
|
20322
|
-
forEachStep(this, fn, walker, thisp);
|
|
20323
|
-
walker = prev;
|
|
20324
|
-
}
|
|
20325
|
-
}
|
|
20326
|
-
|
|
20327
|
-
forEach (fn, thisp) {
|
|
20328
|
-
thisp = thisp || this;
|
|
20329
|
-
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
|
20330
|
-
const next = walker.next;
|
|
20331
|
-
forEachStep(this, fn, walker, thisp);
|
|
20332
|
-
walker = next;
|
|
20333
|
-
}
|
|
20334
|
-
}
|
|
20335
|
-
|
|
20336
|
-
keys () {
|
|
20337
|
-
return this[LRU_LIST].toArray().map(k => k.key)
|
|
20338
|
-
}
|
|
20339
|
-
|
|
20340
|
-
values () {
|
|
20341
|
-
return this[LRU_LIST].toArray().map(k => k.value)
|
|
20342
|
-
}
|
|
20343
|
-
|
|
20344
|
-
reset () {
|
|
20345
|
-
if (this[DISPOSE] &&
|
|
20346
|
-
this[LRU_LIST] &&
|
|
20347
|
-
this[LRU_LIST].length) {
|
|
20348
|
-
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
|
|
20349
|
-
}
|
|
20350
|
-
|
|
20351
|
-
this[CACHE] = new Map(); // hash of items by key
|
|
20352
|
-
this[LRU_LIST] = new Yallist(); // list of items in order of use recency
|
|
20353
|
-
this[LENGTH] = 0; // length of items in the list
|
|
20354
|
-
}
|
|
20355
|
-
|
|
20356
|
-
dump () {
|
|
20357
|
-
return this[LRU_LIST].map(hit =>
|
|
20358
|
-
isStale(this, hit) ? false : {
|
|
20359
|
-
k: hit.key,
|
|
20360
|
-
v: hit.value,
|
|
20361
|
-
e: hit.now + (hit.maxAge || 0)
|
|
20362
|
-
}).toArray().filter(h => h)
|
|
20363
|
-
}
|
|
20364
|
-
|
|
20365
|
-
dumpLru () {
|
|
20366
|
-
return this[LRU_LIST]
|
|
20367
|
-
}
|
|
20368
|
-
|
|
20369
|
-
set (key, value, maxAge) {
|
|
20370
|
-
maxAge = maxAge || this[MAX_AGE];
|
|
20371
|
-
|
|
20372
|
-
if (maxAge && typeof maxAge !== 'number')
|
|
20373
|
-
throw new TypeError('maxAge must be a number')
|
|
20374
|
-
|
|
20375
|
-
const now = maxAge ? Date.now() : 0;
|
|
20376
|
-
const len = this[LENGTH_CALCULATOR](value, key);
|
|
20377
|
-
|
|
20378
|
-
if (this[CACHE].has(key)) {
|
|
20379
|
-
if (len > this[MAX]) {
|
|
20380
|
-
del(this, this[CACHE].get(key));
|
|
20381
|
-
return false
|
|
20382
|
-
}
|
|
20383
|
-
|
|
20384
|
-
const node = this[CACHE].get(key);
|
|
20385
|
-
const item = node.value;
|
|
20386
|
-
|
|
20387
|
-
// dispose of the old one before overwriting
|
|
20388
|
-
// split out into 2 ifs for better coverage tracking
|
|
20389
|
-
if (this[DISPOSE]) {
|
|
20390
|
-
if (!this[NO_DISPOSE_ON_SET])
|
|
20391
|
-
this[DISPOSE](key, item.value);
|
|
20392
|
-
}
|
|
20393
|
-
|
|
20394
|
-
item.now = now;
|
|
20395
|
-
item.maxAge = maxAge;
|
|
20396
|
-
item.value = value;
|
|
20397
|
-
this[LENGTH] += len - item.length;
|
|
20398
|
-
item.length = len;
|
|
20399
|
-
this.get(key);
|
|
20400
|
-
trim(this);
|
|
20401
|
-
return true
|
|
20402
|
-
}
|
|
20403
|
-
|
|
20404
|
-
const hit = new Entry(key, value, len, now, maxAge);
|
|
20405
|
-
|
|
20406
|
-
// oversized objects fall out of cache automatically.
|
|
20407
|
-
if (hit.length > this[MAX]) {
|
|
20408
|
-
if (this[DISPOSE])
|
|
20409
|
-
this[DISPOSE](key, value);
|
|
20410
|
-
|
|
20411
|
-
return false
|
|
20412
|
-
}
|
|
20413
|
-
|
|
20414
|
-
this[LENGTH] += hit.length;
|
|
20415
|
-
this[LRU_LIST].unshift(hit);
|
|
20416
|
-
this[CACHE].set(key, this[LRU_LIST].head);
|
|
20417
|
-
trim(this);
|
|
20418
|
-
return true
|
|
20419
|
-
}
|
|
20420
|
-
|
|
20421
|
-
has (key) {
|
|
20422
|
-
if (!this[CACHE].has(key)) return false
|
|
20423
|
-
const hit = this[CACHE].get(key).value;
|
|
20424
|
-
return !isStale(this, hit)
|
|
20425
|
-
}
|
|
20426
|
-
|
|
20427
|
-
get (key) {
|
|
20428
|
-
return get(this, key, true)
|
|
20429
|
-
}
|
|
20430
|
-
|
|
20431
|
-
peek (key) {
|
|
20432
|
-
return get(this, key, false)
|
|
20433
|
-
}
|
|
20434
|
-
|
|
20435
|
-
pop () {
|
|
20436
|
-
const node = this[LRU_LIST].tail;
|
|
20437
|
-
if (!node)
|
|
20438
|
-
return null
|
|
20439
|
-
|
|
20440
|
-
del(this, node);
|
|
20441
|
-
return node.value
|
|
20442
|
-
}
|
|
20443
|
-
|
|
20444
|
-
del (key) {
|
|
20445
|
-
del(this, this[CACHE].get(key));
|
|
20446
|
-
}
|
|
20447
|
-
|
|
20448
|
-
load (arr) {
|
|
20449
|
-
// reset the cache
|
|
20450
|
-
this.reset();
|
|
20451
|
-
|
|
20452
|
-
const now = Date.now();
|
|
20453
|
-
// A previous serialized cache has the most recent items first
|
|
20454
|
-
for (let l = arr.length - 1; l >= 0; l--) {
|
|
20455
|
-
const hit = arr[l];
|
|
20456
|
-
const expiresAt = hit.e || 0;
|
|
20457
|
-
if (expiresAt === 0)
|
|
20458
|
-
// the item was created without expiration in a non aged cache
|
|
20459
|
-
this.set(hit.k, hit.v);
|
|
20460
|
-
else {
|
|
20461
|
-
const maxAge = expiresAt - now;
|
|
20462
|
-
// dont add already expired items
|
|
20463
|
-
if (maxAge > 0) {
|
|
20464
|
-
this.set(hit.k, hit.v, maxAge);
|
|
20465
|
-
}
|
|
20466
|
-
}
|
|
20467
|
-
}
|
|
20468
|
-
}
|
|
20469
|
-
|
|
20470
|
-
prune () {
|
|
20471
|
-
this[CACHE].forEach((value, key) => get(this, key, false));
|
|
20472
|
-
}
|
|
20473
|
-
}
|
|
20474
|
-
|
|
20475
|
-
const get = (self, key, doUse) => {
|
|
20476
|
-
const node = self[CACHE].get(key);
|
|
20477
|
-
if (node) {
|
|
20478
|
-
const hit = node.value;
|
|
20479
|
-
if (isStale(self, hit)) {
|
|
20480
|
-
del(self, node);
|
|
20481
|
-
if (!self[ALLOW_STALE])
|
|
20482
|
-
return undefined
|
|
20483
|
-
} else {
|
|
20484
|
-
if (doUse) {
|
|
20485
|
-
if (self[UPDATE_AGE_ON_GET])
|
|
20486
|
-
node.value.now = Date.now();
|
|
20487
|
-
self[LRU_LIST].unshiftNode(node);
|
|
20488
|
-
}
|
|
20489
|
-
}
|
|
20490
|
-
return hit.value
|
|
20491
|
-
}
|
|
20492
|
-
};
|
|
20493
|
-
|
|
20494
|
-
const isStale = (self, hit) => {
|
|
20495
|
-
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
|
20496
|
-
return false
|
|
20497
|
-
|
|
20498
|
-
const diff = Date.now() - hit.now;
|
|
20499
|
-
return hit.maxAge ? diff > hit.maxAge
|
|
20500
|
-
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
|
20501
|
-
};
|
|
19784
|
+
class LRUCache {
|
|
19785
|
+
constructor () {
|
|
19786
|
+
this.max = 1000;
|
|
19787
|
+
this.map = new Map();
|
|
19788
|
+
}
|
|
20502
19789
|
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
}
|
|
20515
|
-
};
|
|
19790
|
+
get (key) {
|
|
19791
|
+
const value = this.map.get(key);
|
|
19792
|
+
if (value === undefined) {
|
|
19793
|
+
return undefined
|
|
19794
|
+
} else {
|
|
19795
|
+
// Remove the key from the map and add it to the end
|
|
19796
|
+
this.map.delete(key);
|
|
19797
|
+
this.map.set(key, value);
|
|
19798
|
+
return value
|
|
19799
|
+
}
|
|
19800
|
+
}
|
|
20516
19801
|
|
|
20517
|
-
|
|
20518
|
-
|
|
20519
|
-
|
|
20520
|
-
if (self[DISPOSE])
|
|
20521
|
-
self[DISPOSE](hit.key, hit.value);
|
|
19802
|
+
delete (key) {
|
|
19803
|
+
return this.map.delete(key)
|
|
19804
|
+
}
|
|
20522
19805
|
|
|
20523
|
-
|
|
20524
|
-
|
|
20525
|
-
self[LRU_LIST].removeNode(node);
|
|
20526
|
-
}
|
|
20527
|
-
};
|
|
19806
|
+
set (key, value) {
|
|
19807
|
+
const deleted = this.delete(key);
|
|
20528
19808
|
|
|
20529
|
-
|
|
20530
|
-
|
|
20531
|
-
|
|
20532
|
-
|
|
20533
|
-
|
|
20534
|
-
|
|
20535
|
-
this.maxAge = maxAge || 0;
|
|
20536
|
-
}
|
|
20537
|
-
}
|
|
19809
|
+
if (!deleted && value !== undefined) {
|
|
19810
|
+
// If cache is full, delete the least recently used item
|
|
19811
|
+
if (this.map.size >= this.max) {
|
|
19812
|
+
const firstKey = this.map.keys().next().value;
|
|
19813
|
+
this.delete(firstKey);
|
|
19814
|
+
}
|
|
20538
19815
|
|
|
20539
|
-
|
|
20540
|
-
|
|
20541
|
-
if (isStale(self, hit)) {
|
|
20542
|
-
del(self, node);
|
|
20543
|
-
if (!self[ALLOW_STALE])
|
|
20544
|
-
hit = undefined;
|
|
20545
|
-
}
|
|
20546
|
-
if (hit)
|
|
20547
|
-
fn.call(thisp, hit.value, hit.key, self);
|
|
20548
|
-
};
|
|
19816
|
+
this.map.set(key, value);
|
|
19817
|
+
}
|
|
20549
19818
|
|
|
20550
|
-
|
|
20551
|
-
|
|
19819
|
+
return this
|
|
19820
|
+
}
|
|
20552
19821
|
}
|
|
20553
19822
|
|
|
19823
|
+
var lrucache = LRUCache;
|
|
19824
|
+
|
|
20554
19825
|
var range;
|
|
20555
19826
|
var hasRequiredRange;
|
|
20556
19827
|
|
|
@@ -20757,8 +20028,8 @@ function requireRange () {
|
|
|
20757
20028
|
|
|
20758
20029
|
range = Range;
|
|
20759
20030
|
|
|
20760
|
-
const LRU =
|
|
20761
|
-
const cache = new LRU(
|
|
20031
|
+
const LRU = lrucache;
|
|
20032
|
+
const cache = new LRU();
|
|
20762
20033
|
|
|
20763
20034
|
const parseOptions = parseOptions_1;
|
|
20764
20035
|
const Comparator = requireComparator();
|
|
@@ -21029,9 +20300,10 @@ function requireRange () {
|
|
|
21029
20300
|
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
21030
20301
|
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
|
|
21031
20302
|
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
|
20303
|
+
// TODO build?
|
|
21032
20304
|
const hyphenReplace = incPr => ($0,
|
|
21033
20305
|
from, fM, fm, fp, fpr, fb,
|
|
21034
|
-
to, tM, tm, tp, tpr
|
|
20306
|
+
to, tM, tm, tp, tpr) => {
|
|
21035
20307
|
if (isX(fM)) {
|
|
21036
20308
|
from = '';
|
|
21037
20309
|
} else if (isX(fm)) {
|
|
@@ -22388,9 +21660,10 @@ function replace(options) {
|
|
|
22388
21660
|
if (objectGuards) { expandTypeofReplacements(replacements); }
|
|
22389
21661
|
var functionValues = mapToFunctions(replacements);
|
|
22390
21662
|
var keys = Object.keys(functionValues).sort(longest).map(escape);
|
|
22391
|
-
var
|
|
21663
|
+
var lookbehind = preventAssignment ? '(?<!\\b(?:const|let|var)\\s*)' : '';
|
|
21664
|
+
var lookahead = preventAssignment ? '(?!\\s*=[^=])' : '';
|
|
22392
21665
|
var pattern = new RegExp(
|
|
22393
|
-
((delimiters[0]) + "(" + (keys.join('|')) + ")" + (delimiters[1]) + lookahead),
|
|
21666
|
+
("" + lookbehind + (delimiters[0]) + "(" + (keys.join('|')) + ")" + (delimiters[1]) + lookahead),
|
|
22394
21667
|
'g'
|
|
22395
21668
|
);
|
|
22396
21669
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m2c2kit/build-helpers",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"description": "Utility functions for building m2c2kit apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -15,21 +15,22 @@
|
|
|
15
15
|
"dist/index.d.ts"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@rollup/plugin-commonjs": "
|
|
18
|
+
"@rollup/plugin-commonjs": "26.0.1",
|
|
19
19
|
"@rollup/plugin-json": "6.1.0",
|
|
20
20
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
21
21
|
"@types/estree": "1.0.5",
|
|
22
|
-
"@types/findup-sync": "4.0.
|
|
22
|
+
"@types/findup-sync": "4.0.5",
|
|
23
|
+
"@types/semver": "7.5.8",
|
|
23
24
|
"cpy": "10.1.0",
|
|
24
25
|
"findup-sync": "5.0.0",
|
|
25
|
-
"magic-string": "0.30.
|
|
26
|
-
"rimraf": "5.0.
|
|
27
|
-
"rollup": "4.
|
|
26
|
+
"magic-string": "0.30.10",
|
|
27
|
+
"rimraf": "5.0.7",
|
|
28
|
+
"rollup": "4.18.0",
|
|
28
29
|
"rollup-plugin-copy": "3.5.0",
|
|
29
|
-
"rollup-plugin-dts": "6.1.
|
|
30
|
+
"rollup-plugin-dts": "6.1.1",
|
|
30
31
|
"rollup-plugin-esbuild": "6.1.1",
|
|
31
|
-
"semver": "7.6.
|
|
32
|
-
"typescript": "5.4.
|
|
32
|
+
"semver": "7.6.2",
|
|
33
|
+
"typescript": "5.4.5"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
36
|
"build": "npm run clean && tsc && rollup -c",
|