loose-text-configs

1.0.0 • Public • Published

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"
}
*/

Package Sidebar

Install

npm i loose-text-configs

Weekly Downloads

1

Version

1.0.0

License

GPL-3.0

Unpacked Size

111 kB

Total Files

7

Last publish

Collaborators

  • liamzebedee