Skip to content

Make a really simple toml parser #7

@gkpty

Description

@gkpty

Something like this should do for parsing the torus config and the git config

let obj = {}
let file = fs.readFileSync('tomlfile')
let arr = file.split('[')
for(let elem of arr){
  keyval = elem.split(']')
  let key = keyval[0]].trim()
  obj[key]={}
  let vals = keyval[1].split('=')
  let currentKey = null
  for(let val in vals){
    if(val%2 === 0) {
       obj[key][val]=''
       subKey = val.trim()
    }
    else obj[key][subKey] = val.trim()
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions