
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Simple utility for parsing/processing variable length argument lists for Javascript functions; also verifies argument types and argument list length.
Bower - bower install getargs; NPM - npm install getargs.
var getArgs = require('getargs')
function ajax(/* url:string|array, [options]:object, callback:function */){
var args = getArgs('url:string|array, [options]:object, callback:function', arguments)
console.log('url is', args.url)
console.log('options is optionally', args.options)
console.log('callback', args.callback)
}
The argument spec is a comma delimited string of individual specs, which look like
argname:type
You can specify multiple types by using |
argname:type|type|type
argname is the name of the argument, and can be called anythingtype is an optional basic Javascript type. Currently these are supported
stringbooleannumberobjectfunctionarrayTo denote optional arguments, you'd surround argname with square brackets [].
getArgs will throw if the arguments have the wrong types
var args = getArgs('url:string', [1])
// Error: Expected url(pos 0) to be a string
getArgs will throw if there are too many or too few arguments
> getArgs('a,b', [1])
Error: Not enough arguments, expected 2, got 1
> getArgs('a,b', [1,1])
{ a: 1, b: 1 }
> getArgs('a,b', [1,1,1])
Error: Too many arguments, expected 2, got 3
You can mimick ES6's spread operator
var args = getArgs('first,...rest', [1,2,3,4])
console.log(args.first) // 1
console.log(args.rest) // [2,3,4]
If you pass an object as its third argument, it will set the arguments as properties on that object.
getArgs('a,b,c', arguments, this)
// Now you can access the arguments by
// this.a, this.b, and this.c
FAQs
Utility to handle optional arguments and argument type checking.
We found that getargs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.