yini-parser 1.0.1-beta → 1.1.0-beta

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +131 -328
  3. package/dist/YINI.d.ts +34 -11
  4. package/dist/YINI.js +206 -121
  5. package/dist/core/ASTBuilder.d.ts +191 -0
  6. package/dist/core/ASTBuilder.js +827 -0
  7. package/dist/core/ErrorDataHandler.d.ts +19 -19
  8. package/dist/core/ErrorDataHandler.js +258 -150
  9. package/dist/core/objectBuilder.d.ts +9 -3
  10. package/dist/core/objectBuilder.js +126 -163
  11. package/dist/core/types.d.ts +234 -44
  12. package/dist/core/types.js +7 -33
  13. package/dist/grammar/YiniLexer.d.ts +54 -48
  14. package/dist/grammar/YiniLexer.js +330 -293
  15. package/dist/grammar/YiniParser.d.ts +167 -150
  16. package/dist/grammar/YiniParser.js +1241 -1202
  17. package/dist/grammar/YiniParserVisitor.d.ts +59 -45
  18. package/dist/grammar/YiniParserVisitor.js +1 -1
  19. package/dist/index.d.ts +4 -2
  20. package/dist/index.js +298 -120
  21. package/dist/parseEntry.d.ts +3 -2
  22. package/dist/parseEntry.js +352 -81
  23. package/dist/parsers/extractHeaderParts.d.ts +3 -2
  24. package/dist/parsers/extractHeaderParts.js +1 -0
  25. package/dist/parsers/parseBoolean.d.ts +1 -1
  26. package/dist/parsers/parseBoolean.js +2 -1
  27. package/dist/parsers/parseNumber.d.ts +8 -3
  28. package/dist/parsers/parseNumber.js +50 -16
  29. package/dist/parsers/parseSectionHeader.d.ts +3 -2
  30. package/dist/parsers/parseSectionHeader.js +1 -0
  31. package/dist/utils/number.d.ts +3 -0
  32. package/dist/utils/number.js +18 -0
  33. package/dist/utils/object.d.ts +55 -0
  34. package/dist/utils/object.js +85 -0
  35. package/dist/utils/string.d.ts +21 -1
  36. package/dist/utils/string.js +39 -4
  37. package/dist/utils/system.d.ts +15 -0
  38. package/dist/utils/system.js +21 -0
  39. package/dist/yiniHelpers.d.ts +3 -0
  40. package/dist/yiniHelpers.js +43 -7
  41. package/package.json +3 -3
  42. package/dist/core/YINIVisitor.d.ts +0 -158
  43. package/dist/core/YINIVisitor.js +0 -1010
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## --dev/uppcoming--
4
+
5
+ ## 1.1.0-beta - 2025 Sep
6
+ ### Parser
7
+ - **Reimplemented parser from scratch** (`core/ASTBuilder.ts`) using the refactored grammar for a much cleaner and more maintainable design.
8
+ - **Build logic reimplemented** (`core/objectBuilder.ts`) for improved reliability and consistency.
9
+ - **Error reporting enhanced** to be more user-friendly and informative.
10
+ - **Fixed bug sometimes wrong line** Sometimes incorrect line number in error messages are now reported accurately.
11
+ - Renamed option `bailSensitivity` to a more shorter and user-friendly name `failLevel`.
12
+ - **Extended `parse` and `parseFile` methods** to support an options-object form.
13
+ Example:
14
+ ```ts
15
+ const config= YINI.parse(yini, {
16
+ strictMode: false,
17
+ failLevel: 'auto',
18
+ includeMetaData: false,
19
+ requireDocTerminator: false,
20
+ })
21
+ ```
22
+ ### Specification Alignment
23
+ - Updated to follow the **latest YINI specification (v1.0.0-rc.3)**.
24
+ - Document terminator `/END` is now optional in both lenient and strict mode.
25
+ ### Meta Data
26
+ - The optional returned **meta data structure** has been redesigned.
27
+ - Now includes improved organization.
28
+ - **Timing support** added for detailed performance insight.
29
+ - Grouping with **source**, **structure**, **diagnostics**, etc.
30
+
31
+ ## 1.0.2-beta - 2025 Aug
32
+ - Fixed issues with floats, including negative and exponential numbers with new test files here: `tests/fixed-issues/issue-32/*`
33
+ - Fixed an issue where parseFile(..) did not output a warning when parsing a file missing a newline at EOF. Plus added test cases to check that it is fixed (in `tests/fixed-issues/issue-30`).
34
+ - Fixed and improved number parsing to fully support negative values and edge cases for integers, floats, hex, bin, octal, duodecimal, and exponential numbers. Based on updated lexer and parser grammar files, and added extensive tests to ensure correct and robust handling. Here: `tests/integration/6-number-literals/*`
35
+
3
36
  ## 1.0.1-beta - 2025 Aug
4
37
  - Fixed catching lexer related errors correctly.
5
38
  - Improves error and test handling for invalid YINI syntax.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # YINI Parser for Node.js
2
2
 
3
- YINI is a clean, minimal, and human-readable config format for structured configuration. This parser implements the YINI spec in TypeScript for Node.js, with support for nested sections, strict/lenient modes, and typed values.
3
+ A TypeScript/Node.js parser for YINI A type-safe, structured, and human-readable config format with nested sections, types, comments, and support for strict validation.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/yini-parser.svg)](https://www.npmjs.com/package/yini-parser) [![All Tests](https://github.com/YINI-lang/yini-parser-typescript/actions/workflows/run-all-tests.yml/badge.svg)](https://github.com/YINI-lang/yini-parser-typescript/actions/workflows/run-all-tests.yml)
6
6
 
@@ -13,7 +13,7 @@ import YINI from 'yini-parser'
13
13
  const config = YINI.parseFile('./config.yini')
14
14
  ```
15
15
 
16
- A clean, minimal, human-readable config formatdesigned as an alternative to INI, YAML, and JSON.
16
+ YINI (Yet another INI): YINI is a configuration format designed for readability and structure, inspired by INI and YAML.
17
17
 
18
18
  ➡️ See full [documentation or YINI format specification](https://github.com/YINI-lang/YINI-spec)
19
19
 
@@ -21,7 +21,7 @@ A clean, minimal, human-readable config format—designed as an alternative to I
21
21
 
22
22
  ---
23
23
 
24
- ## YINI Parser – TypeScript
24
+ ## YINI Parser – (source code in TypeScript)
25
25
 
26
26
  > 🚧 This package is in **beta**. The core API is stabilizing, some more advanced features may still change. Feedback and bug reports are welcome!
27
27
 
@@ -34,22 +34,49 @@ YINI is a simple, human-friendly configuration format inspired by INI and JSON.
34
34
 
35
35
  ---
36
36
 
37
+ ## 🙋‍♀️ Why YINI?
38
+ - **YINI is an alternative** to other great config formats like INI, JSON, YAML, XML, and TOML — Supports section nesting and explicit syntax for configuration files.
39
+ - **Started as a personal project and a research challenge:** Provides structure similar to INI, with features inspired by JSON and YAML.
40
+ - **Built for clarity:**
41
+ * Uses a concise syntax to minimize unnecessary characters.
42
+ * Supports commonly used configuration structures.
43
+ - *Developed to meet practical needs, driven by curiosity and a desire **for configuration clarity, simplicity, minimalism, and flexibility**.
44
+
45
+ ---
46
+
47
+ ## 💡 What is YINI?
48
+ - **Simple like INI** — but with strong typing, comments, and nested sections.
49
+ - **Provides concise, structured syntax** for configuration.
50
+ - Supports section nesting **without requiring indentation or dot-delimited keys**.
51
+ - This repo/parser is built for both **JavaScript and TypeScript**.
52
+ - **Supports strict and lenient modes**, and all major data types.
53
+ - Can be **edited manually** or **processed programmatically**.
54
+ - 👉 See [how YINI compares with JSON, YAML, INI, and TOML](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples/compare-formats.md).
55
+ - Want the full syntax reference? See the [YINI Specification](https://github.com/YINI-lang/YINI-spec).
56
+
57
+ ---
58
+
37
59
  ## Quick Start
38
60
 
39
- A minimal example using YINI in TypeScript:
61
+ A small example using YINI in TypeScript/JavaScript:
40
62
  ```ts
41
63
  import YINI from 'yini-parser'
42
64
 
43
65
  const config = YINI.parse(`
44
- ^ App
45
- name = 'My Title' // App display name.
46
- items = 25
47
- darkMode = true
48
-
49
- // Sub-section of App.
50
- ^^ Special
51
- primaryColor = #336699
52
- isCaching = false
66
+ // YINI is a simple, human-readable configuration file format.
67
+
68
+ // Note: In YINI, spaces and tabs don't change meaning -
69
+ // indentation is just for readability.
70
+
71
+ ^ App // Definition of section (group) "App"
72
+ name = 'My Title' // Keys and values are written as key = value
73
+ items = 25
74
+ darkMode = true // "ON" and "YES" works too
75
+
76
+ // Sub-section of the "App" section
77
+ ^^ Special
78
+ primaryColor = #336699 // Hex number format
79
+ isCaching = false // "OFF" and "NO" works too
53
80
  `)
54
81
 
55
82
  // To parse from a file instead:
@@ -67,246 +94,29 @@ My Title
67
94
  false
68
95
 
69
96
  {
70
- App: {
71
- name: 'My Title',
72
- items: 25,
73
- darkMode: true,
74
- Special: {
75
- primaryColor: 3368601,
76
- isCaching: false
97
+ App: {
98
+ name: 'My Title',
99
+ items: 25,
100
+ darkMode: true,
101
+ Special: {
102
+ primaryColor: 3368601,
103
+ isCaching: false
104
+ }
77
105
  }
78
- }
79
106
  }
80
107
  ```
81
108
 
82
109
  That's it!
83
110
 
84
- ▶️ Link to [examples/](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples) files.
111
+ - ▶️ Link to [examples/](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples) files.
112
+ - ▶️ Link to [Demo Apps](https://github.com/YINI-lang/yini-demo-apps/tree/main) with complete basic usage.
85
113
 
86
- ## 💡 Why YINI?
87
- - **Easy to read and write**, minimal syntax noise, maximum clarity.
88
- - **Clear and minimal section nesting** without painful indentation rules or long dot nested strings, etc.
89
- - A perfect alternative to messy JSON, legacy INI, or complex YAML.
90
- - Built for both **JavaScript and TypeScript**.
91
- - **Supports strict/lenient modes**, and all major data types.
92
- - Both **human-friendly**, and **machine-friendly**.
93
- - 👉 See [how YINI compares to JSON, YAML, INI, and TOML](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples/compare-formats.md).
94
- - Want the full syntax reference? See the [YINI Specification](https://github.com/YINI-lang/YINI-spec).
95
-
96
114
  ---
97
115
 
98
116
  ## Intro to YINI Config Format
117
+ **YINI** is a simple and readable configuration format. Sections are defined with `^ SectionName`, and values are assigned using `key = value`. The format supports common data types (same as those found in JSON), including strings, numbers, booleans, nulls, and lists.
99
118
 
100
- ### 1. Sections
101
- Group settings under a named header. A section header name starts with `^`.
102
-
103
- Start a section with `^`, e.g.:
104
- ```yini
105
- ^ App
106
- title = "AppName"
107
- ```
108
-
109
- > Alternative section markers to `^` are also supported: `<`, `§`, `€` (e.g. `< Section`).
110
-
111
- > See section 9 for more advanced marker and naming options.
112
-
113
- ### 2. Key = Value
114
- Each line inside a section is a **key** (name) and **value**, separated by `=`.
115
-
116
- Write settings as `key = value`:
117
- ```yini
118
- maxConnections = 100
119
- enableLogging = true
120
- ```
121
-
122
- > See section 9 for more advanced marker and naming options.
123
-
124
- #### 💡Tip
125
- Use backticks (\`) to quote section or key names that contain spaces or special characters.
126
-
127
- Key names with spaces/special characters can be backticked:
128
-
129
- ```yini
130
- user id = 1 # Invalid ❌
131
- `user id` = 1 # Valid ✅
132
- ```
133
-
134
- ### 3. Values
135
- Values can be:
136
- - **Strings** (always quoted): `'hello'` or `"world"` (either single or double quoted)
137
- - **Numbers:** `42`, `3.14` or `-10`
138
- - **Booleans:** `true`, `false`, `on`, `off`, `yes`, `no` (all case-insensitive)
139
- - **Nulls:** Use `null` or leave the value blank after `=` (in lenient mode)
140
- - **Lists:**
141
- * JSON‑style: `["red", "green", "blue"]`
142
- * Colon‑style: *(Planned – not yet implemented in parser)*
143
-
144
- ### 4. Comments
145
- Various commenting styles are supported:
146
- ```yini
147
- // This is a line comment
148
- timeout = 30 // inline comment
149
- # This is also a line comment (must have a space after #)
150
- interval = 30 # inline comment (must have a space after #)
151
- /* Block comment spanning
152
- multiple lines */
153
- ; Full line comment (must be whole line).
154
- ```
155
-
156
- > **Tip:** You can add comments anywhere—above, beside, or below any setting or section.
157
- >
158
- 👆 **Caveat 1:** If you use `#` for comments, always put a space after the `#`.
159
- (Otherwise, the parser might misinterpret it as part of a value.)
160
-
161
- 👆 **Caveat 2:** `;` is used only for full-line comments. The `;` must be the first non-whitespace character on a line (only spaces or tabs are allowed before it).
162
- (If `;` appears later in the line, the parser may treat it as part of a value or as a line delimiter, not as a comment.)
163
-
164
- 💡**Tip:** You can use any comment style in your file.
165
- For best readability, try to stick to one style per file.
166
-
167
- ### 5. Nested Sections
168
- Use extra carets `^` for sub‑sections:
169
- ```yini
170
- ^ Parent
171
- ^^ Child
172
-
173
- // Add another caret `^` and you get a sub-section
174
- // of the previous section, and so...
175
- ^^^ SubChild
176
- ```
177
-
178
- If you prefer, you can indent the nested section for visibility:
179
- ```yini
180
- ^ Main
181
- ^^ Sub
182
- host = "db.example.com"
183
- ```
184
-
185
- One can nest multiple sections:
186
- ```yini
187
- ^ Root
188
- ^^ Sub
189
- ^^^ SubSub
190
- ^ BackToRoot
191
- ```
192
-
193
- Example with indented sections:
194
- ```yini
195
- ^ Root
196
- value = 'At level 1'
197
- ^^ Sub
198
- value = 'At level 2'
199
- ^^^ SubSub
200
- value = 'At level 3'
201
-
202
- ^ BackToRoot
203
- value = 'Back at level 1'
204
- ```
205
-
206
- The above Yini code will produce the following JavaScript object:
207
- ```js
208
- // JS object
209
- {
210
- Root: {
211
- value: 'At level 1',
212
- Sub: { value: 'At level 2', SubSub: { value: 'At level 3' } }
213
- },
214
- BackToRoot: { value: 'Back at level 1' }
215
- }
216
- ```
217
-
218
- > See section 9 for more advanced marker and naming options.
219
-
220
- ### 6. Lists
221
- ```yini
222
- // JSON‑style lists
223
- colors = ["red", "green", "blue"]
224
-
225
- numberList = [
226
- 10,
227
- 20,
228
- 30
229
- ]
230
-
231
-
232
- // Colon‑style list
233
- // 👆 Colon‑style list support is planned for an upcoming release.
234
- fruits:
235
- "Pear",
236
- "Cherry",
237
- "Banana"
238
- ```
239
-
240
- > You can use either single or double quotes for string values in YINI.
241
-
242
- ### 7. Document Terminator (strict mode)
243
- The `/END` marker is required only in strict mode, and optional in lenient (default) mode.
244
-
245
- End a file explicitly with:
246
- ```yini
247
- ^ App
248
- title = "MyTitle"
249
-
250
- /END // Must be included in strict mode.
251
- ```
252
-
253
- ### 8. Disabled Lines
254
- Prefix any valid line with `--` to skip it entirely:
255
- ```yini
256
- --maxRetries = 5
257
- ```
258
-
259
- ### 9. Advanced: Alternative Section Markers & Naming
260
- In addition to the standard syntax, YINI supports several advanced options:
261
-
262
- - (a.) **Alternative section markers:**
263
- Besides `^`, you can use `<`, `§`, or `€` as section header markers.
264
-
265
- ```yini
266
- < MySection
267
- § Settings
268
- € MyApp
269
- ```
270
-
271
- - (b.) **Backticked section names and key names:**
272
- Use backticks (`) to allow spaces or special characters in section or key names:
273
-
274
- ```yini
275
- ^ `Section name with spaces`
276
- `user id` = 42
277
- ```
278
-
279
- - (c.) **Numeric shorthand section markers:**
280
- To create deeply nested sections (beyond 6 levels), use numeric shorthand:
281
-
282
- ```yini
283
- ^7 DeepSection # Equivalent to 7 carets: ^^^^^^^ DeepSection
284
- <10 VeryDeep # Equivalent to <<<<<<<<<<< VeryDeep
285
- ```
286
-
287
- 👆 Though, can not mix standard/classic and numeric shorthand markers in the same section header.
288
-
289
- - (d.) **More features:**
290
- The YINI format supports even more features than listed here, such as additional number notations, string types, and advanced escaping. For full details, see the [latest release of the YINI specification](https://github.com/YINI-lang/YINI-spec/blob/release/YINI-Specification.md).
291
-
292
- ### 10. Complete Example
293
-
294
- ```yini
295
- @yini # Optional marker to identify YINI format.
296
-
297
- ^ App
298
- name = "MyApp"
299
- version = "1.0.0"
300
- debug = off // Turn on for debugging.
301
-
302
- ^^ Database
303
- host = "db.local"
304
- port = 5432
305
- --user = "secret" # This line is disabled due to --.
306
- userList = ["alice", "bob", "carol"]
307
-
308
- /END
309
- ```
119
+ To learn more, see the [Getting Started: Intro to YINI Config Format](https://github.com/YINI-lang/YINI-spec/blob/develop/Docs/Intro-to-YINI-Config-Format.md) tutorial.
310
120
 
311
121
  ---
312
122
 
@@ -424,45 +234,44 @@ These examples are also included in the npm package.
424
234
 
425
235
  ---
426
236
 
427
- ## Advanced Example
237
+ ## Bigger Example
428
238
 
429
239
  ```js
430
240
  const YINI = require('yini-parser').default; // Or: import YINI from 'yini-parser';
431
241
 
432
242
  const config = YINI.parse(`
433
- /*
434
- This is a multi-line block comment.
243
+ // This is a comment in YINI
244
+ // YINI is a simple, human-readable configuration file format.
245
+
246
+ // Note: In YINI, spaces and tabs don't change meaning - indentation is just
247
+ // for readability.
248
+
249
+ /* This is a block comment
250
+
251
+ In YINI, section headers use repeated characters "^" at the start to
252
+ show their level: (Section header names are case-sensitive.)
253
+
254
+ ^ SectionLevel1
255
+ ^^ SectionLevel2
256
+ ^^^ SectionLevel3
435
257
  */
436
258
 
437
- @yini
259
+ ^ App // Definition of section (group) "App"
260
+ title = 'My App'
261
+ items = 25
262
+ debug = ON // "true" and "YES" works too
438
263
 
439
- ^ App
440
- name = "Nested Example"
441
- version = "1.0.0"
442
- debug = OFF // This is a comment.
443
-
444
- # Database settings.
445
- ^^ Database
446
- host = "db.example.com"
447
- port = 3306
448
- user = "appuser"
449
- --password = "dbpassword" # Disabled line due to --.
450
- //password = "dbpassword" # Not sure yet about this pw.
451
- password = "dbpassword" # Keep this secret.
452
-
453
- // Commenting with slashes works too.
454
- ^^^ Pool
455
- min = 2
456
- max = 10
457
- idleTimeout = 300
458
-
459
- /* Block comment on a single line. */
460
- ^^ Logging
461
- level = "info"
462
- logToFile = ON # This is a comment.
463
- filePath = "./logs/app.log"
264
+ ^ Server // Definition of section (group) "Server"
265
+ host = 'localhost'
266
+ port = 8080
267
+ useTLS = OFF // "false" and "NO" works too
268
+
269
+ // Sub-section of "Server"
270
+ ^^ Login
271
+ username = 'user_name'
272
+ password = 'your_password_here'
464
273
 
465
- /END
274
+ /END // (only optional)
466
275
  `);
467
276
 
468
277
  console.log(config);
@@ -473,60 +282,41 @@ console.log(config);
473
282
  // JS object
474
283
  {
475
284
  App: {
476
- name: "Nested Example",
477
- version: "1.0.0",
478
- debug: false,
479
- Database: {
480
- host: "db.example.com",
481
- port: 3306,
482
- user: "appuser",
483
- password: "dbpassword",
484
- Pool: {
485
- min: 2,
486
- max: 10,
487
- idleTimeout: 300
488
- }
489
- },
490
- Logging: {
491
- level: "info",
492
- logToFile: true,
493
- filePath: "./logs/app.log"
285
+ title: 'My App',
286
+ items: 25,
287
+ debug: true
288
+ },
289
+ Server: {
290
+ host: 'localhost',
291
+ port: 8080,
292
+ useTLS: false,
293
+ Login: {
294
+ username: 'user_name',
295
+ password: 'your_password_here'
494
296
  }
495
297
  }
496
298
  }
497
299
  ```
498
300
 
499
- ---
500
-
501
- ## API
502
-
503
- Only the `YINI` class is exposed in the public API, with two static methods: `parse` and `parseFile`.
504
-
505
- ### `YINI.parse(yiniContent: string, strictMode?: boolean, bailSensitivity: 'auto' | 0 | 1 | 2 = "auto", includeMetaData = false): object`
506
-
507
- Parses YINI code from a string.
508
-
509
- **Params:**
510
- - `yiniContent`: The YINI configuration as a string.
511
- - `strictMode`: (optional, default `false`) Parse in strict mode.
512
- - `bailSensitivity`: (optional, default `"auto"`) Error tolerance level.
513
- * If `bailSensitivity` is `"auto"` then bail sensitivity level will be set to 0 if in non-strict mode, if in strict mode then level 1 will be used automatically.
514
- - `includeMetaData`: If true then additional meta data will be returned along the object.
515
-
516
- **Bail sensitivity levels:**
517
- - 0 = 'Ignore-Errors' // Don't bail on errors, persist and try to recover.
518
- - 1 = 'Abort-on-Errors'
519
- - 2 = 'Abort-Even-on-Warnings'
520
-
521
- Returns a JavaScript object representing the parsed configuration (YINI content).
522
-
523
- ### `YINI.parseFile(filePath: string, strictMode?: boolean, bailSensitivity: 'auto' | 0 | 1 | 2 = "auto", includeMetaData = false): object`
524
-
525
- Parses YINI code from a file.
526
- - `filePath`: Path to the `.yini` file.
527
- - Other parameters are the same as `parse(..)`.
528
-
529
- Returns a JavaScript object representing the parsed YINI configuration file.
301
+ ### Output in JSON:
302
+ ```json
303
+ {
304
+ "App": {
305
+ "title": "My App",
306
+ "items": 25,
307
+ "debug": true
308
+ },
309
+ "Server": {
310
+ "host": "localhost",
311
+ "port": 8080,
312
+ "useTLS": false,
313
+ "Login": {
314
+ "username": "user_name",
315
+ "password": "your_password_here"
316
+ }
317
+ }
318
+ }
319
+ ```
530
320
 
531
321
  ---
532
322
 
@@ -544,13 +334,26 @@ We welcome feedback, bug reports, feature requests, and code contributions!
544
334
  ---
545
335
 
546
336
  ## Links
547
- - ➡️ [Why YINI? Why another format!?](./RATIONALE.md) (rationale)
548
- - ➡️ [Intro to YINI Config Format](https://github.com/YINI-lang/yini-parser-typescript?tab=readme-ov-file#intro-to-yini-config-format) (learn YINI)
549
- - ➡️ [Read the YINI Specification](./YINI-Specification.md#table-of-contents) (spec)
550
- - ➡️ [Official YINI Parser on npm](https://www.npmjs.com/package/yini-parser) (npm)
551
- - ➡️ [YINI Parser GitHub Repo](https://github.com/YINI-lang/yini-parser-typescript) (GitHub)
552
- - ➡️ [YINI vs Other Formats](https://github.com/YINI-lang/YINI-spec/blob/develop/Docs/Examples%20of%20YINI%20vs%20Other%20Formats.md)
553
- - ➡️ [YINI Project](https://github.com/YINI-lang) (home)
337
+ - ➡️ [Getting Started: Intro to YINI Config Format](https://github.com/YINI-lang/YINI-spec/blob/develop/Docs/Intro-to-YINI-Config-Format.md)
338
+ *Beginner-friendly walkthrough and basic usage examples.*
339
+
340
+ - ➡️ [YINI Parser on npm](https://www.npmjs.com/package/yini-parser)
341
+ *Install and view package details.*
342
+
343
+ - ➡️ [Read the YINI Specification](https://github.com/YINI-lang/YINI-spec/blob/release/YINI-Specification.md#table-of-contents)
344
+ *Full formal spec for the YINI format, including syntax and features.*
345
+
346
+ - ➡️ [YINI CLI on GitHub](https://github.com/YINI-lang/yini-cli)
347
+ *TypeScript source code, issue tracker, and contributing guide.*
348
+
349
+ - ➡️ [YINI vs Other Formats](https://github.com/YINI-lang/YINI-spec/tree/release#-summary-difference-with-other-formats)
350
+ *How does YINI differ: comparison with INI, YAML, and JSON.*
351
+
352
+ - ➡️ [Why YINI? (Project Rationale)](https://github.com/YINI-lang/YINI-spec/blob/release/RATIONALE.md)
353
+ *Learn about the motivations and design decisions behind YINI.*
354
+
355
+ - ➡️ [YINI Project](https://github.com/YINI-lang)
356
+ *YINI home.*
554
357
 
555
358
  ---
556
359
 
package/dist/YINI.d.ts CHANGED
@@ -1,43 +1,66 @@
1
- import { TJSObject } from './core/types';
1
+ import { IAllUserOptions, TJSObject, TPreferredFailLevel } from './core/types';
2
2
  /**
3
3
  * This class is the public API, which exposes only parse(..) and
4
4
  * parseFile(..), rest of the implementation details are hidden.
5
5
  * @note Only parse and parseFile are public.
6
6
  */
7
7
  export default class YINI {
8
- static filePath: string;
8
+ private static g_tabSize;
9
9
  /**
10
- * Parse YINI content into a JavaScript object.
10
+ * @returns The number of spaces per tab character used in error messages.
11
+ */
12
+ static getTabSize(): number;
13
+ /**
14
+ * Overrides the number of spaces per tab character used in error messages.
15
+ * Allowed range: 1-32.
16
+ */
17
+ static setTabSize(spaces: number): void;
18
+ /**
19
+ * Parse inline YINI content into a JavaScript object.
11
20
  *
12
21
  * @param yiniContent YINI code as a string (multi‑line content supported).
13
22
  * @param strictMode If `true`, enforce strict parsing rules (e.g. require `/END`, disallow trailing commas).
14
- * @param bailSensitivity Controls how errors and warnings are handled:
15
- * - `'auto'` : Auto‑select level (strict→1, lenient→0)
23
+ * @param failLevel Preferred bail sensitivity level, controls how errors and warnings are handled:
24
+ * - `'auto'` (default) : Auto‑select level (strict→1, lenient→0)
16
25
  * - `0` / `'Ignore-Errors'` : Continue parsing despite errors; log them and attempt recovery.
17
26
  * - `1` / `'Abort-on-Errors'` : Stop parsing on the first error.
18
27
  * - `2` / `'Abort-Even-on-Warnings'`: Stop parsing on the first warning **or** error.
19
28
  * @param includeMetaData If `true`, return additional metadata (e.g. warnings, statistics) alongside the parsed object.
20
29
  *
21
- * @note The order of properties in each output object may differ from their order in the YINI source.
30
+ * @returns A JavaScript object representing the parsed YINI content.
31
+ */
32
+ static parse(yiniContent: string, strictMode?: boolean, failLevel?: TPreferredFailLevel, includeMetaData?: boolean): TJSObject;
33
+ /**
34
+ * Parse inline YINI content into a JavaScript object, using an options object for configuration.
35
+ *
36
+ * @param yiniContent YINI code as a string (multi‑line content supported).
37
+ * @param options Optional settings to customize parsing and/or results, useful if you need more control.
22
38
  *
23
39
  * @returns A JavaScript object representing the parsed YINI content.
24
40
  */
25
- static parse: (yiniContent: string, strictMode?: boolean, bailSensitivity?: "auto" | 0 | 1 | 2, includeMetaData?: boolean) => TJSObject;
41
+ static parse(yiniContent: string, options?: IAllUserOptions): TJSObject;
26
42
  /**
27
43
  * Parse a YINI file into a JavaScript object.
28
44
  *
29
45
  * @param yiniFile Path to the YINI file.
30
46
  * @param strictMode If `true`, enforce strict parsing rules (e.g. require `/END`, disallow trailing commas).
31
- * @param bailSensitivity Controls how errors and warnings are handled:
32
- * - `'auto'` : Auto‑select level (strict→1, lenient→0)
47
+ * @param failLevel Preferred bail sensitivity level, controls how errors and warnings are handled:
48
+ * - `'auto'` (default) : Auto‑select level (strict→1, lenient→0)
33
49
  * - `0` / `'Ignore-Errors'` : Continue parsing despite errors; log them and attempt recovery.
34
50
  * - `1` / `'Abort-on-Errors'` : Stop parsing on the first error.
35
51
  * - `2` / `'Abort-Even-on-Warnings'`: Stop parsing on the first warning **or** error.
36
52
  * @param includeMetaData If `true`, return additional metadata (e.g. warnings, statistics) alongside the parsed object.
37
53
  *
38
- * @note The order of properties in each output object may differ from their order in the YINI source.
54
+ * @returns A JavaScript object representing the parsed YINI content.
55
+ */
56
+ static parseFile(filePath: string, strictMode?: boolean, failLevel?: TPreferredFailLevel, includeMetaData?: boolean): TJSObject;
57
+ /**
58
+ * Parse a YINI file into a JavaScript object, using an options object for configuration.
59
+ *
60
+ * @param yiniFile Path to the YINI file.
61
+ * @param options Optional settings to customize parsing and/or results, useful if you need more control.
39
62
  *
40
63
  * @returns A JavaScript object representing the parsed YINI content.
41
64
  */
42
- static parseFile: (filePath: string, strictMode?: boolean, bailSensitivity?: "auto" | 0 | 1 | 2, includeMetaData?: boolean) => TJSObject;
65
+ static parseFile(filePath: string, options?: IAllUserOptions): TJSObject;
43
66
  }