fast-args
v1.0.0
Published
Very fast way to turn a function's `arguments` into an array.
Downloads
60
Maintainers
Readme
fast-args
Very fast way to turn a function's
arguments
into an array.
var fargs = require('fast-args');
function foo() {
return fargs(arguments);
}
foo(1, 2, 3);
// => [1, 2, 3]
Most functions don't get called with more than 6 params, so this module uses a switch for manually making an array when arguments.length
is 1 through 6. It can fall back on a fast slice for any number of params higher than 6.
Note: This module is best for ES5 and below. Use rest parameters for the fastest method (by far) in ES6+.
Installation
$ npm install --save fast-args
API
fargs(args, [offset])
Turn the arguments
object of a function into an array.
args
(arguments
): Thearguments
object of a function.offset
(Number
): The index to start onarguments
.
var fargs = require('fast-args');
function foo() {
var args = fargs(arguments, 1);
// ...
}
This is the only export of the module.
Meta
npm test
: Run tests.npm run bench
: Run benchmarks.
License
MIT © Jamen Marz