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');
; 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'
}
}
};
MIT