kaguranana-birthday-project/node_modules/simple-swizzle
2021-12-12 18:49:32 -08:00
..
node_modules/is-arrayish initial 2021-12-12 18:49:32 -08:00
index.js initial 2021-12-12 18:49:32 -08:00
LICENSE initial 2021-12-12 18:49:32 -08:00
package.json initial 2021-12-12 18:49:32 -08:00
README.md initial 2021-12-12 18:49:32 -08:00

simple-swizzle Travis-CI.org Build Status Coveralls.io Coverage Rating

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.