Created
November 7, 2019 13:48
-
-
Save jeovazero/6f57b7210108269df68e82332d5e03ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const expr = /export \{?((.|\s)+?)\}? from \'(.+)\'/gmi | |
process.stdin.setEncoding('utf8'); | |
let input = '' | |
process.stdin.on('data', (chunk) => { | |
input += chunk | |
}); | |
const getKeys = (text) => { | |
return text.replace(/\s/gm, '').split(',') | |
} | |
const parse = (text) => { | |
let ans; | |
const mapping = {} | |
while(true) { | |
ans = expr.exec(text) | |
if (ans !== null) | |
getKeys(ans[1]).forEach(cur => { | |
mapping[cur] = ans[3] | |
}) | |
else break; | |
} | |
return mapping | |
} | |
process.stdin.on('end', () => { | |
console.log(parse(input)) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment