aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/dargs.js
diff options
context:
space:
mode:
authoreric <thul.eric@gmail.com>2016-06-12 16:06:34 -0400
committerGitHub <noreply@github.com>2016-06-12 16:06:34 -0400
commit27638f63256b6d38745eef251b3327536766e7c3 (patch)
tree75e135abd95c9fee60ef9d9ba7d35440fd2c1ddf /src/dargs.js
parent7243be70a2163be2230a5f2739768137305a24ef (diff)
parent0b853815ef14d35cedebc2c7806fd2f9ff9d5ab5 (diff)
downloadpurs-loader-27638f63256b6d38745eef251b3327536766e7c3.tar.gz
purs-loader-27638f63256b6d38745eef251b3327536766e7c3.tar.zst
purs-loader-27638f63256b6d38745eef251b3327536766e7c3.zip
Merge pull request #61 from ethul/topic/issues
Reduce building of PureScript module map
Diffstat (limited to 'src/dargs.js')
-rw-r--r--src/dargs.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/dargs.js b/src/dargs.js
new file mode 100644
index 0000000..e5c574c
--- /dev/null
+++ b/src/dargs.js
@@ -0,0 +1,16 @@
1'use strict';
2
3function dargs(obj) {
4 return Object.keys(obj).reduce((args, key) => {
5 const arg = '--' + key.replace(/[A-Z]/g, '-$&').toLowerCase();
6 const val = obj[key]
7
8 if (key === '_') val.forEach(v => args.push(v))
9 else if (Array.isArray(val)) val.forEach(v => args.push(arg, v))
10 else args.push(arg, obj[key])
11
12 return args.filter(arg => (typeof arg !== 'boolean'))
13 }, [])
14}
15
16module.exports = dargs;