Skip to content

Commit 8d39186

Browse files
authoredJun 14, 2024··
fix(deps): update to braces 3.0.3 (#1199)
1 parent 4088b41 commit 8d39186

File tree

3 files changed

+76
-66
lines changed

3 files changed

+76
-66
lines changed
 

‎dist/index.js

+62-52
Original file line numberDiff line numberDiff line change
@@ -46556,8 +46556,8 @@ const braces = (input, options = {}) => {
4655646556
let output = [];
4655746557

4655846558
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);
4656146561
if (Array.isArray(result)) {
4656246562
output.push(...result);
4656346563
} else {
@@ -46691,7 +46691,7 @@ braces.create = (input, options = {}) => {
4669146691
return [input];
4669246692
}
4669346693

46694-
return options.expand !== true
46694+
return options.expand !== true
4669546695
? braces.compile(input, options)
4669646696
: braces.expand(input, options);
4669746697
};
@@ -46715,50 +46715,53 @@ const fill = __nccwpck_require__(6330);
4671546715
const utils = __nccwpck_require__(5207);
4671646716

4671746717
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 ? '\\' : '';
4672346723
let output = '';
4672446724

4672546725
if (node.isOpen === true) {
4672646726
return prefix + node.value;
4672746727
}
46728+
4672846729
if (node.isClose === true) {
46730+
console.log('node.isClose', prefix, node.value);
4672946731
return prefix + node.value;
4673046732
}
4673146733

4673246734
if (node.type === 'open') {
46733-
return invalid ? (prefix + node.value) : '(';
46735+
return invalid ? prefix + node.value : '(';
4673446736
}
4673546737

4673646738
if (node.type === 'close') {
46737-
return invalid ? (prefix + node.value) : ')';
46739+
return invalid ? prefix + node.value : ')';
4673846740
}
4673946741

4674046742
if (node.type === 'comma') {
46741-
return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
46743+
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
4674246744
}
4674346745

4674446746
if (node.value) {
4674546747
return node.value;
4674646748
}
4674746749

4674846750
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 });
4675146753

4675246754
if (range.length !== 0) {
4675346755
return args.length > 1 && range.length > 1 ? `(${range})` : range;
4675446756
}
4675546757
}
4675646758

4675746759
if (node.nodes) {
46758-
for (let child of node.nodes) {
46760+
for (const child of node.nodes) {
4675946761
output += walk(child, node);
4676046762
}
4676146763
}
46764+
4676246765
return output;
4676346766
};
4676446767

@@ -46777,7 +46780,7 @@ module.exports = compile;
4677746780

4677846781

4677946782
module.exports = {
46780-
MAX_LENGTH: 1024 * 64,
46783+
MAX_LENGTH: 10000,
4678146784

4678246785
// Digits
4678346786
CHAR_0: '0', /* 0 */
@@ -46846,7 +46849,7 @@ const stringify = __nccwpck_require__(8750);
4684646849
const utils = __nccwpck_require__(5207);
4684746850

4684846851
const append = (queue = '', stash = '', enclose = false) => {
46849-
let result = [];
46852+
const result = [];
4685046853

4685146854
queue = [].concat(queue);
4685246855
stash = [].concat(stash);
@@ -46856,25 +46859,25 @@ const append = (queue = '', stash = '', enclose = false) => {
4685646859
return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
4685746860
}
4685846861

46859-
for (let item of queue) {
46862+
for (const item of queue) {
4686046863
if (Array.isArray(item)) {
46861-
for (let value of item) {
46864+
for (const value of item) {
4686246865
result.push(append(value, stash, enclose));
4686346866
}
4686446867
} else {
4686546868
for (let ele of stash) {
4686646869
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);
4686846871
}
4686946872
}
4687046873
}
4687146874
return utils.flatten(result);
4687246875
};
4687346876

4687446877
const expand = (ast, options = {}) => {
46875-
let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
46878+
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
4687646879

46877-
let walk = (node, parent = {}) => {
46880+
const walk = (node, parent = {}) => {
4687846881
node.queue = [];
4687946882

4688046883
let p = parent;
@@ -46896,7 +46899,7 @@ const expand = (ast, options = {}) => {
4689646899
}
4689746900

4689846901
if (node.nodes && node.ranges > 0) {
46899-
let args = utils.reduce(node.nodes);
46902+
const args = utils.reduce(node.nodes);
4690046903

4690146904
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
4690246905
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 = {}) => {
4691246915
return;
4691346916
}
4691446917

46915-
let enclose = utils.encloseBrace(node);
46918+
const enclose = utils.encloseBrace(node);
4691646919
let queue = node.queue;
4691746920
let block = node;
4691846921

@@ -46922,7 +46925,7 @@ const expand = (ast, options = {}) => {
4692246925
}
4692346926

4692446927
for (let i = 0; i < node.nodes.length; i++) {
46925-
let child = node.nodes[i];
46928+
const child = node.nodes[i];
4692646929

4692746930
if (child.type === 'comma' && node.type === 'brace') {
4692846931
if (i === 1) queue.push('');
@@ -46995,22 +46998,21 @@ const parse = (input, options = {}) => {
4699546998
throw new TypeError('Expected a string');
4699646999
}
4699747000

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;
4700047003
if (input.length > max) {
4700147004
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
4700247005
}
4700347006

47004-
let ast = { type: 'root', input, nodes: [] };
47005-
let stack = [ast];
47007+
const ast = { type: 'root', input, nodes: [] };
47008+
const stack = [ast];
4700647009
let block = ast;
4700747010
let prev = ast;
4700847011
let brackets = 0;
47009-
let length = input.length;
47012+
const length = input.length;
4701047013
let index = 0;
4701147014
let depth = 0;
4701247015
let value;
47013-
let memo = {};
4701447016

4701547017
/**
4701647018
* Helpers
@@ -47073,7 +47075,6 @@ const parse = (input, options = {}) => {
4707347075
if (value === CHAR_LEFT_SQUARE_BRACKET) {
4707447076
brackets++;
4707547077

47076-
let closed = true;
4707747078
let next;
4707847079

4707947080
while (index < length && (next = advance())) {
@@ -47129,7 +47130,7 @@ const parse = (input, options = {}) => {
4712947130
*/
4713047131

4713147132
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
47132-
let open = value;
47133+
const open = value;
4713347134
let next;
4713447135

4713547136
if (options.keepQuotes !== true) {
@@ -47161,8 +47162,8 @@ const parse = (input, options = {}) => {
4716147162
if (value === CHAR_LEFT_CURLY_BRACE) {
4716247163
depth++;
4716347164

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 = {
4716647167
type: 'brace',
4716747168
open: true,
4716847169
close: false,
@@ -47189,7 +47190,7 @@ const parse = (input, options = {}) => {
4718947190
continue;
4719047191
}
4719147192

47192-
let type = 'close';
47193+
const type = 'close';
4719347194
block = stack.pop();
4719447195
block.close = true;
4719547196

@@ -47207,7 +47208,7 @@ const parse = (input, options = {}) => {
4720747208
if (value === CHAR_COMMA && depth > 0) {
4720847209
if (block.ranges > 0) {
4720947210
block.ranges = 0;
47210-
let open = block.nodes.shift();
47211+
const open = block.nodes.shift();
4721147212
block.nodes = [open, { type: 'text', value: stringify(block) }];
4721247213
}
4721347214

@@ -47221,7 +47222,7 @@ const parse = (input, options = {}) => {
4722147222
*/
4722247223

4722347224
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
47224-
let siblings = block.nodes;
47225+
const siblings = block.nodes;
4722547226

4722647227
if (depth === 0 || siblings.length === 0) {
4722747228
push({ type: 'text', value });
@@ -47248,7 +47249,7 @@ const parse = (input, options = {}) => {
4724847249
if (prev.type === 'range') {
4724947250
siblings.pop();
4725047251

47251-
let before = siblings[siblings.length - 1];
47252+
const before = siblings[siblings.length - 1];
4725247253
before.value += prev.value + value;
4725347254
prev = before;
4725447255
block.ranges--;
@@ -47281,8 +47282,8 @@ const parse = (input, options = {}) => {
4728147282
});
4728247283

4728347284
// 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);
4728647287
// replace the (invalid) block with it's nodes
4728747288
parent.nodes.splice(index, 1, ...block.nodes);
4728847289
}
@@ -47306,9 +47307,9 @@ module.exports = parse;
4730647307
const utils = __nccwpck_require__(5207);
4730747308

4730847309
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;
4731247313
let output = '';
4731347314

4731447315
if (node.value) {
@@ -47323,7 +47324,7 @@ module.exports = (ast, options = {}) => {
4732347324
}
4732447325

4732547326
if (node.nodes) {
47326-
for (let child of node.nodes) {
47327+
for (const child of node.nodes) {
4732747328
output += stringify(child);
4732847329
}
4732947330
}
@@ -47374,7 +47375,7 @@ exports.exceedsLimit = (min, max, step = 1, limit) => {
4737447375
*/
4737547376

4737647377
exports.escapeNode = (block, n = 0, type) => {
47377-
let node = block.nodes[n];
47378+
const node = block.nodes[n];
4737847379
if (!node) return;
4737947380

4738047381
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
@@ -47443,13 +47444,23 @@ exports.reduce = nodes => nodes.reduce((acc, node) => {
4744347444

4744447445
exports.flatten = (...args) => {
4744547446
const result = [];
47447+
4744647448
const flat = arr => {
4744747449
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+
}
4745047460
}
4745147461
return result;
4745247462
};
47463+
4745347464
flat(args);
4745447465
return result;
4745547466
};
@@ -49907,7 +49918,7 @@ const toMaxLen = (input, maxLength) => {
4990749918
return negative ? ('-' + input) : input;
4990849919
};
4990949920

49910-
const toSequence = (parts, options) => {
49921+
const toSequence = (parts, options, maxLen) => {
4991149922
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
4991249923
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
4991349924

@@ -49917,11 +49928,11 @@ const toSequence = (parts, options) => {
4991749928
let result;
4991849929

4991949930
if (parts.positives.length) {
49920-
positives = parts.positives.join('|');
49931+
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
4992149932
}
4992249933

4992349934
if (parts.negatives.length) {
49924-
negatives = `-(${prefix}${parts.negatives.join('|')})`;
49935+
negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
4992549936
}
4992649937

4992749938
if (positives && negatives) {
@@ -50019,7 +50030,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
5001950030

5002050031
if (options.toRegex === true) {
5002150032
return step > 1
50022-
? toSequence(parts, options)
50033+
? toSequence(parts, options, maxLen)
5002350034
: toRegex(range, null, { wrap: false, ...options });
5002450035
}
5002550036

@@ -50031,7 +50042,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
5003150042
return invalidRange(start, end, options);
5003250043
}
5003350044

50034-
5003550045
let format = options.transform || (val => String.fromCharCode(val));
5003650046
let a = `${start}`.charCodeAt(0);
5003750047
let b = `${end}`.charCodeAt(0);

‎examples/webpack/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.