Skip to content

Commit

Permalink
refactor(parse): simplify the Parser's filter function
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalfaso authored and rodyhaddad committed Jun 4, 2014
1 parent f7a0a38 commit 6fb121e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,21 +542,17 @@ Parser.prototype = {
var token = this.expect();
var fn = this.$filter(token.text);
var argsFn = [];
while (true) {
if ((token = this.expect(':'))) {
argsFn.push(this.expression());
} else {
var fnInvoke = function(self, locals, input) {
var args = [input];
for (var i = 0; i < argsFn.length; i++) {
args.push(argsFn[i](self, locals));
}
return fn.apply(self, args);
};
return function() {
return fnInvoke;
};
while(this.expect(':')) {
argsFn.push(this.expression());
}
return valueFn(fnInvoke);

function fnInvoke(self, locals, input) {
var args = [input];
for (var i = 0; i < argsFn.length; i++) {
args.push(argsFn[i](self, locals));
}
return fn.apply(self, args);
}
},

Expand Down

0 comments on commit 6fb121e

Please sign in to comment.