Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

argsparser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argsparser - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

Makefile

23

lib/argsparser.js

@@ -11,13 +11,11 @@ /**

var opts = {},
curSwitch;
var opts = {}, curSwitch;
args.forEach(function(arg) {
var curValType = typeof opts[curSwitch];
// its a switch
if (/^(-|--)/.test(arg)) {
if (/^(-|--)/.test(arg) || !curSwitch) {
opts[arg] = true;
curSwitch = arg;
// this arg is some data
} else if (curSwitch) {
// this arg is a data
} else {
if (arg === 'false') {

@@ -31,12 +29,11 @@ arg = false;

if (curValType === 'boolean') {
// it was a boolean switch per default,
// now it has got a val
if (typeof opts[curSwitch] === 'boolean') {
opts[curSwitch] = arg;
} else if (curValType === 'string') {
} else if (Array.isArray(opts[curSwitch])) {
opts[curSwitch].push(arg);
} else {
opts[curSwitch] = [opts[curSwitch], arg];
} else {
opts[curSwitch].push(arg);
}
} else {
opts[arg] = true;
curSwitch = arg;
}

@@ -43,0 +40,0 @@ });

{
"name": "argsparser",
"description": "A tiny command line arguments parser",
"version": "0.0.5",
"version": "0.0.6",
"author": "Oleg Slobodskoi <oleg008@gmail.com>",

@@ -6,0 +6,0 @@ "repository": {

@@ -37,2 +37,4 @@ var a = require('assert'),

a.deepEqual(parse(['--port', '80', '8080']), {'--port': [80, 8080]}, 'node server.js --port 80 8080');
util.print('All tests ok\n');
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc