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

argufy

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argufy - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

test.js

47

build/index.js

@@ -8,2 +8,11 @@ "use strict";

/**
* @typedef {Object} Flag
* @property {string} [short] Shorthand for this flag, usually one letter.
* @property {boolean} [boolean] Does not have to be followed by a value, true if given.
* @property {boolean} [number] Parse as a number.
* @property {boolean} [command] Whether this flag can be specified as the first argument without the dash, such as `example run`: run is the command.
*
* @typedef {Object.<string, string|Flag>} Config
*/
const find = (argv, long, short, bool, number) => {

@@ -25,4 +34,36 @@ const re = new RegExp(`-(${short}|-${long})`);

};
/**
* Parse the config and extract arguments from the `process.argv` array.
* @param {Config} config The configuration for parsing, where each key is a flag and values are either strings, or objects with possible properties:
*
* - __short__ Shorthand for this flag, usually one letter.
* - __boolean__ Does not have to be followed by a value, true if given.
* - __number__ Parse as a number.
* - __command__ Whether this flag can be specified as the first argument without the dash, such as `example run`.
*
* @example
*
* ```js
* const config = {
* title: 't', // program -t Title
* open: { // program -o
* short: 'o',
* boolean: true,
* },
* delay: { // program -d 100
* short: 'd',
* number: true,
* },
* file: { // program File.txt
* command: true,
* },
* }
* ```
*
* @param {string[]} args value of process.argv. It is assumed that user arguments start from the 3rd position.
* @returns {Object.<string, string|boolean|number>} An object with all found values for the configuration request.
*/
var _default = (config = {}, args = []) => {
const argufy = (config = {}, args = []) => {
const [,, ...argv] = args;

@@ -57,7 +98,9 @@ /** @type {string} */

};
}, {});
}, {}); // /** @type {Object} */
return res;
};
var _default = argufy;
exports.default = _default;
//# sourceMappingURL=index.js.map
## 11 June 2018
### 1.0.2
- [doc] jsdoc documentation for `argufy`.
## 11 June 2018
## 1.0.1

@@ -4,0 +10,0 @@

2

package.json
{
"name": "argufy",
"version": "1.0.1",
"version": "1.0.2",
"description": "Parse command line arguments to Node.js CLI programs.",

@@ -5,0 +5,0 @@ "main": "build",

@@ -0,1 +1,12 @@

/**
* @typedef {Object} Flag
* @property {string} [short] Shorthand for this flag, usually one letter.
* @property {boolean} [boolean] Does not have to be followed by a value, true if given.
* @property {boolean} [number] Parse as a number.
* @property {boolean} [command] Whether this flag can be specified as the first argument without the dash, such as `example run`: run is the command.
*
* @typedef {Object.<string, string|Flag>} Config
*/
const find = (argv, long, short, bool, number) => {

@@ -16,3 +27,34 @@ const re = new RegExp(`-(${short}|-${long})`)

export default (config = {}, args = []) => {
/**
* Parse the config and extract arguments from the `process.argv` array.
* @param {Config} config The configuration for parsing, where each key is a flag and values are either strings, or objects with possible properties:
*
* - __short__ Shorthand for this flag, usually one letter.
* - __boolean__ Does not have to be followed by a value, true if given.
* - __number__ Parse as a number.
* - __command__ Whether this flag can be specified as the first argument without the dash, such as `example run`.
*
* @example
*
* ```js
* const config = {
* title: 't', // program -t Title
* open: { // program -o
* short: 'o',
* boolean: true,
* },
* delay: { // program -d 100
* short: 'd',
* number: true,
* },
* file: { // program File.txt
* command: true,
* },
* }
* ```
*
* @param {string[]} args value of process.argv. It is assumed that user arguments start from the 3rd position.
* @returns {Object.<string, string|boolean|number>} An object with all found values for the configuration request.
*/
const argufy = (config = {}, args = []) => {
const [ ,, ...argv ] = args

@@ -38,3 +80,6 @@ /** @type {string} */

}, {})
// /** @type {Object} */
return res
}
export default argufy

Sorry, the diff of this file is not supported yet

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