- Notifications
You must be signed in to change notification settings - Fork2
Simply swizzle your arguments
License
Qix-/node-simple-swizzle
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
NOTE:
⚠️ Don't use this package in new projects. It is ahuge 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, pleasereally reconsider your API's design.
Swizzle your function arguments; pass in mixed arrays/values and get a clean array
varswizzle=require('simple-swizzle');functionmyFunc(){varargs=swizzle(arguments);// ...returnargs;}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 passedthe resulting array.
varswizzle=require('simple-swizzle');varswizzledFn=swizzle.wrap(function(args){// ...returnargs;});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 theMIT License.You can find a copy of it inLICENSE.
About
Simply swizzle your arguments
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.