[Pkg-javascript-commits] [node-dargs] 50/54: minor tweaks

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:41:06 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-dargs.

commit a9a061a8c95b4de4978522d0f36f865eca106c77
Author: Sindre Sorhus <sindresorhus at gmail.com>
Date:   Fri Sep 23 00:10:08 2016 +0700

    minor tweaks
---
 .gitattributes |  1 +
 index.js       |  9 +++++----
 readme.md      | 11 ++++++++---
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index 176a458..391f0a4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
 * text=auto
+*.js text eol=lf
diff --git a/index.js b/index.js
index ab16539..f908375 100644
--- a/index.js
+++ b/index.js
@@ -11,7 +11,7 @@ module.exports = (input, opts) => {
 	}, opts);
 
 	const makeArg = (key, val) => {
-		key = '--' + (opts.allowCamelCase ? key : key.replace(/[A-Z]/g, '-$&').toLowerCase()); // eslint-disable-line prefer-template
+		key = '--' + (opts.allowCamelCase ? key : key.replace(/[A-Z]/g, '-$&').toLowerCase());
 
 		if (opts.useEquals) {
 			args.push(key + (val ? `=${val}` : ''));
@@ -32,6 +32,7 @@ module.exports = (input, opts) => {
 		}
 	};
 
+	// TODO: use for-of loop and Object.entries when targeting Node.js 6
 	Object.keys(input).forEach(key => {
 		const val = input[key];
 		let pushArg = makeArg;
@@ -81,9 +82,9 @@ module.exports = (input, opts) => {
 		}
 	});
 
-	extraArgs.forEach(extraArgVal => {
-		args.push(String(extraArgVal));
-	});
+	for (const x of extraArgs) {
+		args.push(String(x));
+	}
 
 	return args;
 };
diff --git a/readme.md b/readme.md
index a8bb011..7c54aa5 100644
--- a/readme.md
+++ b/readme.md
@@ -120,7 +120,9 @@ Maps keys in `input` to an aliased name. Matching keys are converted to argument
 Type: `boolean`<br>
 Default: `true`
 
-Setting this to `false` makes it return the key and value as separate array items instead of using a `=` separator in one item. This can be useful for tools that doesn't support `--foo=bar` style flags. For example:
+Setting this to `false` makes it return the key and value as separate array items instead of using a `=` separator in one item. This can be useful for tools that doesn't support `--foo=bar` style flags.
+
+###### Example
 
 ```js
 console.log(dargs({foo: 'bar'}, {useEquals: false}));
@@ -143,9 +145,11 @@ Exclude `false` values. Can be useful when dealing with strict argument parsers
 Type: `boolean`<br>
 Default: `false`
 
-By default dargs will convert camelcase arguments to hyphenated arguments. Setting this to true will bypass the conversion process. For example:
+By default, camelCased keys will be hyphenated. Enabling this will bypass the conversion process.
 
-```
+###### Example
+
+```js
 console.log(dargs({fooBar: 'baz'}));
 //=> ['--foo-bar', 'baz']
 
@@ -153,6 +157,7 @@ console.log(dargs({fooBar: 'baz'}, {allowCamelCase: true}));
 //=> ['--fooBar', 'baz']
 ```
 
+
 ## License
 
 MIT © [Sindre Sorhus](https://sindresorhus.com)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-dargs.git



More information about the Pkg-javascript-commits mailing list