correct spacing around operators in slice output
This commit is contained in:
parent
b8149812cd
commit
972a5299d5
|
@ -535,7 +535,7 @@
|
|||
case end:
|
||||
stack.pop();
|
||||
if (!stack.length) {
|
||||
return str.slice(0, +i+1 || 9e9);
|
||||
return str.slice(0, +i + 1 || 9e9);
|
||||
}
|
||||
end = stack[stack.length - 1];
|
||||
continue;
|
||||
|
|
|
@ -1151,7 +1151,7 @@
|
|||
fromStr = from && from.compile(o, LEVEL_PAREN) || '0';
|
||||
compiled = to && to.compile(o, LEVEL_PAREN);
|
||||
if (to && !(!this.range.exclusive && +compiled === -1)) {
|
||||
toStr = ', ' + (this.range.exclusive ? compiled : SIMPLENUM.test(compiled) ? "" + (+compiled + 1) : (compiled = to.compile(o, LEVEL_ACCESS), "+" + compiled + "+1 || 9e9"));
|
||||
toStr = ', ' + (this.range.exclusive ? compiled : SIMPLENUM.test(compiled) ? "" + (+compiled + 1) : (compiled = to.compile(o, LEVEL_ACCESS), "+" + compiled + " + 1 || 9e9"));
|
||||
}
|
||||
return ".slice(" + fromStr + (toStr || '') + ")";
|
||||
};
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
startIndex = 0;
|
||||
condition = function(token, i) {
|
||||
var one, tag, three, two, _ref, _ref1;
|
||||
_ref = this.tokens.slice(i + 1, +(i + 3)+1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
|
||||
_ref = this.tokens.slice(i + 1, +(i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
|
||||
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@
|
|||
if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') {
|
||||
noCall = true;
|
||||
}
|
||||
_ref = tokens.slice(i - 1, +(i + 1)+1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
||||
_ref = tokens.slice(i - 1, +(i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
||||
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0);
|
||||
seenSingle = false;
|
||||
seenControl = false;
|
||||
|
|
|
@ -787,7 +787,7 @@ exports.Slice = class Slice extends Base
|
|||
"#{+compiled + 1}"
|
||||
else
|
||||
compiled = to.compile o, LEVEL_ACCESS
|
||||
"+#{compiled}+1 || 9e9"
|
||||
"+#{compiled} + 1 || 9e9"
|
||||
".slice(#{ fromStr }#{ toStr or '' })"
|
||||
|
||||
#### Obj
|
||||
|
|
|
@ -61,7 +61,7 @@ test "#1722: operator precedence in unbounded slice compilation", ->
|
|||
arrayEq [0..n], list[..n or 0]
|
||||
arrayEq [0..n], list[..if n then n else 0]
|
||||
|
||||
test "#2349: slicing to numeric strings", ->
|
||||
test "#2349: inclusive slicing to numeric strings", ->
|
||||
arrayEq [0, 1], [0..10][.."1"]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue