Skip to content
Stop hand-writing JSON for configurations that you can easily process like it's text!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.npmignore
README.md
go-crosscompile.sh
package.json
yarn-error.log
yarn.lock

README.md

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

Originally built as part of my Dutch NLP assistant.

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"
}
*/
You can’t perform that action at this time.