You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Björn
b963b3396c
|
4 years ago | |
---|---|---|
.. | ||
node_modules/is-arrayish | 4 years ago | |
LICENSE | 4 years ago | |
README.md | 4 years ago | |
index.js | 4 years ago | |
package.json | 4 years ago |
README.md
simple-swizzle
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.