loose-text-configs
v1.0.0
Published
Stop hand-writing JSON for configurations that you can easily process like it's text!
Downloads
1
Maintainers
Readme
loose-text-configs
Stop hand-writing JSON for configurations that you can easily process like it's text! Small helper library that processes a multi-line string, ignoring empty lines and trims spacing, and runs a function for each line.
yarn add loose-text-configs
Example
import createConfig from 'loose-text-configs';
createConfig(
`
ADJ = JJR JJS
BW = RBR RBS WRB
LID = DT PDT WDT
VG = CC
`,
line => {
let [dutchCode, enCodes] = line.split(' = ')
enCodes.split(' ').map(code => {
en2nlCodeMapping[code] = dutchCode
})
}
)
/*
Returns:
{
"JJR": "ADJ",
"JJS": "ADJ",
"RBR": "BW",
"RBS": "BW",
"WRB": "BW",
"DT": "LID",
"PDT": "LID",
"WDT": "LID",
"CC": "VG"
}
*/