yini-parser 1.0.0-alpha.7 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +254 -151
- package/dist/YINI.js +15 -15
- package/dist/core/ErrorDataHandler.js +15 -15
- package/dist/core/YINIVisitor.d.ts +2 -2
- package/dist/core/YINIVisitor.js +254 -160
- package/dist/core/objectBuilder.js +39 -39
- package/dist/grammar/YiniLexer.js +5 -2
- package/dist/grammar/YiniParser.d.ts +28 -4
- package/dist/grammar/YiniParser.js +548 -298
- package/dist/grammar/YiniParserVisitor.d.ts +14 -0
- package/dist/grammar/YiniParserVisitor.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +17 -18
- package/dist/parseEntry.js +21 -21
- package/dist/parsers/extractHeaderParts.js +14 -14
- package/dist/parsers/extractSignificantYiniLine.js +18 -16
- package/dist/parsers/parseBoolean.js +2 -2
- package/dist/parsers/parseNull.js +2 -2
- package/dist/parsers/parseNumber.js +8 -8
- package/dist/parsers/parseSectionHeader.js +19 -19
- package/dist/parsers/parseString.js +9 -9
- package/dist/utils/string.js +3 -3
- package/dist/yiniHelpers.js +3 -3
- package/examples/basic-output.js +15 -0
- package/examples/basic-with-comments.yini +15 -0
- package/examples/basic.yini +11 -0
- package/examples/compare-formats.md +89 -0
- package/examples/nested-output.js +18 -0
- package/examples/nested.yini +26 -0
- package/examples/parse-example.ts +22 -0
- package/package.json +3 -2
- /package/dist/utils/{system.d.ts → print.d.ts} +0 -0
- /package/dist/utils/{system.js → print.js} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# YINI vs JSON, YAML, INI, and TOML
|
|
2
|
+
|
|
3
|
+
This document shows how the same configuration would look in different formats.
|
|
4
|
+
|
|
5
|
+
It highlights YINI's goal: *clean, human-friendly config syntax* - with full support for nesting, comments, and typed values - while remaining simpler than YAML or JSON.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🔵 YINI
|
|
10
|
+
|
|
11
|
+
This example shows how YINI compares to other formats for common configuration needs.
|
|
12
|
+
|
|
13
|
+
```yini
|
|
14
|
+
@yini
|
|
15
|
+
|
|
16
|
+
^ App
|
|
17
|
+
name = 'Demo App'
|
|
18
|
+
items = 25
|
|
19
|
+
darkMode = true
|
|
20
|
+
|
|
21
|
+
^^ Special
|
|
22
|
+
color = #336699
|
|
23
|
+
isCaching = false
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 🟠 JSON
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"App": {
|
|
31
|
+
"name": "Demo App",
|
|
32
|
+
"items": 25,
|
|
33
|
+
"darkMode": true,
|
|
34
|
+
"Special": {
|
|
35
|
+
"color": 3368601,
|
|
36
|
+
"isCaching": false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 🟡 YAML
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
App:
|
|
46
|
+
name: "Demo App"
|
|
47
|
+
items: 25
|
|
48
|
+
darkMode: true
|
|
49
|
+
Special:
|
|
50
|
+
color: 0x336699
|
|
51
|
+
isCaching: false
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 🟢 INI
|
|
55
|
+
|
|
56
|
+
```ini
|
|
57
|
+
[App]
|
|
58
|
+
name = Demo App
|
|
59
|
+
items = 25
|
|
60
|
+
darkMode = true
|
|
61
|
+
|
|
62
|
+
[App.Special]
|
|
63
|
+
color = 3368601
|
|
64
|
+
isCaching = false
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 🔴 TOML
|
|
68
|
+
|
|
69
|
+
```toml
|
|
70
|
+
[App]
|
|
71
|
+
name = "Demo App"
|
|
72
|
+
items = 25
|
|
73
|
+
darkMode = true
|
|
74
|
+
|
|
75
|
+
[App.Special]
|
|
76
|
+
color = 0x336699
|
|
77
|
+
isCaching = false
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## ✅ Summary
|
|
81
|
+
|
|
82
|
+
| Feature | **YINI** | **JSON** | **YAML** | **INI** | **TOML** |
|
|
83
|
+
|--------------------|---------------|-------------|------------|-------------|----------|
|
|
84
|
+
| Comments | ✅ Yes | ❌ No | ✅ Yes | ✅ Yes | ✅ Yes |
|
|
85
|
+
| Nesting | ✅ Clean | ✅ Manual | ✅ Native | ⚠️ Limited | ✅ Native |
|
|
86
|
+
| Data Types | ✅ Rich | ✅ Rich | ✅ Rich | ⚠️ Limited | ✅ Rich |
|
|
87
|
+
| Syntax Noise | 🚫 Minimal | 🔺 High | ⚠️ Medium | ✅ Minimal | ⚠️ Medium |
|
|
88
|
+
| Human-Writable | ✅ Yes | ❌ Verbose | ✅ Yes | ✅ Yes | ✅ Yes |
|
|
89
|
+
| Designed for Config| ✅ Purposeful | ❌ General | ✅ Yes | ✅ Yes | ✅ Yes |
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Parsed output in config from examples/nested.yini using YINI.parseFile(...)
|
|
2
|
+
|
|
3
|
+
config = {
|
|
4
|
+
App: {
|
|
5
|
+
name: 'Nested Demo App',
|
|
6
|
+
version: '1.2.3',
|
|
7
|
+
Theme: {
|
|
8
|
+
primaryColor: 3368601,
|
|
9
|
+
darkMode: true,
|
|
10
|
+
Overrides: { darkMode: false, fontSize: 14 },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
Database: {
|
|
14
|
+
host: 'db.local',
|
|
15
|
+
port: 5432,
|
|
16
|
+
Credentials: { password: 'secret' },
|
|
17
|
+
},
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
nested.yini
|
|
3
|
+
Demonstrates nested sections in YINI format.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@yini
|
|
7
|
+
|
|
8
|
+
^ App // Top-level section: App
|
|
9
|
+
name = 'Nested Demo App'
|
|
10
|
+
version = "1.2.3"
|
|
11
|
+
|
|
12
|
+
^^ Theme // Nested under App: App.Theme
|
|
13
|
+
primaryColor = #336699
|
|
14
|
+
darkMode = true
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
^^^ Overrides // Nested under Theme: App.Theme.Overrides
|
|
18
|
+
darkMode = false
|
|
19
|
+
fontSize = 14
|
|
20
|
+
|
|
21
|
+
^ Database // Another top-level section: Database
|
|
22
|
+
host = "db.local"
|
|
23
|
+
port = 5432
|
|
24
|
+
|
|
25
|
+
^^ Credentials // Nested under Database: Database.Credentials username = "admin"
|
|
26
|
+
password = "secret"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parse-example.ts
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates reading and parsing a YINI configuration file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'path'
|
|
8
|
+
import YINI from 'yini-parser'
|
|
9
|
+
|
|
10
|
+
// Resolve path to the example config file.
|
|
11
|
+
const configPath = path.resolve(__dirname, './basic.yini')
|
|
12
|
+
|
|
13
|
+
// Parse the YINI config file.
|
|
14
|
+
const config = YINI.parseFile(configPath)
|
|
15
|
+
|
|
16
|
+
// Output some example values.
|
|
17
|
+
console.log('App Title:', config.App.title)
|
|
18
|
+
console.log('Items:', config.App.items)
|
|
19
|
+
console.log('Dark Theme Enabled:', config.App.isDarkTheme)
|
|
20
|
+
|
|
21
|
+
console.log('\nFull Config:')
|
|
22
|
+
console.dir(config, { depth: null })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yini-parser",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "Simple and flexible config parser for Node.js. YINI: an enhanced, readable alternative to JSON, INI, and YAML—built for modern JavaScript and TypeScript projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yini",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"package.json",
|
|
27
27
|
"README.md",
|
|
28
28
|
"LICENSE",
|
|
29
|
-
"CHANGELOG.md"
|
|
29
|
+
"CHANGELOG.md",
|
|
30
|
+
"examples/"
|
|
30
31
|
],
|
|
31
32
|
"main": "dist/index.js",
|
|
32
33
|
"types": "dist/index.d.ts",
|
|
File without changes
|
|
File without changes
|