summaryrefslogtreecommitdiff
path: root/node_modules/braces/lib/utils.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-08-30 17:21:18 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-08-30 17:21:18 +0800
commitefbc2ffe6a1ee5ec38a4396305561d6515d0943e (patch)
tree2b4c94f18f2c792dfda813050755d5c0273fae22 /node_modules/braces/lib/utils.js
parent43acceb75957c880a5ba5a31aae221394a36d5f6 (diff)
node fixes, updates
Diffstat (limited to 'node_modules/braces/lib/utils.js')
-rw-r--r--node_modules/braces/lib/utils.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/node_modules/braces/lib/utils.js b/node_modules/braces/lib/utils.js
index e3551a67..d19311fe 100644
--- a/node_modules/braces/lib/utils.js
+++ b/node_modules/braces/lib/utils.js
@@ -31,7 +31,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') {
@@ -100,13 +100,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;
};