From 2438817775ca92139baf10ad2bb667ea5a6a88c7 Mon Sep 17 00:00:00 2001
From: John Gee <john@ruru.gen.nz>
Date: Mon, 11 Apr 2022 21:21:20 +1200
Subject: [PATCH 1/3] refactor: fix types and the like based on PR feedback

---
 utils.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils.js b/utils.js
index b921b96..77c8642 100644
--- a/utils.js
+++ b/utils.js
@@ -43,7 +43,7 @@ function isOptionValue(value) {
 }
 
 /**
- * Determines if `arg` is a just a short option.
+ * Determines if `arg` is just a short option.
  * @example '-f'
  */
 function isLoneShortOption(arg) {

From 876f61ca40e5e126f602bb893d01d1b5bd640e92 Mon Sep 17 00:00:00 2001
From: John Gee <john@ruru.gen.nz>
Date: Mon, 11 Apr 2022 21:40:48 +1200
Subject: [PATCH 2/3] Fixes in comments, pre feedback

---
 index.js      |  1 -
 test/index.js |  2 +-
 utils.js      | 16 ++++++++--------
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/index.js b/index.js
index ac0e78f..c29cfe7 100644
--- a/index.js
+++ b/index.js
@@ -178,7 +178,6 @@ const parseArgs = ({
           ArrayPrototypePush(expanded, `-${shortOption}`);
         } else {
           // String option in middle. Yuck.
-          // ToDo: if strict then throw
           // Expand -abfFILE to -a -b -fFILE
           ArrayPrototypePush(expanded, `-${StringPrototypeSlice(arg, index)}`);
           break; // finished short group
diff --git a/test/index.js b/test/index.js
index 2a8f99b..fd58567 100644
--- a/test/index.js
+++ b/test/index.js
@@ -91,7 +91,7 @@ test('short option group does not consume subsequent positional', (t) => {
   t.end();
 });
 
-// // See: Guideline 5 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
+// See: Guideline 5 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
 test('if terminal of short-option group configured `type: "string"`, subsequent positional is stored', (t) => {
   const passedArgs = ['-rvf', 'foo'];
   const passedOptions = { f: { type: 'string' } };
diff --git a/utils.js b/utils.js
index 77c8642..b718c01 100644
--- a/utils.js
+++ b/utils.js
@@ -57,7 +57,7 @@ function isLoneShortOption(arg) {
  * @example
  * isLoneLongOption('a') // returns false
  * isLoneLongOption('-a') // returns false
- * isLoneLongOption('--foo) // returns true
+ * isLoneLongOption('--foo') // returns true
  * isLoneLongOption('--foo=bar') // returns false
  */
 function isLoneLongOption(arg) {
@@ -69,7 +69,7 @@ function isLoneLongOption(arg) {
 /**
  * Determines if `arg` is a long option and value in the same argument.
  * @example
- * isLongOptionAndValue('--foo) // returns false
+ * isLongOptionAndValue('--foo') // returns false
  * isLongOptionAndValue('--foo=bar') // returns true
  */
 function isLongOptionAndValue(arg) {
@@ -90,14 +90,14 @@ function isLongOptionAndValue(arg) {
  * isShortOptionGroup('-ab', {}) // returns true
  * // -fb is an option and a value, not a short option group
  * isShortOptionGroup('-fb', {
- *   options: { f: { type: 'string' }}
+ *   options: { f: { type: 'string' } }
  * }) // returns false
  * isShortOptionGroup('-bf', {
- *   options: { f: { type: 'string' }}
+ *   options: { f: { type: 'string' } }
  * }) // returns true
  * // -bfb is an edge case, return true and caller sorts it out
  * isShortOptionGroup('-bfb', {
- *   options: { f: { type: 'string' }}
+ *   options: { f: { type: 'string' } }
  * }) // returns true
  */
 function isShortOptionGroup(arg, options) {
@@ -111,10 +111,10 @@ function isShortOptionGroup(arg, options) {
 }
 
 /**
- * Determine is arg is a short string option followed by its value.
+ * Determine if arg is a short string option followed by its value.
  * @example
- * isShortOptionAndValue('-a, {}); // returns false
- * isShortOptionAndValue('-ab, {}); // returns false
+ * isShortOptionAndValue('-a', {}); // returns false
+ * isShortOptionAndValue('-ab', {}); // returns false
  * isShortOptionAndValue('-fFILE', {
  *   options: { foo: { short: 'f', type: 'string' }}
  * }) // returns true

From 3bf8712044f129f758c75fcf9092b576bb0bd8a6 Mon Sep 17 00:00:00 2001
From: John Gee <john@ruru.gen.nz>
Date: Mon, 11 Apr 2022 21:43:42 +1200
Subject: [PATCH 3/3] Switch more tests to use arrow functions

---
 test/index.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/test/index.js b/test/index.js
index fd58567..59323ac 100644
--- a/test/index.js
+++ b/test/index.js
@@ -249,7 +249,7 @@ test('when expecting `multiple:true` boolean option and option used multiple tim
   t.end();
 });
 
-test('order of option and positional does not matter (per README)', function(t) {
+test('order of option and positional does not matter (per README)', (t) => {
   const passedArgs1 = ['--foo=bar', 'baz'];
   const passedArgs2 = ['baz', '--foo=bar'];
   const passedOptions = { foo: { type: 'string' } };
@@ -368,17 +368,17 @@ test('invalid argument passed for options', (t) => {
   const passedArgs = ['--so=wat'];
   const passedOptions = 'bad value';
 
-  t.throws(function() { parseArgs({ args: passedArgs, options: passedOptions }); }, {
+  t.throws(() => { parseArgs({ args: passedArgs, options: passedOptions }); }, {
     code: 'ERR_INVALID_ARG_TYPE'
   });
 
   t.end();
 });
 
-test('then type property missing for option then throw', function(t) {
+test('then type property missing for option then throw', (t) => {
   const knownOptions = { foo: { } };
 
-  t.throws(function() { parseArgs({ options: knownOptions }); }, {
+  t.throws(() => { parseArgs({ options: knownOptions }); }, {
     code: 'ERR_INVALID_ARG_TYPE'
   });
 
@@ -389,7 +389,7 @@ test('boolean passed to "type" option', (t) => {
   const passedArgs = ['--so=wat'];
   const passedOptions = { foo: { type: true } };
 
-  t.throws(function() { parseArgs({ args: passedArgs, options: passedOptions }); }, {
+  t.throws(() => { parseArgs({ args: passedArgs, options: passedOptions }); }, {
     code: 'ERR_INVALID_ARG_TYPE'
   });
 
@@ -400,7 +400,7 @@ test('invalid union value passed to "type" option', (t) => {
   const passedArgs = ['--so=wat'];
   const passedOptions = { foo: { type: 'str' } };
 
-  t.throws(function() { parseArgs({ args: passedArgs, options: passedOptions }); }, {
+  t.throws(() => { parseArgs({ args: passedArgs, options: passedOptions }); }, {
     code: 'ERR_INVALID_ARG_TYPE'
   });
 
@@ -411,7 +411,7 @@ test('invalid short option length', (t) => {
   const passedArgs = [];
   const passedOptions = { foo: { short: 'fo', type: 'boolean' } };
 
-  t.throws(function() { parseArgs({ args: passedArgs, options: passedOptions }); }, {
+  t.throws(() => { parseArgs({ args: passedArgs, options: passedOptions }); }, {
     code: 'ERR_INVALID_ARG_VALUE'
   });