Socket
Socket
Sign inDemoInstall

parsec

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parsec - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

72

dist/index.js

@@ -33,17 +33,21 @@ "use strict";

/**
* @type {String} Key name for array of operands. _ by default.
@type {String} Key name for array of operands. _ by default.
*/
this.operandsKey = operandsKey;
/**
* @type {Boolean} Given an option A, create another option no-A==!A.
@type {Boolean} Given an option A, create another option no-A==!A.
*/
this.noFlags = noFlags;
/**
* @type {Boolean} Slice index for arguments array.
@type {Boolean} Slice index for arguments array.
*/
this.sliceIndex = sliceIndex;
/**
* @type {Boolean} Throw a runtime error if unknown flags are found.
@type {Boolean} Throw a runtime error if unknown flags are found.
*/
this.strictMode = strictMode;
/**
@private
@type Flag the end of options was found.
*/
this._endOfOpts = false;

@@ -53,5 +57,5 @@ }

/**
* Create mappings for cli options.
* @param {[String]} keys to map to cli args
* @param {Object} options
Create mappings for cli options.
@param {[String]} keys to map to cli args
@param {Object} options
*/

@@ -63,6 +67,6 @@

/**
* Iterator for entries
* @param {Array} args
* @param {String} operandsKey
* @return {{ key, value }}
Iterator for entries
@param {Array} args
@param {String} operandsKey
@return {{ key, value }}
*/

@@ -171,5 +175,5 @@ value: _regeneratorRuntime.mark(function entries(args) {

/**
* Token iterator for options.
* @param {Array} args
* @return {{ curr, next, value }}
Token iterator for options.
@param {Array} args
@return {{ curr, next, value }}
*/

@@ -308,5 +312,5 @@ }, {

/**
* Token sub-iterator for short options.
* @param {Token} *iterator
* @return {{ curr: {Token}, value }}
Token sub-iterator for short options.
@param {Token} *iterator
@return {{ curr: {Token}, value }}
*/

@@ -399,8 +403,8 @@ }, {

/**
* Map CLI arguments to custom Token objects.
* Short Options { isShort, tokens }
* Long Options { isLong, key, value, token }
* Operands { token, isBare }
* @param {Array} args
* @return {[Token]}
Map CLI arguments to custom Token objects.
Short Options { isShort, tokens }
Long Options { isLong, key, value, token }
Operands { token, isBare }
@param {Array} args
@return {[Token]}
*/

@@ -448,9 +452,9 @@ }, {

/**
* Returns an iterator that yields objects of the form
* `{ prev, curr, next }` for each item in a list.
* @param {Array | String} List to iterate.
* @param {Object} [last] last value (optional)
* @param {Object} [prev] first prev value (optional)
* @param {Object} [curr] first curr value (optional)
* @return { prev, curr, next } for each item in a list
Returns an iterator that yields objects of the form
`{ prev, curr, next }` for each item in a list.
@param {Array | String} List to iterate.
@param {Object} [last] last value (optional)
@param {Object} [prev] first prev value (optional)
@param {Object} [curr] first curr value (optional)
@return { prev, curr, next } for each item in a list
*/

@@ -558,5 +562,5 @@ }, {

/**
* Parse an array of arguments like process.argv
* @param {[String]} args
* @param {Object} options
Parse an array of arguments like process.argv
@param {[String]} args
@param {Object} options
*/

@@ -642,3 +646,3 @@ }, {

return prev.concat(next.keys);
}, []);
}, []).concat("_");
_Object$keys(_this2).filter(function (key) {

@@ -645,0 +649,0 @@ return key !== "$";

{
"name": "parsec",
"version": "0.2.1",
"version": "0.3.0",
"description": "Generator-based CLI parser.",

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

export default class Parsec {
constructor ({ operandsKey = "_", noFlags = true, sliceIndex = 2, strictMode = false }) {
/**
* @type {String} Key name for array of operands. _ by default.
@type {String} Key name for array of operands. _ by default.
*/
this.operandsKey = operandsKey
/**
* @type {Boolean} Given an option A, create another option no-A==!A.
@type {Boolean} Given an option A, create another option no-A==!A.
*/
this.noFlags = noFlags
/**
* @type {Boolean} Slice index for arguments array.
@type {Boolean} Slice index for arguments array.
*/
this.sliceIndex = sliceIndex
/**
* @type {Boolean} Throw a runtime error if unknown flags are found.
@type {Boolean} Throw a runtime error if unknown flags are found.
*/
this.strictMode = strictMode
/**
@private
@type Flag the end of options was found.
*/
this._endOfOpts = false
}
/**
* Create mappings for cli options.
* @param {[String]} keys to map to cli args
* @param {Object} options
Create mappings for cli options.
@param {[String]} keys to map to cli args
@param {Object} options
*/

@@ -37,5 +41,5 @@ static options (keys, opts) {

/**
* Parse an array of arguments like process.argv
* @param {[String]} args
* @param {Object} options
Parse an array of arguments like process.argv
@param {[String]} args
@param {Object} options
*/

@@ -46,6 +50,6 @@ static parse (args, options) {

/**
* Iterator for entries
* @param {Array} args
* @param {String} operandsKey
* @return {{ key, value }}
Iterator for entries
@param {Array} args
@param {String} operandsKey
@return {{ key, value }}
*/

@@ -74,5 +78,5 @@ *entries (args) {

/**
* Token iterator for options.
* @param {Array} args
* @return {{ curr, next, value }}
Token iterator for options.
@param {Array} args
@return {{ curr, next, value }}
*/

@@ -103,5 +107,5 @@ *tokens (args) {

/**
* Token sub-iterator for short options.
* @param {Token} *iterator
* @return {{ curr: {Token}, value }}
Token sub-iterator for short options.
@param {Token} *iterator
@return {{ curr: {Token}, value }}
*/

@@ -123,8 +127,8 @@ *shorts (iterator) {

/**
* Map CLI arguments to custom Token objects.
* Short Options { isShort, tokens }
* Long Options { isLong, key, value, token }
* Operands { token, isBare }
* @param {Array} args
* @return {[Token]}
Map CLI arguments to custom Token objects.
Short Options { isShort, tokens }
Long Options { isLong, key, value, token }
Operands { token, isBare }
@param {Array} args
@return {[Token]}
*/

@@ -157,9 +161,9 @@ map (args) {

/**
* Returns an iterator that yields objects of the form
* `{ prev, curr, next }` for each item in a list.
* @param {Array | String} List to iterate.
* @param {Object} [last] last value (optional)
* @param {Object} [prev] first prev value (optional)
* @param {Object} [curr] first curr value (optional)
* @return { prev, curr, next } for each item in a list
Returns an iterator that yields objects of the form
`{ prev, curr, next }` for each item in a list.
@param {Array | String} List to iterate.
@param {Object} [last] last value (optional)
@param {Object} [prev] first prev value (optional)
@param {Object} [curr] first curr value (optional)
@return { prev, curr, next } for each item in a list
*/

@@ -208,4 +212,4 @@ *tuples (list, last, prev, curr) {

if (options.strictMode) {
const validKeys = this.$
.reduce((prev, next) => prev.concat(next.keys), [])
const validKeys = this.$.reduce((prev, next) =>
prev.concat(next.keys), []).concat("_")
Object.keys(this)

@@ -212,0 +216,0 @@ .filter((key) => key !== "$")

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