30
30
31
31
## Quick Into to YINI Format
32
32
33
- A small example using YINI in TypeScript:
34
- ``` ts
35
- import YINI from ' yini-parser'
36
-
37
- const config = YINI .parse (`
33
+ YINI code looks like this:
34
+ ``` yini
35
+ // This is a comment in YINI
38
36
// YINI is a simple, human-readable configuration file format.
39
37
40
- // Note: In YINI, spaces and tabs don't change meaning -
41
- // indentation is just for readability.
38
+ // Note: In YINI, spaces and tabs don't change meaning - indentation is just
39
+ // for readability.
40
+
41
+ /* This is a block comment
42
+
43
+ In YINI, section headers use repeated characters "^" at the start to
44
+ show their level: (Section header names are case-sensitive.)
45
+
46
+ ^ SectionLevel1
47
+ ^^ SectionLevel2
48
+ ^^^ SectionLevel3
49
+ */
42
50
43
51
^ App // Definition of section (group) "App"
44
52
name = 'My Title' // Keys and values are written as key = value
@@ -49,22 +57,10 @@ const config = YINI.parse(`
49
57
^^ Special
50
58
primaryColor = #336699 // Hex number format
51
59
isCaching = false // "OFF" and "NO" works too
52
- ` )
53
-
54
- // To parse from a file instead:
55
- // const config = YINI.parseFile('./config.yini')
56
-
57
- console .log (config .App .name ) // My Title
58
- console .log (config .App .Special .isCaching ) // false
59
- console .log ()
60
- console .log (config )
61
60
```
62
61
63
- ** Output :**
62
+ ** The above YINI converted to a JS object :**
64
63
``` js
65
- My Title
66
- false
67
-
68
64
{
69
65
App: {
70
66
name: ' My Title' ,
0 commit comments