This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!function(){ | |
function fakeLength(fn, length) { | |
if (length == fn.length) return fn; | |
var fakeArgs = []; | |
while(length--) fakeArgs.push('$fakeArg'+length); | |
return eval('(function('+fakeArgs.join(',')+'){ return fn.apply(this, arguments); })'); | |
} | |
Function.prototype.allRequired = function(){ | |
var fn = this, | |
wrapped = function(){ | |
if (arguments.length >= fn.length) | |
return fn.apply(this, arguments); | |
else | |
throw new Error('Oh Shit...'); | |
}; | |
return fakeLength(wrapped, fn.length); | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment