caoge c760052ff9 机车状态修改 | 8 bulan lalu | |
---|---|---|
.. | ||
node_modules | 8 bulan lalu | |
LICENSE | 8 bulan lalu | |
README.md | 8 bulan lalu | |
index.js | 8 bulan lalu | |
package.json | 8 bulan lalu |
Swizzle your function arguments; pass in mixed arrays/values and get a clean array
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]
Licensed under the MIT License. You can find a copy of it in LICENSE.