prefer the include() helper to 'in', except for array literals.

This commit is contained in:
Jeremy Ashkenas 2010-08-08 17:41:10 -04:00
parent 18d6fd72de
commit 3eda5a2e85
2 changed files with 5 additions and 5 deletions

View File

@ -41,7 +41,7 @@
return true;
};
Rewriter.prototype.detectEnd = function(i, condition, action) {
var _c, _d, _e, _f, _g, _h, levels, token;
var levels, token;
levels = 0;
while (true) {
if (!(token = this.tokens[i])) {
@ -50,10 +50,10 @@
if (!levels && condition(token, i)) {
return action(token, i);
}
if ((function(){ (_c = token[0]); for (var _d=0, _e=EXPRESSION_START.length; _d<_e; _d++) { if (EXPRESSION_START[_d] === _c) return true; } return false; }).call(this)) {
if (include(EXPRESSION_START, token[0])) {
levels += 1;
}
if ((function(){ (_f = token[0]); for (var _g=0, _h=EXPRESSION_END.length; _g<_h; _g++) { if (EXPRESSION_END[_g] === _f) return true; } return false; }).call(this)) {
if (include(EXPRESSION_END, token[0])) {
levels -= 1;
}
i += 1;

View File

@ -59,8 +59,8 @@ exports.Rewriter = class Rewriter
loop
break unless token = @tokens[i]
return action token, i if !levels and condition token, i
levels += 1 if token[0] in EXPRESSION_START
levels -= 1 if token[0] in EXPRESSION_END
levels += 1 if include EXPRESSION_START, token[0]
levels -= 1 if include EXPRESSION_END, token[0]
i += 1
i - 1