Socket
Socket
Sign inDemoInstall

optimist

Package Overview
Dependencies
Maintainers
0
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimist - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

examples/string.js

17

index.js

@@ -47,2 +47,3 @@ module.exports = Argv;

var value = typeof val !== 'string' || isNaN(num) ? val : num;
if (flags.strings[key]) value = val;

@@ -60,3 +61,3 @@ if (key in self.argv) {

var flags = { bools : {} };
var flags = { bools : {}, strings : {} };

@@ -83,2 +84,16 @@ self.boolean = function (bools) {

self.string = function (strings) {
if (!Array.isArray(strings)) {
strings = [].slice.call(arguments);
}
strings.forEach(function (name) {
flags.strings[name] = true;
});
rescan();
return self;
};
function rescan () {

@@ -85,0 +100,0 @@ self.argv = { _ : [], $0 : self.$0 };

7

package.json
{
"name" : "optimist",
"version" : "0.1.6",
"version" : "0.1.7",
"description" : "Light-weight option parsing with an argv hash. No optstrings attached.",

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

"argument",
"args",
"option",
"parser",
"parsing"
"parsing",
"cli",
"command"
],

@@ -17,0 +20,0 @@ "author" : {

// coffee script style arguments where process.argv is .splice(2)'d
var fs = require('fs');
var Script = process.binding('evals').Script;
var Hash = require('traverse/hash');
var Hash = require('hashish');

@@ -6,0 +6,0 @@ exports.coffee = function (assert) {

var optimist = require('optimist');
var assert = require('assert');

@@ -146,2 +147,3 @@ exports['short boolean'] = function (assert) {

'-w', '10f',
'--hex', '0xdeadbeef',
'789',

@@ -154,2 +156,3 @@ ]);

w : '10f',
hex : 0xdeadbeef,
_ : [ 789 ],

@@ -162,2 +165,3 @@ $0 : 'expresso'

assert.eql(typeof argv.w, 'string');
assert.eql(typeof argv.hex, 'number');
assert.eql(typeof argv._[0], 'number');

@@ -188,1 +192,11 @@ };

};
exports.strings = function () {
var s = optimist([ '-s', '0001234' ]).string('s').argv.s;
assert.eql(s, '0001234');
assert.eql(typeof s, 'string');
var x = optimist([ '-x', '56' ]).string('x').argv.x;
assert.eql(x, '56');
assert.eql(typeof x, 'string');
};

@@ -1,2 +0,2 @@

var Hash = require('traverse/hash');
var Hash = require('hashish');
var optimist = require('optimist');

@@ -3,0 +3,0 @@

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