Skip to content

Instantly share code, notes, and snippets.

@jed
Created May 1, 2010 00:17
Show Gist options
  • Save jed/385918 to your computer and use it in GitHub Desktop.
Save jed/385918 to your computer and use it in GitHub Desktop.
// async: manually sets the length of a function by wrapping it in another with the desired length
fab.arity = function( num ) {
var fn = function(_){ fn.apply( this, arguments ) }
, ends = [ "this(", ")" ]
, args = [];
while ( --num ) args[ num - 1 ] = "_" + num;
this( Function( "fn", ends.join( fn ).replace( "_", args ) ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment