feat: core.fastApply

This commit is contained in:
cha0s 2019-05-02 20:55:14 -05:00
parent 2be6729f20
commit be5fdb1d82
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,23 @@
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]);
}
}

View File

@ -69,4 +69,5 @@ export class TickingPromise extends Promise {
}
export {EventEmitterMixin as EventEmitter} from './event-emitter';
export {fastApply} from './fast-apply';
export {PropertyMixin as Property} from './property';