3.0.1 • Published 5 years ago

@yaas/iniparser v3.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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(fs.readFileSync('./config.ini', 'utf8'), '\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 now valid
[scope=global]
globalBool
[user]
name = Sam Price
[user.data]
someDataKey = dataProp
[global]
name = iniFile

arr[] = value1 ; value at index 0
arr[] = value2 ; value at index 1

Is transformed into

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

NOTE: Numbers, Sets, Bigints, NaN or false are not supported to be parsed

License

MIT

3.0.1

5 years ago

3.0.0

5 years ago

2.3.0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.1

5 years ago