UNPKG

pp-parachute

Version:
23 lines (21 loc) 839 B
var fastbind = function(fn, ctx) { return function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { switch(arguments.length) { case 0: return fn.call(ctx); case 1: return fn.call(ctx, arg0); case 2: return fn.call(ctx, arg0, arg1); case 3: return fn.call(ctx, arg0, arg1, arg2); case 4: return fn.call(ctx, arg0, arg1, arg2, arg3); case 5: return fn.call(ctx, arg0, arg1, arg2, arg3, arg4); case 6: return fn.call(ctx, arg0, arg1, arg2, arg3, arg4, arg5); case 7: return fn.call(ctx, arg0, arg1, arg2, arg3, arg4, arg5, arg6); default: return fn.apply(ctx, arguments); } } }; fastbind.setBinding = function(ctx) { return function(fn) { return fastbind(fn, ctx); }; }; module.exports = fastbind;