Remove argument juggling from _.before.

This commit is contained in:
John-David Dalton
2015-07-29 23:22:13 -07:00
parent b17f6eee6a
commit 693704a832
2 changed files with 1 additions and 19 deletions

View File

@@ -6648,13 +6648,7 @@
function before(n, func) {
var result;
if (typeof func != 'function') {
if (typeof n == 'function') {
var temp = n;
n = func;
func = temp;
} else {
throw new TypeError(FUNC_ERROR_TEXT);
}
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
if (--n > 0) {

View File

@@ -1190,18 +1190,6 @@
deepEqual(actual, expected);
});
test('should allow `func` as the first argument', 1, function() {
var count = 0;
try {
var before = _.before(function() { count++; }, 2);
before();
before();
} catch(e) {}
strictEqual(count, 1);
});
test('should not set a `this` binding', 2, function() {
var before = _.before(2, function() { return ++this.count; }),
object = { 'count': 0, 'before': before };