Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Apr 10, 2022. It is now read-only.

Simply swizzle your arguments

License

NotificationsYou must be signed in to change notification settings

Qix-/node-simple-swizzle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Usage

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]

License

Licensed under theMIT License.You can find a copy of it inLICENSE.

About

Simply swizzle your arguments

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp