Skip to content

Commit

Permalink
Support _.flip as a method combinator.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacc committed Apr 12, 2014
1 parent 648488b commit 8cd7f42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/function.combinators.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ $(document).ready(function() {
var echo = function() { return Array.prototype.slice.call(arguments, 0); };

deepEqual(_.flip(echo)(1, 2, 3, 4), [4, 3, 2, 1], 'should return a function that flips the first three or more args to a function');

var obj = {
num: 5,
addToNum: function (a, b) { return [a + this.num, b + this.num]; }
};

obj.reversedAddToNum = _.flip(obj.addToNum);

deepEqual(obj.reversedAddToNum(1, 2), [7, 6], 'should function as a method combinator.');
});

test("fnull", function() {
Expand Down
2 changes: 1 addition & 1 deletion underscore.function.combinators.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
return function(/* args */) {
var reversed = __reverse.call(arguments);

return fun.apply(null, reversed);
return fun.apply(this, reversed);
};
},

Expand Down

0 comments on commit 8cd7f42

Please sign in to comment.