fast-apply
Version:
Apply an array of arguments... faster
37 lines (21 loc) • 826 B
Markdown
var fastApply = require('fast-apply')
, scope = {}
;
function run() {}
fastApply(run, scope, [ 'a', 'b', 'c' ]);
```
$ npm install fast-apply
none
It uses a simple switch statement to `call` the function rather than `apply` for up to 5 arguments.
While more than 5 arguments would run faster using `apply`, anything less will be
[ ](http://jsperf.com/many-arguments-apply-vs-switch/2)
If the scope is `null`, fastApply will run up to 3 times faster than `apply`
- It is only optimized for 5 arguments or less. If you think the function will frequently be taking
more than 5 arguments, I suggest that you instead use `apply`
Apply an array of arguments... faster.
```javascript