Socket
Socket
Sign inDemoInstall

nopt

Package Overview
Dependencies
1
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.8 to 1.0.9

34

lib/nopt.js

@@ -53,3 +53,5 @@ // info about each config option.

, typeDefault = [false, true, null, String, Number]
Object.keys(data).forEach(function (k) {
if (k === "argv") return
var val = data[k]

@@ -82,5 +84,13 @@ , isArray = Array.isArray(val)

}
if (!types.hasOwnProperty(k)) {
return val
}
// allow `--no-blah` to set 'blah' to null if null is allowed
if (val === false && ~type.indexOf(null) &&
!(~type.indexOf(false) || ~type.indexOf(Boolean))) {
val = null
}
var d = {}

@@ -247,5 +257,2 @@ d[k] = val

var isBool = no || types[arg] === Boolean ||
Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1
var isArray = types[arg] === Array ||

@@ -255,3 +262,11 @@ Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1

var val
, la = args[i + 1]
var isBool = no ||
types[arg] === Boolean ||
Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 ||
(la === "false" &&
(types[arg] === null ||
Array.isArray(types[arg]) && ~types[arg].indexOf(null)))
if (isBool) {

@@ -261,3 +276,2 @@ // just set and move along

// however, also support --bool true or --bool false
var la = args[i + 1]
if (la === "true" || la === "false") {

@@ -299,3 +313,2 @@ val = JSON.parse(la)

var la = args[i + 1]
if (la && la.match(/^-{2,}$/)) {

@@ -305,2 +318,3 @@ la = undefined

}
val = la === undefined ? true : la

@@ -382,4 +396,4 @@ if (isArray) (data[arg] = data[arg] || []).push(val)

, types =
{ argv : NaN
, aoa: Array
{ aoa: Array
, nullstream: [null, Stream]
, str: String

@@ -503,2 +517,8 @@ , browser : String

,[]]
,["--no-nullstream"
,{nullstream:null}
,[]]
,["--nullstream false"
,{nullstream:null}
,[]]
].forEach(function (test) {

@@ -505,0 +525,0 @@ var argv = test[0].split(/\s+/)

{ "name" : "nopt"
, "version" : "1.0.8"
, "version" : "1.0.9"
, "description" : "Option parsing for Node, supporting types, shorthands, etc. Used by npm."

@@ -4,0 +4,0 @@ , "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc