yini-parser 1.0.2-beta → 1.2.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.
- package/CHANGELOG.md +50 -0
- package/README.md +83 -98
- package/dist/YINI.d.ts +162 -23
- package/dist/YINI.js +183 -99
- package/dist/YINI.js.map +1 -0
- package/dist/config/env.js +1 -0
- package/dist/config/env.js.map +1 -0
- package/dist/core/astBuilder.d.ts +191 -0
- package/dist/core/astBuilder.js +840 -0
- package/dist/core/astBuilder.js.map +1 -0
- package/dist/core/{ErrorDataHandler.d.ts → errorDataHandler.d.ts} +21 -19
- package/dist/core/errorDataHandler.js +271 -0
- package/dist/core/errorDataHandler.js.map +1 -0
- package/dist/core/internalTypes.d.ts +121 -0
- package/dist/core/internalTypes.js +16 -0
- package/dist/core/internalTypes.js.map +1 -0
- package/dist/core/objectBuilder.d.ts +10 -4
- package/dist/core/objectBuilder.js +127 -163
- package/dist/core/objectBuilder.js.map +1 -0
- package/dist/core/options/failLevel.d.ts +3 -0
- package/dist/core/options/failLevel.js +27 -0
- package/dist/core/options/failLevel.js.map +1 -0
- package/dist/core/options/normalizeOptions.d.ts +5 -0
- package/dist/core/options/normalizeOptions.js +53 -0
- package/dist/core/options/normalizeOptions.js.map +1 -0
- package/dist/core/options/parserOptionsConstants.d.ts +7 -0
- package/dist/core/options/parserOptionsConstants.js +37 -0
- package/dist/core/options/parserOptionsConstants.js.map +1 -0
- package/dist/core/pipeline.d.ts +18 -0
- package/dist/core/pipeline.js +323 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/resultMetadataBuilder.d.ts +19 -0
- package/dist/core/resultMetadataBuilder.js +166 -0
- package/dist/core/resultMetadataBuilder.js.map +1 -0
- package/dist/core/runtime.d.ts +17 -0
- package/dist/core/runtime.js +189 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/dev/main.d.ts +1 -0
- package/dist/dev/main.js +374 -0
- package/dist/dev/main.js.map +1 -0
- package/dist/grammar/generated/YiniLexer.d.ts +74 -0
- package/dist/grammar/generated/YiniLexer.js +415 -0
- package/dist/grammar/generated/YiniLexer.js.map +1 -0
- package/dist/grammar/{YiniParser.d.ts → generated/YiniParser.d.ts} +167 -150
- package/dist/grammar/{YiniParser.js → generated/YiniParser.js} +1242 -1202
- package/dist/grammar/generated/YiniParser.js.map +1 -0
- package/dist/grammar/{YiniParserVisitor.d.ts → generated/YiniParserVisitor.d.ts} +59 -45
- package/dist/grammar/{YiniParserVisitor.js → generated/YiniParserVisitor.js} +2 -1
- package/dist/grammar/generated/YiniParserVisitor.js.map +1 -0
- package/dist/index.d.ts +43 -2
- package/dist/index.js +62 -101
- package/dist/index.js.map +1 -0
- package/dist/parsers/extractHeaderParts.d.ts +4 -3
- package/dist/parsers/extractHeaderParts.js +3 -1
- package/dist/parsers/extractHeaderParts.js.map +1 -0
- package/dist/parsers/extractSignificantYiniLine.js +2 -1
- package/dist/parsers/extractSignificantYiniLine.js.map +1 -0
- package/dist/parsers/parseBoolean.d.ts +1 -1
- package/dist/parsers/parseBoolean.js +3 -1
- package/dist/parsers/parseBoolean.js.map +1 -0
- package/dist/parsers/parseNull.js +1 -0
- package/dist/parsers/parseNull.js.map +1 -0
- package/dist/parsers/parseNumber.d.ts +8 -3
- package/dist/parsers/parseNumber.js +22 -7
- package/dist/parsers/parseNumber.js.map +1 -0
- package/dist/parsers/parseSectionHeader.d.ts +5 -4
- package/dist/parsers/parseSectionHeader.js +3 -1
- package/dist/parsers/parseSectionHeader.js.map +1 -0
- package/dist/parsers/parseString.js +3 -3
- package/dist/parsers/parseString.js.map +1 -0
- package/dist/types/index.d.ts +198 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/number.d.ts +3 -0
- package/dist/utils/number.js +19 -0
- package/dist/utils/number.js.map +1 -0
- package/dist/utils/object.d.ts +67 -0
- package/dist/utils/object.js +125 -0
- package/dist/utils/object.js.map +1 -0
- package/dist/utils/pathAndFileName.js +1 -0
- package/dist/utils/pathAndFileName.js.map +1 -0
- package/dist/utils/print.d.ts +2 -2
- package/dist/utils/print.js +11 -6
- package/dist/utils/print.js.map +1 -0
- package/dist/utils/string.d.ts +26 -1
- package/dist/utils/string.js +48 -4
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/system.d.ts +15 -0
- package/dist/utils/system.js +22 -0
- package/dist/utils/system.js.map +1 -0
- package/dist/{yiniHelpers.d.ts → utils/yiniHelpers.d.ts} +3 -0
- package/dist/{yiniHelpers.js → utils/yiniHelpers.js} +46 -9
- package/dist/utils/yiniHelpers.js.map +1 -0
- package/package.json +7 -5
- package/dist/core/ErrorDataHandler.js +0 -203
- package/dist/core/YINIVisitor.d.ts +0 -158
- package/dist/core/YINIVisitor.js +0 -1008
- package/dist/core/types.d.ts +0 -59
- package/dist/core/types.js +0 -36
- package/dist/grammar/YiniLexer.d.ts +0 -68
- package/dist/grammar/YiniLexer.js +0 -379
- package/dist/parseEntry.d.ts +0 -2
- package/dist/parseEntry.js +0 -185
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## --dev/uppcoming--
|
|
4
|
+
|
|
5
|
+
## 1.2.0-beta - 2025 Sep
|
|
6
|
+
- **Fixed:** `parseFile()` now correctly passes through all options (e.g. `includeDiagnostics`) so they work and matches as in `parse(..)`.
|
|
7
|
+
- **Fixed:** typo (`in in`) in file parsing error message.
|
|
8
|
+
- **Updated:** metadata structure bumped to version 1.1.0, and below added (among other things):
|
|
9
|
+
```ts
|
|
10
|
+
preservesOrder: true // Member/section order: platform-, implementation-, and language-specific. Not mandated by the YINI spec.
|
|
11
|
+
orderGuarantee: 'implementation-defined'
|
|
12
|
+
orderNotes?: string
|
|
13
|
+
```
|
|
14
|
+
- **Refactored:** the static public (user-facing) YINI class to use per-invocation runtime state, preventing race conditions in runtime info when multiple calls to `parse(..)` / `parseFile(..)` run in parallel.
|
|
15
|
+
- **Refactored file layout:** Moved and renamed files in `src/`
|
|
16
|
+
* File `src/parseEntry.ts` renamed and moved to `src/src/pipeline.ts`,
|
|
17
|
+
- And in that file, rename the method/function `_parseEntry(..)` to `runPipeline(..)`.
|
|
18
|
+
* Renamed the file `core/types.ts` to `core/internalTypes.ts`
|
|
19
|
+
- And moved public (user-facing) types and interfaces into its own file `src/types/index.ts`.
|
|
20
|
+
* Moved the file `src/yiniHelpers.ts` to `src/utils/yiniHelpers.ts`.
|
|
21
|
+
- **Renamed:** `includeMetaData` to `includeMetadata`.
|
|
22
|
+
- **Updated:** Codebase now consistently uses the `ParsedObject` type,
|
|
23
|
+
replacing the older `TJSObject` type for representing parsed YINI.
|
|
24
|
+
- **Docs:** Expanded and improved TSDoc of several of the functions in the public API.
|
|
25
|
+
- **Internal:** Unit tests are now colocated with their source code files in `src/**`. So there is 1:1 visibility between code and its unit tests, and less chance of missing coverage, etc.
|
|
26
|
+
|
|
27
|
+
## 1.1.0-beta - 2025 Sep
|
|
28
|
+
### Parser
|
|
29
|
+
- **Reimplemented parser from scratch** (`core/ASTBuilder.ts`) using the refactored grammar for a much cleaner and more maintainable design.
|
|
30
|
+
- **Build logic reimplemented** (`core/objectBuilder.ts`) for improved reliability and consistency.
|
|
31
|
+
- **Error reporting enhanced** to be more user-friendly and informative.
|
|
32
|
+
- **Fixed bug sometimes wrong line** Sometimes incorrect line number in error messages are now reported accurately.
|
|
33
|
+
- Renamed option `bailSensitivity` to a more shorter and user-friendly name `failLevel`.
|
|
34
|
+
- **Extended `parse` and `parseFile` methods** to support an options-object form.
|
|
35
|
+
Example:
|
|
36
|
+
```ts
|
|
37
|
+
const config= YINI.parse(yini, {
|
|
38
|
+
strictMode: false,
|
|
39
|
+
failLevel: 'auto',
|
|
40
|
+
includeMetadata: false,
|
|
41
|
+
requireDocTerminator: false,
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
### Specification Alignment
|
|
45
|
+
- Updated to follow the **latest YINI specification (v1.0.0-rc.3)**.
|
|
46
|
+
- Document terminator `/END` is now optional in both lenient and strict mode.
|
|
47
|
+
### Meta Data
|
|
48
|
+
- The optional returned **meta data structure** has been redesigned.
|
|
49
|
+
- Now includes improved organization.
|
|
50
|
+
- **Timing support** added for detailed performance insight.
|
|
51
|
+
- Grouping with **source**, **structure**, **diagnostics**, etc.
|
|
52
|
+
|
|
3
53
|
## 1.0.2-beta - 2025 Aug
|
|
4
54
|
- Fixed issues with floats, including negative and exponential numbers with new test files here: `tests/fixed-issues/issue-32/*`
|
|
5
55
|
- 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`).
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ YINI (Yet another INI): YINI is a configuration format designed for readability
|
|
|
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
|
|
|
@@ -58,20 +58,25 @@ YINI is a simple, human-friendly configuration format inspired by INI and JSON.
|
|
|
58
58
|
|
|
59
59
|
## Quick Start
|
|
60
60
|
|
|
61
|
-
A
|
|
61
|
+
A small example using YINI in TypeScript/JavaScript:
|
|
62
62
|
```ts
|
|
63
63
|
import YINI from 'yini-parser'
|
|
64
64
|
|
|
65
65
|
const config = YINI.parse(`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
75
80
|
`)
|
|
76
81
|
|
|
77
82
|
// To parse from a file instead:
|
|
@@ -89,15 +94,15 @@ My Title
|
|
|
89
94
|
false
|
|
90
95
|
|
|
91
96
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
App: {
|
|
98
|
+
name: 'My Title',
|
|
99
|
+
items: 25,
|
|
100
|
+
darkMode: true,
|
|
101
|
+
Special: {
|
|
102
|
+
primaryColor: 3368601,
|
|
103
|
+
isCaching: false
|
|
104
|
+
}
|
|
99
105
|
}
|
|
100
|
-
}
|
|
101
106
|
}
|
|
102
107
|
```
|
|
103
108
|
|
|
@@ -229,45 +234,44 @@ These examples are also included in the npm package.
|
|
|
229
234
|
|
|
230
235
|
---
|
|
231
236
|
|
|
232
|
-
##
|
|
237
|
+
## Bigger Example
|
|
233
238
|
|
|
234
239
|
```js
|
|
235
240
|
const YINI = require('yini-parser').default; // Or: import YINI from 'yini-parser';
|
|
236
241
|
|
|
237
242
|
const config = YINI.parse(`
|
|
238
|
-
|
|
239
|
-
|
|
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
|
|
240
257
|
*/
|
|
241
258
|
|
|
242
|
-
|
|
259
|
+
^ App // Definition of section (group) "App"
|
|
260
|
+
title = 'My App'
|
|
261
|
+
items = 25
|
|
262
|
+
debug = ON // "true" and "YES" works too
|
|
243
263
|
|
|
244
|
-
^
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
^^
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
user = "appuser"
|
|
254
|
-
--password = "dbpassword" # Disabled line due to --.
|
|
255
|
-
//password = "dbpassword" # Not sure yet about this pw.
|
|
256
|
-
password = "dbpassword" # Keep this secret.
|
|
257
|
-
|
|
258
|
-
// Commenting with slashes works too.
|
|
259
|
-
^^^ Pool
|
|
260
|
-
min = 2
|
|
261
|
-
max = 10
|
|
262
|
-
idleTimeout = 300
|
|
263
|
-
|
|
264
|
-
/* Block comment on a single line. */
|
|
265
|
-
^^ Logging
|
|
266
|
-
level = "info"
|
|
267
|
-
logToFile = ON # This is a comment.
|
|
268
|
-
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'
|
|
269
273
|
|
|
270
|
-
/END
|
|
274
|
+
/END // (only optional)
|
|
271
275
|
`);
|
|
272
276
|
|
|
273
277
|
console.log(config);
|
|
@@ -278,60 +282,41 @@ console.log(config);
|
|
|
278
282
|
// JS object
|
|
279
283
|
{
|
|
280
284
|
App: {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
debug:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
idleTimeout: 300
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
Logging: {
|
|
296
|
-
level: "info",
|
|
297
|
-
logToFile: true,
|
|
298
|
-
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'
|
|
299
296
|
}
|
|
300
297
|
}
|
|
301
298
|
}
|
|
302
299
|
```
|
|
303
300
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
- 1 = 'Abort-on-Errors'
|
|
324
|
-
- 2 = 'Abort-Even-on-Warnings'
|
|
325
|
-
|
|
326
|
-
Returns a JavaScript object representing the parsed configuration (YINI content).
|
|
327
|
-
|
|
328
|
-
### `YINI.parseFile(filePath: string, strictMode?: boolean, bailSensitivity: 'auto' | 0 | 1 | 2 = "auto", includeMetaData = false): object`
|
|
329
|
-
|
|
330
|
-
Parses YINI code from a file.
|
|
331
|
-
- `filePath`: Path to the `.yini` file.
|
|
332
|
-
- Other parameters are the same as `parse(..)`.
|
|
333
|
-
|
|
334
|
-
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
|
+
```
|
|
335
320
|
|
|
336
321
|
---
|
|
337
322
|
|
package/dist/YINI.d.ts
CHANGED
|
@@ -1,43 +1,182 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AllUserOptions, ParsedObject, PreferredFailLevel, YiniParseResult } from './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
|
|
8
|
+
private static g_tabSize;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
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.
|
|
20
|
+
*
|
|
21
|
+
* @param yiniContent YINI code as a string (multi‑line content supported).
|
|
22
|
+
* @param strictMode If `true`, enforce strict parsing rules (e.g. require `/END`, disallow trailing commas).
|
|
23
|
+
* @param failLevel Preferred bail sensitivity level, controls how errors and warnings are handled:
|
|
24
|
+
* - `'auto'` (default) : Auto‑select level (strict → `'errors'`, lenient → `'ignore-errors'`)
|
|
25
|
+
* - `'ignore-errors'` : Continue parsing despite errors; log them and attempt recovery.
|
|
26
|
+
* - `'errors'` : Stop parsing on the first error.
|
|
27
|
+
* - `'warnings-and-errors'` : Stop parsing on the first warning **or** error.
|
|
28
|
+
* @param includeMetadata If `true`, return additional metadata (e.g. warnings, statistics) alongside the parsed object.
|
|
29
|
+
*
|
|
30
|
+
* @returns The parsed YINI content.
|
|
31
|
+
*
|
|
32
|
+
* By default (`includeMetadata = false`), this method returns a plain JavaScript object:
|
|
33
|
+
*
|
|
34
|
+
* `
|
|
35
|
+
* export type ParsedObject = any
|
|
36
|
+
* `
|
|
37
|
+
*
|
|
38
|
+
* If `includeMetadata = true`, the return value is wrapped in a container that also
|
|
39
|
+
* includes parsing metadata:
|
|
40
|
+
*
|
|
41
|
+
* `
|
|
42
|
+
* export interface YiniParseResult {
|
|
43
|
+
* result: ParsedObject
|
|
44
|
+
* meta: ResultMetadata
|
|
45
|
+
* }
|
|
46
|
+
* `
|
|
47
|
+
*/
|
|
48
|
+
static parse(yiniContent: string, strictMode?: boolean, failLevel?: PreferredFailLevel, includeMetadata?: boolean): ParsedObject | YiniParseResult;
|
|
49
|
+
/**
|
|
50
|
+
* Parse inline YINI content into a JavaScript object, using an options object for configuration.
|
|
11
51
|
*
|
|
12
52
|
* @param yiniContent YINI code as a string (multi‑line content supported).
|
|
13
|
-
* @param
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
53
|
+
* @param options Optional settings to customize parsing and/or results, useful if you need more control.
|
|
54
|
+
* For all options, see types/IAllUserOptions.
|
|
55
|
+
*
|
|
56
|
+
* @param options.failLevel - Minimum severity that should cause the parse to fail.
|
|
57
|
+
* Accepts:
|
|
58
|
+
* `'ignore-errors'` - Don't bail/fail on error, persist and try to recover.
|
|
59
|
+
* `'errors'` - Stop parsing on the first error.
|
|
60
|
+
* `'warnings-and-errors'` - Stop parsing on the first warning or error.
|
|
61
|
+
* (Type: TPreferredFailLevel; exact behavior is implementation-defined.)
|
|
62
|
+
* @param options.includeDiagnostics - Include diagnostics in the returned metadata.
|
|
63
|
+
* Requires: `includeMetadata = true`. Ignored otherwise.
|
|
64
|
+
* @param options.includeMetadata - Attach a metadata object to the parse result
|
|
65
|
+
* (e.g., timings, diagnostics).
|
|
66
|
+
* @param options.includeTiming - Include timing information for parser phases in metadata.
|
|
67
|
+
* Requires: `includeMetadata = true`. Ignored otherwise.
|
|
68
|
+
* @param options.onDuplicateKey - Strategy/handler when encountering a duplicate key.
|
|
69
|
+
* Allowed values: `'warn-and-keep-first'` | `'warn-and-overwrite'` | `'keep-first'` (silent, first wins) | `'overwrite'` (silent, last wins) | `'error'`.
|
|
70
|
+
* @param options.preserveUndefinedInMeta - Keep properties with value `undefined` inside
|
|
71
|
+
* the returned metadata. Requires: `includeMetadata = true`. Ignored otherwise.
|
|
72
|
+
* @param options.requireDocTerminator - Controls whether a document terminator is required.
|
|
73
|
+
* Allowed values: `'optional'` | `'warn-if-missing'` | `'required'`.
|
|
74
|
+
* @param options.strictMode - Enable stricter syntax and well-formedness checks according
|
|
75
|
+
* to the spec (exact rules are implementation-defined).
|
|
76
|
+
* @param options.suppressWarnings - Suppress warnings sent to the console/log.
|
|
77
|
+
* Does not affect warnings included in returned metadata.
|
|
78
|
+
* @param options.treatEmptyValueAsNull - How to treat an explicitly empty value on the
|
|
79
|
+
* right-hand side of '='. Allowed values: `'allow'` | `'allow-with-warning'` | `'disallow'`.
|
|
80
|
+
*
|
|
81
|
+
* @returns The parsed YINI content.
|
|
20
82
|
*
|
|
21
|
-
*
|
|
83
|
+
* By default (`includeMetadata = false`), this method returns a plain JavaScript object:
|
|
22
84
|
*
|
|
23
|
-
*
|
|
85
|
+
* `
|
|
86
|
+
* export type ParsedObject = any
|
|
87
|
+
* `
|
|
88
|
+
*
|
|
89
|
+
* If `includeMetadata = true`, the return value is wrapped in a container that also
|
|
90
|
+
* includes parsing metadata:
|
|
91
|
+
*
|
|
92
|
+
* `
|
|
93
|
+
* export interface YiniParseResult {
|
|
94
|
+
* result: ParsedObject
|
|
95
|
+
* meta: ResultMetadata
|
|
96
|
+
* }
|
|
97
|
+
* `
|
|
24
98
|
*/
|
|
25
|
-
static parse
|
|
99
|
+
static parse(yiniContent: string, options?: AllUserOptions): ParsedObject | YiniParseResult;
|
|
26
100
|
/**
|
|
27
101
|
* Parse a YINI file into a JavaScript object.
|
|
28
102
|
*
|
|
103
|
+
* @param yiniFile Path to the YINI file.
|
|
104
|
+
* @param strictMode If `true`, enforce strict parsing rules (e.g. require `/END`, disallow trailing commas).
|
|
105
|
+
* @param failLevel Preferred bail sensitivity level, controls how errors and warnings are handled:
|
|
106
|
+
* - `'auto'` (default) : Auto‑select level (strict → `'errors'`, lenient → `'ignore-errors'`)
|
|
107
|
+
* - `'ignore-errors'` : Continue parsing despite errors; log them and attempt recovery.
|
|
108
|
+
* - `'errors'` : Stop parsing on the first error.
|
|
109
|
+
* - `'warnings-and-errors'` : Stop parsing on the first warning **or** error.
|
|
110
|
+
* @param includeMetadata If `true`, return additional metadata (e.g. warnings, statistics) alongside the parsed object.
|
|
111
|
+
*
|
|
112
|
+
* @returns The parsed YINI content.
|
|
113
|
+
*
|
|
114
|
+
* By default (`includeMetadata = false`), this method returns a plain JavaScript object:
|
|
115
|
+
*
|
|
116
|
+
* `
|
|
117
|
+
* export type ParsedObject = any
|
|
118
|
+
* `
|
|
119
|
+
*
|
|
120
|
+
* If `includeMetadata = true`, the return value is wrapped in a container that also
|
|
121
|
+
* includes parsing metadata:
|
|
122
|
+
*
|
|
123
|
+
* `
|
|
124
|
+
* export interface YiniParseResult {
|
|
125
|
+
* result: ParsedObject
|
|
126
|
+
* meta: ResultMetadata
|
|
127
|
+
* }
|
|
128
|
+
* `
|
|
129
|
+
*/
|
|
130
|
+
static parseFile(filePath: string, strictMode?: boolean, failLevel?: PreferredFailLevel, includeMetadata?: boolean): ParsedObject | YiniParseResult;
|
|
131
|
+
/**
|
|
132
|
+
* Parse a YINI file into a JavaScript object, using an options object for configuration.
|
|
133
|
+
*
|
|
29
134
|
* @param yiniFile Path to the YINI file.
|
|
30
|
-
* @param
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
135
|
+
* @param options Optional settings to customize parsing and/or results, useful if you need more control.
|
|
136
|
+
* For all options, see types/IAllUserOptions.
|
|
137
|
+
*
|
|
138
|
+
* @param options.failLevel - Minimum severity that should cause the parse to fail.
|
|
139
|
+
* Accepts:
|
|
140
|
+
* `'ignore-errors'` - Don't bail/fail on error, persist and try to recover.
|
|
141
|
+
* `'errors'` - Stop parsing on the first error.
|
|
142
|
+
* `'warnings-and-errors'` - Stop parsing on the first warning or error.
|
|
143
|
+
* (Type: TPreferredFailLevel; exact behavior is implementation-defined.)
|
|
144
|
+
* @param options.includeDiagnostics - Include diagnostics in the returned metadata.
|
|
145
|
+
* Requires: `includeMetadata = true`. Ignored otherwise.
|
|
146
|
+
* @param options.includeMetadata - Attach a metadata object to the parse result
|
|
147
|
+
* (e.g., timings, diagnostics).
|
|
148
|
+
* @param options.includeTiming - Include timing information for parser phases in metadata.
|
|
149
|
+
* Requires: `includeMetadata = true`. Ignored otherwise.
|
|
150
|
+
* @param options.onDuplicateKey - Strategy/handler when encountering a duplicate key.
|
|
151
|
+
* Allowed values: `'warn-and-keep-first'` | `'warn-and-overwrite'` | `'keep-first'` (silent, first wins) | `'overwrite'` (silent, last wins) | `'error'`.
|
|
152
|
+
* @param options.preserveUndefinedInMeta - Keep properties with value `undefined` inside
|
|
153
|
+
* the returned metadata. Requires: `includeMetadata = true`. Ignored otherwise.
|
|
154
|
+
* @param options.requireDocTerminator - Controls whether a document terminator is required.
|
|
155
|
+
* Allowed values: `'optional'` | `'warn-if-missing'` | `'required'`.
|
|
156
|
+
* @param options.strictMode - Enable stricter syntax and well-formedness checks according
|
|
157
|
+
* to the spec (exact rules are implementation-defined).
|
|
158
|
+
* @param options.suppressWarnings - Suppress warnings sent to the console/log.
|
|
159
|
+
* Does not affect warnings included in returned metadata.
|
|
160
|
+
* @param options.treatEmptyValueAsNull - How to treat an explicitly empty value on the
|
|
161
|
+
* right-hand side of '='. Allowed values: `'allow'` | `'allow-with-warning'` | `'disallow'`.
|
|
162
|
+
*
|
|
163
|
+
* @returns The parsed YINI content.
|
|
164
|
+
*
|
|
165
|
+
* By default (`includeMetadata = false`), this method returns a plain JavaScript object:
|
|
166
|
+
*
|
|
167
|
+
* `
|
|
168
|
+
* export type ParsedObject = any
|
|
169
|
+
* `
|
|
37
170
|
*
|
|
38
|
-
*
|
|
171
|
+
* If `includeMetadata = true`, the return value is wrapped in a container that also
|
|
172
|
+
* includes parsing metadata:
|
|
39
173
|
*
|
|
40
|
-
*
|
|
174
|
+
* `
|
|
175
|
+
* export interface YiniParseResult {
|
|
176
|
+
* result: ParsedObject
|
|
177
|
+
* meta: ResultMetadata
|
|
178
|
+
* }
|
|
179
|
+
* `
|
|
41
180
|
*/
|
|
42
|
-
static parseFile
|
|
181
|
+
static parseFile(filePath: string, options?: AllUserOptions): ParsedObject | YiniParseResult;
|
|
43
182
|
}
|