feat: core.fastApply
This commit is contained in:
parent
2be6729f20
commit
be5fdb1d82
23
packages/core/fast-apply.js
Normal file
23
packages/core/fast-apply.js
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -69,4 +69,5 @@ export class TickingPromise extends Promise {
|
||||||
}
|
}
|
||||||
|
|
||||||
export {EventEmitterMixin as EventEmitter} from './event-emitter';
|
export {EventEmitterMixin as EventEmitter} from './event-emitter';
|
||||||
|
export {fastApply} from './fast-apply';
|
||||||
export {PropertyMixin as Property} from './property';
|
export {PropertyMixin as Property} from './property';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user