Skip to content

ghSP/iniparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

iniParser

A tool that allows you to parse and create .ini files to and from regular javascript objects

const fs = require('fs');
const ini = require('@yaas/iniparser');

const config = ini.parse('./config.ini', '\n'); // By default the eol is \n, but you can change it to \r\n if required.
fs.writeFileSync('./other_config.ini', ini.stringify(config), 'utf8');

Valid .ini config to JS object

; This is a comment
# This is also a comment
key = value ; This is an invalid comment, will get to supporting this soon
[scope=global]
globalBool
[user]
name = Sam Price
[user.data]
someDataKey = dataProp
[global]
name = iniFile

Is transformed into

// Assuming you parsed it correctly into the variable `config`
const config = {
  key: 'value',
  globalBool: true,
  name: 'iniFile',
  user: {
    name: 'Sam Price',
    data: {
      someDataKey: 'dataProp'
    }
  }
};

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published