Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update to braces 3.0.3 #1199

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 62 additions & 52 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46556,8 +46556,8 @@ const braces = (input, options = {}) => {
let output = [];

if (Array.isArray(input)) {
for (let pattern of input) {
let result = braces.create(pattern, options);
for (const pattern of input) {
const result = braces.create(pattern, options);
if (Array.isArray(result)) {
output.push(...result);
} else {
Expand Down Expand Up @@ -46691,7 +46691,7 @@ braces.create = (input, options = {}) => {
return [input];
}

return options.expand !== true
return options.expand !== true
? braces.compile(input, options)
: braces.expand(input, options);
};
Expand All @@ -46715,50 +46715,53 @@ const fill = __nccwpck_require__(6330);
const utils = __nccwpck_require__(5207);

const compile = (ast, options = {}) => {
let walk = (node, parent = {}) => {
let invalidBlock = utils.isInvalidBrace(parent);
let invalidNode = node.invalid === true && options.escapeInvalid === true;
let invalid = invalidBlock === true || invalidNode === true;
let prefix = options.escapeInvalid === true ? '\\' : '';
const walk = (node, parent = {}) => {
const invalidBlock = utils.isInvalidBrace(parent);
const invalidNode = node.invalid === true && options.escapeInvalid === true;
const invalid = invalidBlock === true || invalidNode === true;
const prefix = options.escapeInvalid === true ? '\\' : '';
let output = '';

if (node.isOpen === true) {
return prefix + node.value;
}

if (node.isClose === true) {
console.log('node.isClose', prefix, node.value);
return prefix + node.value;
}

if (node.type === 'open') {
return invalid ? (prefix + node.value) : '(';
return invalid ? prefix + node.value : '(';
}

if (node.type === 'close') {
return invalid ? (prefix + node.value) : ')';
return invalid ? prefix + node.value : ')';
}

if (node.type === 'comma') {
return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
}

if (node.value) {
return node.value;
}

if (node.nodes && node.ranges > 0) {
let args = utils.reduce(node.nodes);
let range = fill(...args, { ...options, wrap: false, toRegex: true });
const args = utils.reduce(node.nodes);
const range = fill(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });

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

if (node.nodes) {
for (let child of node.nodes) {
for (const child of node.nodes) {
output += walk(child, node);
}
}

return output;
};

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


module.exports = {
MAX_LENGTH: 1024 * 64,
MAX_LENGTH: 10000,

// Digits
CHAR_0: '0', /* 0 */
Expand Down Expand Up @@ -46846,7 +46849,7 @@ const stringify = __nccwpck_require__(8750);
const utils = __nccwpck_require__(5207);

const append = (queue = '', stash = '', enclose = false) => {
let result = [];
const result = [];

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

for (let item of queue) {
for (const item of queue) {
if (Array.isArray(item)) {
for (let value of item) {
for (const value of item) {
result.push(append(value, stash, enclose));
}
} else {
for (let ele of stash) {
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
}
}
}
return utils.flatten(result);
};

const expand = (ast, options = {}) => {
let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;

let walk = (node, parent = {}) => {
const walk = (node, parent = {}) => {
node.queue = [];

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

if (node.nodes && node.ranges > 0) {
let args = utils.reduce(node.nodes);
const args = utils.reduce(node.nodes);

if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
Expand All @@ -46912,7 +46915,7 @@ const expand = (ast, options = {}) => {
return;
}

let enclose = utils.encloseBrace(node);
const enclose = utils.encloseBrace(node);
let queue = node.queue;
let block = node;

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

for (let i = 0; i < node.nodes.length; i++) {
let child = node.nodes[i];
const child = node.nodes[i];

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

let opts = options || {};
let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
const opts = options || {};
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
if (input.length > max) {
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
}

let ast = { type: 'root', input, nodes: [] };
let stack = [ast];
const ast = { type: 'root', input, nodes: [] };
const stack = [ast];
let block = ast;
let prev = ast;
let brackets = 0;
let length = input.length;
const length = input.length;
let index = 0;
let depth = 0;
let value;
let memo = {};

/**
* Helpers
Expand Down Expand Up @@ -47073,7 +47075,6 @@ const parse = (input, options = {}) => {
if (value === CHAR_LEFT_SQUARE_BRACKET) {
brackets++;

let closed = true;
let next;

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

if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
let open = value;
const open = value;
let next;

if (options.keepQuotes !== true) {
Expand Down Expand Up @@ -47161,8 +47162,8 @@ const parse = (input, options = {}) => {
if (value === CHAR_LEFT_CURLY_BRACE) {
depth++;

let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
let brace = {
const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
const brace = {
type: 'brace',
open: true,
close: false,
Expand All @@ -47189,7 +47190,7 @@ const parse = (input, options = {}) => {
continue;
}

let type = 'close';
const type = 'close';
block = stack.pop();
block.close = true;

Expand All @@ -47207,7 +47208,7 @@ const parse = (input, options = {}) => {
if (value === CHAR_COMMA && depth > 0) {
if (block.ranges > 0) {
block.ranges = 0;
let open = block.nodes.shift();
const open = block.nodes.shift();
block.nodes = [open, { type: 'text', value: stringify(block) }];
}

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

if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
let siblings = block.nodes;
const siblings = block.nodes;

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

let before = siblings[siblings.length - 1];
const before = siblings[siblings.length - 1];
before.value += prev.value + value;
prev = before;
block.ranges--;
Expand Down Expand Up @@ -47281,8 +47282,8 @@ const parse = (input, options = {}) => {
});

// get the location of the block on parent.nodes (block's siblings)
let parent = stack[stack.length - 1];
let index = parent.nodes.indexOf(block);
const parent = stack[stack.length - 1];
const index = parent.nodes.indexOf(block);
// replace the (invalid) block with it's nodes
parent.nodes.splice(index, 1, ...block.nodes);
}
Expand All @@ -47306,9 +47307,9 @@ module.exports = parse;
const utils = __nccwpck_require__(5207);

module.exports = (ast, options = {}) => {
let stringify = (node, parent = {}) => {
let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
let invalidNode = node.invalid === true && options.escapeInvalid === true;
const stringify = (node, parent = {}) => {
const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
const invalidNode = node.invalid === true && options.escapeInvalid === true;
let output = '';

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

if (node.nodes) {
for (let child of node.nodes) {
for (const child of node.nodes) {
output += stringify(child);
}
}
Expand Down Expand Up @@ -47374,7 +47375,7 @@ exports.exceedsLimit = (min, max, step = 1, limit) => {
*/

exports.escapeNode = (block, n = 0, type) => {
let node = block.nodes[n];
const node = block.nodes[n];
if (!node) return;

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

exports.flatten = (...args) => {
const result = [];

const flat = arr => {
for (let i = 0; i < arr.length; i++) {
let ele = arr[i];
Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
const ele = arr[i];

if (Array.isArray(ele)) {
flat(ele);
continue;
}

if (ele !== undefined) {
result.push(ele);
}
}
return result;
};

flat(args);
return result;
};
Expand Down Expand Up @@ -49907,7 +49918,7 @@ const toMaxLen = (input, maxLength) => {
return negative ? ('-' + input) : input;
};

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

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

if (parts.positives.length) {
positives = parts.positives.join('|');
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
}

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

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

if (options.toRegex === true) {
return step > 1
? toSequence(parts, options)
? toSequence(parts, options, maxLen)
: toRegex(range, null, { wrap: false, ...options });
}

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


let format = options.transform || (val => String.fromCharCode(val));
let a = `${start}`.charCodeAt(0);
let b = `${end}`.charCodeAt(0);
Expand Down
14 changes: 7 additions & 7 deletions examples/webpack/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading