Socket
Socket
Sign inDemoInstall

optimist

Package Overview
Dependencies
1
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.8 to 0.3.0

29

index.js

@@ -314,11 +314,3 @@ var path = require('path');

if (key in argv && !flags.bools[key]) {
if (!Array.isArray(argv[key])) {
argv[key] = [ argv[key] ];
}
argv[key].push(value);
}
else {
argv[key] = value;
}
setKey(argv, key.split('.'), value);

@@ -459,1 +451,20 @@ (aliases[key] || []).forEach(function (x) {

};
function setKey (obj, keys, value) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
if (o[key] === undefined) o[key] = {};
o = o[key];
});
var key = keys[keys.length - 1];
if (o[key] === undefined || typeof o[key] === 'boolean') {
o[key] = value;
}
else if (Array.isArray(o[key])) {
o[key].push(value);
}
else {
o[key] = [ o[key], value ];
}
}
{
"name" : "optimist",
"version" : "0.2.8",
"version" : "0.3.0",
"description" : "Light-weight option parsing with an argv hash. No optstrings attached.",

@@ -5,0 +5,0 @@ "main" : "./index.js",

@@ -305,1 +305,19 @@ var optimist = require('../index');

};
exports['nested dotted objects'] = function () {
var argv = optimist([
'--foo.bar', '3', '--foo.baz', '4',
'--foo.quux.quibble', '5', '--foo.quux.o_O',
'--beep.boop'
]).argv;
assert.deepEqual(argv.foo, {
bar : 3,
baz : 4,
quux : {
quibble : 5,
o_O : true
},
});
assert.deepEqual(argv.beep, { boop : true });
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc