config.ini
your .ini
files parser with some extras
Version
Version | Published | By | URL |
---|---|---|---|
0.0.60 | 2019-08-11 | codebloke |
npm |
How to use it
Installation
npm install --save config.ini
In your code...
var configIni = ;
Examples
- Example .ini file format
- Reading string
- Reading from a file
- Output to .ini string (you can save it into a file)
- I8N Support
Example format
For all examples below we are assuming following .ini file
structure
# A comment ; This is a comment too [SectionOne] key = "value"integer = 1234real = 3.14string1 = "Case 1"string2 = 'Case 2'multivalue[] = "first" # in-line comments multivalue[] = 'second' # are supported as well ; Section: SectionTwo[SectionTwo] key = new valueinteger = 1234real = 3.14string1 = Case 1string2 = Case 2string3 = Case 3multivalue[] = firstmultivalue[] = secondmultivalue[] = third
Reading from a string
Reading config from an .ini string
with sections (For section-less feature see: #2)
var string = '' conf = configIni; /// (...) console; // 1234 console; // 'number' console; // 'object' console; // 3.14 /// (...)
Reading from a file
Reading config from a file.ini
var conf = configIni; /// (...) console; // 1234 console; // 'number' console; // 'object' console; // 3.14 /// (...)
Output to an .ini string
var objToIniString = mysection: key: "string" integer: 1234 real: 314 ; console;'; Section: mysection[mysection] key = stringinteger = 1234real = 3.14'
I8N Support
For the .ini
file as follows:
[Japan]miyamoto_musashi = "宮本武蔵" [Germany]gebhard_von_bluecher = "Gebhard-Leberecht von Blücher Fürst von Wahlstatt" [ME]salah_ad_din = "صلاحالدينيوسفبنأيوب"
we are getting back following object:
console;