simple-swizzle
Simply swizzle your arguments
Last updated a year ago by qix .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install simple-swizzle 
SYNC missed versions from official npm registry.

NOTE: ⚠️ Don't use this package in new projects. It is a huge anti-pattern and will only confuse and annoy people who use whatever code you write with it. I wrote this in a time when Javascript and Node.js were still pretty experimental and clever things like this weren't frowned upon. I've also learned a LOT about proper API design since I wrote this package. DO. NOT. USE. THIS. PACKAGE. If you're reaching for it, please really reconsider your API's design.


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.

Current Tags

  • 0.2.4                                ...           latest (a year ago)

5 Versions

  • 0.2.4                                ...           a year ago
  • 0.2.2                                ...           10 years ago
  • 0.2.1                                ...           11 years ago
  • 0.2.0 [deprecated]           ...           11 years ago
  • 0.1.0 [deprecated]           ...           11 years ago
Maintainers (1)
Downloads
Total 18
Today 0
This Week 0
This Month 7
Last Day 0
Last Week 1
Last Month 0
Dependencies (1)
Dev Dependencies (6)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE