24 lines
535 B
JavaScript
24 lines
535 B
JavaScript
export function fastApply(holder, fn, args) {
|
|
if (holder || args.length > 5) {
|
|
return fn.apply(holder, args);
|
|
}
|
|
if (0 === args.length) {
|
|
return fn();
|
|
}
|
|
if (1 === args.length) {
|
|
return fn(args[0]);
|
|
}
|
|
if (2 === args.length) {
|
|
return fn(args[0], args[1]);
|
|
}
|
|
if (3 === args.length) {
|
|
return fn(args[0], args[1], args[2]);
|
|
}
|
|
if (4 === args.length) {
|
|
return fn(args[0], args[1], args[2], args[3]);
|
|
}
|
|
if (5 === args.length) {
|
|
return fn(args[0], args[1], args[2], args[3], args[4]);
|
|
}
|
|
}
|