@@ -46556,8 +46556,8 @@ const braces = (input, options = {}) => {
46556
46556
let output = [];
46557
46557
46558
46558
if (Array.isArray(input)) {
46559
- for (let pattern of input) {
46560
- let result = braces.create(pattern, options);
46559
+ for (const pattern of input) {
46560
+ const result = braces.create(pattern, options);
46561
46561
if (Array.isArray(result)) {
46562
46562
output.push(...result);
46563
46563
} else {
@@ -46691,7 +46691,7 @@ braces.create = (input, options = {}) => {
46691
46691
return [input];
46692
46692
}
46693
46693
46694
- return options.expand !== true
46694
+ return options.expand !== true
46695
46695
? braces.compile(input, options)
46696
46696
: braces.expand(input, options);
46697
46697
};
@@ -46715,50 +46715,53 @@ const fill = __nccwpck_require__(6330);
46715
46715
const utils = __nccwpck_require__(5207);
46716
46716
46717
46717
const compile = (ast, options = {}) => {
46718
- let walk = (node, parent = {}) => {
46719
- let invalidBlock = utils.isInvalidBrace(parent);
46720
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
46721
- let invalid = invalidBlock === true || invalidNode === true;
46722
- let prefix = options.escapeInvalid === true ? '\\' : '';
46718
+ const walk = (node, parent = {}) => {
46719
+ const invalidBlock = utils.isInvalidBrace(parent);
46720
+ const invalidNode = node.invalid === true && options.escapeInvalid === true;
46721
+ const invalid = invalidBlock === true || invalidNode === true;
46722
+ const prefix = options.escapeInvalid === true ? '\\' : '';
46723
46723
let output = '';
46724
46724
46725
46725
if (node.isOpen === true) {
46726
46726
return prefix + node.value;
46727
46727
}
46728
+
46728
46729
if (node.isClose === true) {
46730
+ console.log('node.isClose', prefix, node.value);
46729
46731
return prefix + node.value;
46730
46732
}
46731
46733
46732
46734
if (node.type === 'open') {
46733
- return invalid ? ( prefix + node.value) : '(';
46735
+ return invalid ? prefix + node.value : '(';
46734
46736
}
46735
46737
46736
46738
if (node.type === 'close') {
46737
- return invalid ? ( prefix + node.value) : ')';
46739
+ return invalid ? prefix + node.value : ')';
46738
46740
}
46739
46741
46740
46742
if (node.type === 'comma') {
46741
- return node.prev.type === 'comma' ? '' : ( invalid ? node.value : '|') ;
46743
+ return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
46742
46744
}
46743
46745
46744
46746
if (node.value) {
46745
46747
return node.value;
46746
46748
}
46747
46749
46748
46750
if (node.nodes && node.ranges > 0) {
46749
- let args = utils.reduce(node.nodes);
46750
- let range = fill(...args, { ...options, wrap: false, toRegex: true });
46751
+ const args = utils.reduce(node.nodes);
46752
+ const range = fill(...args, { ...options, wrap: false, toRegex: true, strictZeros : true });
46751
46753
46752
46754
if (range.length !== 0) {
46753
46755
return args.length > 1 && range.length > 1 ? `(${range})` : range;
46754
46756
}
46755
46757
}
46756
46758
46757
46759
if (node.nodes) {
46758
- for (let child of node.nodes) {
46760
+ for (const child of node.nodes) {
46759
46761
output += walk(child, node);
46760
46762
}
46761
46763
}
46764
+
46762
46765
return output;
46763
46766
};
46764
46767
@@ -46777,7 +46780,7 @@ module.exports = compile;
46777
46780
46778
46781
46779
46782
module.exports = {
46780
- MAX_LENGTH: 1024 * 64 ,
46783
+ MAX_LENGTH: 10000 ,
46781
46784
46782
46785
// Digits
46783
46786
CHAR_0: '0', /* 0 */
@@ -46846,7 +46849,7 @@ const stringify = __nccwpck_require__(8750);
46846
46849
const utils = __nccwpck_require__(5207);
46847
46850
46848
46851
const append = (queue = '', stash = '', enclose = false) => {
46849
- let result = [];
46852
+ const result = [];
46850
46853
46851
46854
queue = [].concat(queue);
46852
46855
stash = [].concat(stash);
@@ -46856,25 +46859,25 @@ const append = (queue = '', stash = '', enclose = false) => {
46856
46859
return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
46857
46860
}
46858
46861
46859
- for (let item of queue) {
46862
+ for (const item of queue) {
46860
46863
if (Array.isArray(item)) {
46861
- for (let value of item) {
46864
+ for (const value of item) {
46862
46865
result.push(append(value, stash, enclose));
46863
46866
}
46864
46867
} else {
46865
46868
for (let ele of stash) {
46866
46869
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
46867
- result.push(Array.isArray(ele) ? append(item, ele, enclose) : ( item + ele) );
46870
+ result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
46868
46871
}
46869
46872
}
46870
46873
}
46871
46874
return utils.flatten(result);
46872
46875
};
46873
46876
46874
46877
const expand = (ast, options = {}) => {
46875
- let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
46878
+ const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
46876
46879
46877
- let walk = (node, parent = {}) => {
46880
+ const walk = (node, parent = {}) => {
46878
46881
node.queue = [];
46879
46882
46880
46883
let p = parent;
@@ -46896,7 +46899,7 @@ const expand = (ast, options = {}) => {
46896
46899
}
46897
46900
46898
46901
if (node.nodes && node.ranges > 0) {
46899
- let args = utils.reduce(node.nodes);
46902
+ const args = utils.reduce(node.nodes);
46900
46903
46901
46904
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
46902
46905
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
@@ -46912,7 +46915,7 @@ const expand = (ast, options = {}) => {
46912
46915
return;
46913
46916
}
46914
46917
46915
- let enclose = utils.encloseBrace(node);
46918
+ const enclose = utils.encloseBrace(node);
46916
46919
let queue = node.queue;
46917
46920
let block = node;
46918
46921
@@ -46922,7 +46925,7 @@ const expand = (ast, options = {}) => {
46922
46925
}
46923
46926
46924
46927
for (let i = 0; i < node.nodes.length; i++) {
46925
- let child = node.nodes[i];
46928
+ const child = node.nodes[i];
46926
46929
46927
46930
if (child.type === 'comma' && node.type === 'brace') {
46928
46931
if (i === 1) queue.push('');
@@ -46995,22 +46998,21 @@ const parse = (input, options = {}) => {
46995
46998
throw new TypeError('Expected a string');
46996
46999
}
46997
47000
46998
- let opts = options || {};
46999
- let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
47001
+ const opts = options || {};
47002
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
47000
47003
if (input.length > max) {
47001
47004
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
47002
47005
}
47003
47006
47004
- let ast = { type: 'root', input, nodes: [] };
47005
- let stack = [ast];
47007
+ const ast = { type: 'root', input, nodes: [] };
47008
+ const stack = [ast];
47006
47009
let block = ast;
47007
47010
let prev = ast;
47008
47011
let brackets = 0;
47009
- let length = input.length;
47012
+ const length = input.length;
47010
47013
let index = 0;
47011
47014
let depth = 0;
47012
47015
let value;
47013
- let memo = {};
47014
47016
47015
47017
/**
47016
47018
* Helpers
@@ -47073,7 +47075,6 @@ const parse = (input, options = {}) => {
47073
47075
if (value === CHAR_LEFT_SQUARE_BRACKET) {
47074
47076
brackets++;
47075
47077
47076
- let closed = true;
47077
47078
let next;
47078
47079
47079
47080
while (index < length && (next = advance())) {
@@ -47129,7 +47130,7 @@ const parse = (input, options = {}) => {
47129
47130
*/
47130
47131
47131
47132
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
47132
- let open = value;
47133
+ const open = value;
47133
47134
let next;
47134
47135
47135
47136
if (options.keepQuotes !== true) {
@@ -47161,8 +47162,8 @@ const parse = (input, options = {}) => {
47161
47162
if (value === CHAR_LEFT_CURLY_BRACE) {
47162
47163
depth++;
47163
47164
47164
- let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
47165
- let brace = {
47165
+ const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
47166
+ const brace = {
47166
47167
type: 'brace',
47167
47168
open: true,
47168
47169
close: false,
@@ -47189,7 +47190,7 @@ const parse = (input, options = {}) => {
47189
47190
continue;
47190
47191
}
47191
47192
47192
- let type = 'close';
47193
+ const type = 'close';
47193
47194
block = stack.pop();
47194
47195
block.close = true;
47195
47196
@@ -47207,7 +47208,7 @@ const parse = (input, options = {}) => {
47207
47208
if (value === CHAR_COMMA && depth > 0) {
47208
47209
if (block.ranges > 0) {
47209
47210
block.ranges = 0;
47210
- let open = block.nodes.shift();
47211
+ const open = block.nodes.shift();
47211
47212
block.nodes = [open, { type: 'text', value: stringify(block) }];
47212
47213
}
47213
47214
@@ -47221,7 +47222,7 @@ const parse = (input, options = {}) => {
47221
47222
*/
47222
47223
47223
47224
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
47224
- let siblings = block.nodes;
47225
+ const siblings = block.nodes;
47225
47226
47226
47227
if (depth === 0 || siblings.length === 0) {
47227
47228
push({ type: 'text', value });
@@ -47248,7 +47249,7 @@ const parse = (input, options = {}) => {
47248
47249
if (prev.type === 'range') {
47249
47250
siblings.pop();
47250
47251
47251
- let before = siblings[siblings.length - 1];
47252
+ const before = siblings[siblings.length - 1];
47252
47253
before.value += prev.value + value;
47253
47254
prev = before;
47254
47255
block.ranges--;
@@ -47281,8 +47282,8 @@ const parse = (input, options = {}) => {
47281
47282
});
47282
47283
47283
47284
// get the location of the block on parent.nodes (block's siblings)
47284
- let parent = stack[stack.length - 1];
47285
- let index = parent.nodes.indexOf(block);
47285
+ const parent = stack[stack.length - 1];
47286
+ const index = parent.nodes.indexOf(block);
47286
47287
// replace the (invalid) block with it's nodes
47287
47288
parent.nodes.splice(index, 1, ...block.nodes);
47288
47289
}
@@ -47306,9 +47307,9 @@ module.exports = parse;
47306
47307
const utils = __nccwpck_require__(5207);
47307
47308
47308
47309
module.exports = (ast, options = {}) => {
47309
- let stringify = (node, parent = {}) => {
47310
- let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
47311
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
47310
+ const stringify = (node, parent = {}) => {
47311
+ const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
47312
+ const invalidNode = node.invalid === true && options.escapeInvalid === true;
47312
47313
let output = '';
47313
47314
47314
47315
if (node.value) {
@@ -47323,7 +47324,7 @@ module.exports = (ast, options = {}) => {
47323
47324
}
47324
47325
47325
47326
if (node.nodes) {
47326
- for (let child of node.nodes) {
47327
+ for (const child of node.nodes) {
47327
47328
output += stringify(child);
47328
47329
}
47329
47330
}
@@ -47374,7 +47375,7 @@ exports.exceedsLimit = (min, max, step = 1, limit) => {
47374
47375
*/
47375
47376
47376
47377
exports.escapeNode = (block, n = 0, type) => {
47377
- let node = block.nodes[n];
47378
+ const node = block.nodes[n];
47378
47379
if (!node) return;
47379
47380
47380
47381
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
@@ -47443,13 +47444,23 @@ exports.reduce = nodes => nodes.reduce((acc, node) => {
47443
47444
47444
47445
exports.flatten = (...args) => {
47445
47446
const result = [];
47447
+
47446
47448
const flat = arr => {
47447
47449
for (let i = 0; i < arr.length; i++) {
47448
- let ele = arr[i];
47449
- Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
47450
+ const ele = arr[i];
47451
+
47452
+ if (Array.isArray(ele)) {
47453
+ flat(ele);
47454
+ continue;
47455
+ }
47456
+
47457
+ if (ele !== undefined) {
47458
+ result.push(ele);
47459
+ }
47450
47460
}
47451
47461
return result;
47452
47462
};
47463
+
47453
47464
flat(args);
47454
47465
return result;
47455
47466
};
@@ -49907,7 +49918,7 @@ const toMaxLen = (input, maxLength) => {
49907
49918
return negative ? ('-' + input) : input;
49908
49919
};
49909
49920
49910
- const toSequence = (parts, options) => {
49921
+ const toSequence = (parts, options, maxLen ) => {
49911
49922
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
49912
49923
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
49913
49924
@@ -49917,11 +49928,11 @@ const toSequence = (parts, options) => {
49917
49928
let result;
49918
49929
49919
49930
if (parts.positives.length) {
49920
- positives = parts.positives.join('|');
49931
+ positives = parts.positives.map(v => toMaxLen(String(v), maxLen)). join('|');
49921
49932
}
49922
49933
49923
49934
if (parts.negatives.length) {
49924
- negatives = `-(${prefix}${parts.negatives.join('|')})`;
49935
+ negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)). join('|')})`;
49925
49936
}
49926
49937
49927
49938
if (positives && negatives) {
@@ -50019,7 +50030,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
50019
50030
50020
50031
if (options.toRegex === true) {
50021
50032
return step > 1
50022
- ? toSequence(parts, options)
50033
+ ? toSequence(parts, options, maxLen )
50023
50034
: toRegex(range, null, { wrap: false, ...options });
50024
50035
}
50025
50036
@@ -50031,7 +50042,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
50031
50042
return invalidRange(start, end, options);
50032
50043
}
50033
50044
50034
-
50035
50045
let format = options.transform || (val => String.fromCharCode(val));
50036
50046
let a = `${start}`.charCodeAt(0);
50037
50047
let b = `${end}`.charCodeAt(0);
0 commit comments