Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Readme
Probably the sole command line option parser you'll ever need to Ctrl+C, Ctrl+V. Proof:npm install optjs
function opt(argv) {
var opt={},arg,p;argv=Array.prototype.slice.call(argv||process.argv);for(var i=2;i<argv.length;i++)if(argv[i].charAt(0)=='-')
((p=(arg=(""+argv.splice(i--,1)).replace(/^[\-]+/,'')).indexOf("="))>0?opt[arg.substring(0,p)]=arg.substring(p+1):opt[arg]=true);
return {'node':argv[0],'script':argv[1],'argv':argv.slice(2),'opt':opt};
}
var opt = require("optjs")();
console.log(opt.node); // Path to node executable
console.log(opt.script); // Path to the current script
console.log(opt.opt); // Command line options as a hash
console.log(opt.argv); // Remaining non-option arguments
node somescript.js foo -a=1 -b --c="hello world" bar ----d
// Result
opt.node == "/path/to/node[.exe]"
opt.script == "/path/to/somescript.js"
opt.opt == { a: 1, b: true, c: "hello world", d: true }
opt.argv == ["foo", "bar"]
#!/usr/bin/env node
console.log(require("./opt.js")());
MIT
FAQs
Probably the sole command line option parser you'll ever need to...
The npm package optjs receives a total of 168,388 weekly downloads. As such, optjs popularity was classified as popular.
We found that optjs 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.