simple-swizzle
![Coveralls.io Coverage Rating](https://camo.githubusercontent.com/96c864c213e15054ad279004f5afffa589acab78d8ba60b560bbbee6121e8694/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f5169782d2f6e6f64652d73696d706c652d7377697a7a6c652e7376673f7374796c653d666c61742d737175617265)
Swizzle your function arguments; pass in mixed arrays/values and get a clean array
Usage
var swizzle = require('simple-swizzle');
function myFunc() {
var args = swizzle(arguments);
// ...
return args;
}
myFunc(1, [2, 3], 4); // [1, 2, 3, 4]
myFunc(1, 2, 3, 4); // [1, 2, 3, 4]
myFunc([1, 2, 3, 4]); // [1, 2, 3, 4]
Functions can also be wrapped to automatically swizzle arguments and be passed the resulting array.
var swizzle = require('simple-swizzle');
var swizzledFn = swizzle.wrap(function (args) {
// ...
return args;
});
swizzledFn(1, [2, 3], 4); // [1, 2, 3, 4]
swizzledFn(1, 2, 3, 4); // [1, 2, 3, 4]
swizzledFn([1, 2, 3, 4]); // [1, 2, 3, 4]
License
Licensed under the MIT License. You can find a copy of it in LICENSE.