Area restrita - Questionario

This commit is contained in:
2026-06-08 23:50:59 -03:00
parent f2e2400637
commit ef968f10ae
6972 changed files with 23454 additions and 2267883 deletions
+11 -13
View File
@@ -62,13 +62,10 @@ function parseCommaParts(str) {
return parts;
}
function expandTop(str, options) {
function expandTop(str) {
if (!str)
return [];
options = options || {};
var max = options.max == null ? Infinity : options.max;
// I don't know why Bash 4.3 does this, but it does.
// Anything starting with {} will have the first two bytes preserved
// but *only* at the top level, so {},a}b will not expand to anything,
@@ -79,7 +76,7 @@ function expandTop(str, options) {
str = '\\{\\}' + str.substr(2);
}
return expand(escapeBraces(str), max, true).map(unescapeBraces);
return expand(escapeBraces(str), true).map(unescapeBraces);
}
function identity(e) {
@@ -100,7 +97,7 @@ function gte(i, y) {
return i >= y;
}
function expand(str, max, isTop) {
function expand(str, isTop) {
var expansions = [];
var m = balanced('{', '}', str);
@@ -114,7 +111,7 @@ function expand(str, max, isTop) {
// {a},b}
if (m.post.match(/,(?!,).*\}/)) {
str = m.pre + '{' + m.body + escClose + m.post;
return expand(str, max, true);
return expand(str);
}
return [str];
}
@@ -126,10 +123,10 @@ function expand(str, max, isTop) {
n = parseCommaParts(m.body);
if (n.length === 1) {
// x{{a,b}}y ==> x{a}y x{b}y
n = expand(n[0], max, false).map(embrace);
n = expand(n[0], false).map(embrace);
if (n.length === 1) {
var post = m.post.length
? expand(m.post, max, false)
? expand(m.post, false)
: [''];
return post.map(function(p) {
return m.pre + n[0] + p;
@@ -144,7 +141,7 @@ function expand(str, max, isTop) {
// no need to expand pre, since it is guaranteed to be free of brace-sets
var pre = m.pre;
var post = m.post.length
? expand(m.post, max, false)
? expand(m.post, false)
: [''];
var N;
@@ -154,7 +151,7 @@ function expand(str, max, isTop) {
var y = numeric(n[1]);
var width = Math.max(n[0].length, n[1].length)
var incr = n.length == 3
? Math.max(Math.abs(numeric(n[2])), 1)
? Math.abs(numeric(n[2]))
: 1;
var test = lte;
var reverse = y < x;
@@ -188,11 +185,11 @@ function expand(str, max, isTop) {
N.push(c);
}
} else {
N = concatMap(n, function(el) { return expand(el, max, false) });
N = concatMap(n, function(el) { return expand(el, false) });
}
for (var j = 0; j < N.length; j++) {
for (var k = 0; k < post.length && expansions.length < max; k++) {
for (var k = 0; k < post.length; k++) {
var expansion = pre + N[j] + post[k];
if (!isTop || isSequence || expansion)
expansions.push(expansion);
@@ -201,3 +198,4 @@ function expand(str, max, isTop) {
return expansions;
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "brace-expansion",
"description": "Brace expansion as known from sh/bash",
"version": "1.1.14",
"version": "1.1.12",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/brace-expansion.git"