aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/dargs.js
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-06-12 15:17:44 -0400
committereric thul <thul.eric@gmail.com>2016-06-12 15:17:44 -0400
commit531c751fe5593750a377db38bcfaf9a5383ac661 (patch)
tree935b5f17cc29bee58e27b474fe604a3257b7fc63 /src/dargs.js
parent7243be70a2163be2230a5f2739768137305a24ef (diff)
downloadpurs-loader-531c751fe5593750a377db38bcfaf9a5383ac661.tar.gz
purs-loader-531c751fe5593750a377db38bcfaf9a5383ac661.tar.zst
purs-loader-531c751fe5593750a377db38bcfaf9a5383ac661.zip
Reduce building of PureScript module map
Resolves #59 and resolves #60
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;