yini-parser 1.1.0-beta → 1.3.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 -2
- package/README.md +2 -2
- package/dist/YINI.d.ts +155 -27
- package/dist/YINI.js +145 -174
- 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 → astBuilder.d.ts} +4 -4
- package/dist/core/{ASTBuilder.js → astBuilder.js} +82 -69
- package/dist/core/astBuilder.js.map +1 -0
- package/dist/core/{ErrorDataHandler.d.ts → errorDataHandler.d.ts} +16 -10
- package/dist/core/{ErrorDataHandler.js → errorDataHandler.js} +115 -109
- package/dist/core/errorDataHandler.js.map +1 -0
- package/dist/core/internalTypes.d.ts +127 -0
- package/dist/core/{types.js → internalTypes.js} +6 -0
- package/dist/core/internalTypes.js.map +1 -0
- package/dist/core/objectBuilder.d.ts +2 -2
- package/dist/core/objectBuilder.js +1 -0
- package/dist/core/objectBuilder.js.map +1 -0
- package/dist/core/options/defaultParserOptions.d.ts +17 -0
- package/dist/core/options/defaultParserOptions.js +46 -0
- package/dist/core/options/defaultParserOptions.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/optionsFunctions.d.ts +8 -0
- package/dist/core/options/optionsFunctions.js +62 -0
- package/dist/core/options/optionsFunctions.js.map +1 -0
- package/dist/core/parsingRules/modeFromRulesMatcher.d.ts +8 -0
- package/dist/core/parsingRules/modeFromRulesMatcher.js +114 -0
- package/dist/core/parsingRules/modeFromRulesMatcher.js.map +1 -0
- package/dist/core/parsingRules/rulesConstAndGuards.d.ts +7 -0
- package/dist/core/parsingRules/rulesConstAndGuards.js +35 -0
- package/dist/core/parsingRules/rulesConstAndGuards.js.map +1 -0
- package/dist/core/pipeline/errorListeners.d.ts +18 -0
- package/dist/core/pipeline/errorListeners.js +107 -0
- package/dist/core/pipeline/errorListeners.js.map +1 -0
- package/dist/core/pipeline/pipeline.d.ts +18 -0
- package/dist/core/pipeline/pipeline.js +244 -0
- package/dist/core/pipeline/pipeline.js.map +1 -0
- package/dist/core/resultMetadataBuilder.d.ts +19 -0
- package/dist/core/resultMetadataBuilder.js +187 -0
- package/dist/core/resultMetadataBuilder.js.map +1 -0
- package/dist/core/runtime.d.ts +21 -0
- package/dist/core/runtime.js +201 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/dev/main.d.ts +1 -0
- package/dist/dev/main.js +305 -0
- package/dist/dev/main.js.map +1 -0
- package/dist/grammar/{YiniLexer.js → generated/YiniLexer.js} +2 -1
- package/dist/grammar/generated/YiniLexer.js.map +1 -0
- package/dist/grammar/{YiniParser.js → generated/YiniParser.js} +2 -1
- package/dist/grammar/generated/YiniParser.js.map +1 -0
- package/dist/grammar/{YiniParserVisitor.js → generated/YiniParserVisitor.js} +2 -1
- package/dist/grammar/generated/YiniParserVisitor.js.map +1 -0
- package/dist/index.d.ts +40 -1
- package/dist/index.js +60 -359
- package/dist/index.js.map +1 -0
- package/dist/parsers/extractHeaderParts.d.ts +2 -2
- package/dist/parsers/extractHeaderParts.js +2 -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.js +1 -0
- 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.js +1 -0
- package/dist/parsers/parseNumber.js.map +1 -0
- package/dist/parsers/parseSectionHeader.d.ts +3 -3
- package/dist/parsers/parseSectionHeader.js +2 -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 +219 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/number.js +1 -0
- package/dist/utils/number.js.map +1 -0
- package/dist/utils/object.d.ts +12 -0
- package/dist/utils/object.js +41 -1
- 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 +5 -0
- package/dist/utils/string.js +10 -1
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/system.js +1 -0
- package/dist/utils/system.js.map +1 -0
- package/dist/{yiniHelpers.d.ts → utils/yiniHelpers.d.ts} +1 -1
- package/dist/{yiniHelpers.js → utils/yiniHelpers.js} +3 -2
- package/dist/utils/yiniHelpers.js.map +1 -0
- package/examples/basic-output.js +12 -12
- package/package.json +11 -6
- package/dist/core/types.d.ts +0 -249
- package/dist/parseEntry.d.ts +0 -3
- package/dist/parseEntry.js +0 -456
- /package/dist/grammar/{YiniLexer.d.ts → generated/YiniLexer.d.ts} +0 -0
- /package/dist/grammar/{YiniParser.d.ts → generated/YiniParser.d.ts} +0 -0
- /package/dist/grammar/{YiniParserVisitor.d.ts → generated/YiniParserVisitor.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.3.0-beta - 2025 Sep
|
|
4
|
+
- **Fixed:** bug where `buildResultMetadata(..)` could occasionally produce an `undefined` error.
|
|
5
|
+
- **Renamed:** some public (user facing) interfaces to be more ergonomic for end users:
|
|
6
|
+
* `AllUserOptions` to `ParseOptions`
|
|
7
|
+
* `PrimaryUserParams` to `BasicOptions`
|
|
8
|
+
- **Renamed:** public (user facing) parsing rule type to be more ergonomic for end users:
|
|
9
|
+
* `OnDuplicateKey` to `DuplicateKeyPolicy`
|
|
10
|
+
- **Clarified:** the `strictMode` parameter in TSDoc: it defines the baseline
|
|
11
|
+
ruleset (true = strict, false = lenient). It's only a starting
|
|
12
|
+
point—rule-specific options (e.g., `treatEmptyValueAsNull`, `onDuplicateKey`)
|
|
13
|
+
may override parts of that ruleset. When overrides are provided, the
|
|
14
|
+
effective mode becomes custom.
|
|
15
|
+
- **New:** Added user facing parsing rule value types `DocumentTerminatorRule` and `EmptyValueRule`.
|
|
16
|
+
- **New:** Added `quiet` option, prints only errors to the console and warnings/info/etc. are not printed. This does not affect diagnostics captured in metadata.
|
|
17
|
+
- **New:** Added `silent` option, no console output will be outputted at all, not even errors. Programmatic callers should rely on returned metadata, CLI users should rely on the exit code.
|
|
18
|
+
- **(Heads-up) New:** Added `throwOnError` option, when `true` (default) the parser throws on parse errors, when `false` errors are reported via diagnostics without throwing.
|
|
19
|
+
- **Current default:** `true`.
|
|
20
|
+
- **Planned change:** Next release will switch the default to `false`.
|
|
21
|
+
- **Action:** Set throwOnError: true (to keep throwing) or `throwOnError: false` (to adopt the future behavior) explicitly.
|
|
22
|
+
- **Updated:** Metadata now includes `effectiveMode` in `meta.diagnostics.effectiveOptions`, and the metadata version has been bumped to `1.1.1`.
|
|
23
|
+
The fields `strictMode` and `effectiveOptions` in `meta.diagnostics` now correctly reflect when any rules have been overridden from the initially selected mode.
|
|
24
|
+
- **CI/Tooling (GitHub Actions):** Added security and quality checks:
|
|
25
|
+
- **Security:** CodeQL, dependency checke (`npm audit`) + lockfile-lint, Gitleaks (SARIF), Semgrep (SARIF).
|
|
26
|
+
- **Grammar drift check:** ANTLR-based verification to ensure generated sources are committed.
|
|
27
|
+
- **Regression tests:** run across a Node/OS matrix.
|
|
28
|
+
- **Releases:** npm publish with provenance (tag-driven).
|
|
29
|
+
- **Updated** the logic and message(s) when parser summary is shown.
|
|
30
|
+
|
|
31
|
+
## 1.2.0-beta - 2025 Sep
|
|
32
|
+
- **Fixed:** `parseFile()` now correctly passes through all options (e.g. `includeDiagnostics`) so they work and matches as in `parse(..)`.
|
|
33
|
+
- **Fixed:** typo (`in in`) in file parsing error message.
|
|
34
|
+
- **Updated:** metadata structure bumped to version 1.1.0, and below added (among other things):
|
|
35
|
+
```ts
|
|
36
|
+
preservesOrder: true // Member/section order: platform-, implementation-, and language-specific. Not mandated by the YINI spec.
|
|
37
|
+
orderGuarantee: 'implementation-defined'
|
|
38
|
+
orderNotes?: string
|
|
39
|
+
```
|
|
40
|
+
- **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.
|
|
41
|
+
- **Refactored file layout:** Moved and renamed files in `src/`
|
|
42
|
+
* File `src/parseEntry.ts` renamed and moved to `src/src/pipeline.ts`,
|
|
43
|
+
- And in that file, rename the method/function `_parseEntry(..)` to `runPipeline(..)`.
|
|
44
|
+
* Renamed the file `core/types.ts` to `core/internalTypes.ts`
|
|
45
|
+
- And moved public (user-facing) types and interfaces into its own file `src/types/index.ts`.
|
|
46
|
+
* Moved the file `src/yiniHelpers.ts` to `src/utils/yiniHelpers.ts`.
|
|
47
|
+
- **Renamed:** `includeMetaData` to `includeMetadata`.
|
|
48
|
+
- **Updated:** Codebase now consistently uses the `ParsedObject` type,
|
|
49
|
+
replacing the older `TJSObject` type for representing parsed YINI.
|
|
50
|
+
- **Docs:** Expanded and improved TSDoc of several of the functions in the public API.
|
|
51
|
+
- **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.
|
|
4
52
|
|
|
5
53
|
## 1.1.0-beta - 2025 Sep
|
|
6
54
|
### Parser
|
|
@@ -15,7 +63,7 @@
|
|
|
15
63
|
const config= YINI.parse(yini, {
|
|
16
64
|
strictMode: false,
|
|
17
65
|
failLevel: 'auto',
|
|
18
|
-
|
|
66
|
+
includeMetadata: false,
|
|
19
67
|
requireDocTerminator: false,
|
|
20
68
|
})
|
|
21
69
|
```
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
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
|
-
[](https://www.npmjs.com/package/yini-parser) [](https://www.npmjs.com/package/yini-parser) [](https://github.com/YINI-lang/yini-parser-typescript/actions/workflows/run-all-tests.yml) [](https://github.com/YINI-lang/yini-parser-typescript/actions/workflows/run-regression-tests.yml) [](https://github.com/YINI-lang/yini-parser-typescript/actions/workflows/run-grammar-drift-check.yml)
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
npm install yini-parser
|
|
@@ -17,7 +17,7 @@ YINI (Yet another INI): YINI is a configuration format designed for readability
|
|
|
17
17
|
|
|
18
18
|
➡️ See full [documentation or YINI format specification](https://github.com/YINI-lang/YINI-spec)
|
|
19
19
|
|
|
20
|
-
⭐ **Enjoying YINI?** If you
|
|
20
|
+
⭐ **Enjoying YINI?** If you like this project, [star it on GitHub](https://github.com/YINI-lang/yini-parser-typescript) — it helps a lot, thank you!
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
package/dist/YINI.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParsedObject, ParseOptions, 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.
|
|
@@ -18,49 +18,177 @@ export default class YINI {
|
|
|
18
18
|
/**
|
|
19
19
|
* Parse inline YINI content into a JavaScript object.
|
|
20
20
|
*
|
|
21
|
-
* @param yiniContent
|
|
22
|
-
* @param strictMode
|
|
23
|
-
* @param failLevel
|
|
24
|
-
* - `'auto'` (default)
|
|
25
|
-
* - `
|
|
26
|
-
* - `
|
|
27
|
-
* - `
|
|
28
|
-
* @param
|
|
29
|
-
*
|
|
30
|
-
* @returns
|
|
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 if and when parsing should stop on problems:
|
|
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 {ParsedObject | YiniParseResult} 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
|
+
* `
|
|
31
47
|
*/
|
|
32
|
-
static parse(yiniContent: string, strictMode?: boolean, failLevel?:
|
|
48
|
+
static parse(yiniContent: string, strictMode?: boolean, failLevel?: PreferredFailLevel, includeMetadata?: boolean): ParsedObject | YiniParseResult;
|
|
33
49
|
/**
|
|
34
50
|
* Parse inline YINI content into a JavaScript object, using an options object for configuration.
|
|
35
51
|
*
|
|
36
52
|
* @param yiniContent YINI code as a string (multi‑line content supported).
|
|
37
53
|
* @param options Optional settings to customize parsing and/or results, useful if you need more control.
|
|
54
|
+
* For all options, see types/ParseOptions.
|
|
55
|
+
*
|
|
56
|
+
* @param options.failLevel - Preferred bail sensitivity level, controls if and when parsing should stop on problems:
|
|
57
|
+
* Accepts:
|
|
58
|
+
* `'ignore-errors'` - Continue despite errors, 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.quiet - Show only errors, will suppress warnings and messages sent to the console/log.
|
|
73
|
+
* Does not affect warnings included in returned metadata.
|
|
74
|
+
* @param options.requireDocTerminator - Controls whether a document terminator is required.
|
|
75
|
+
* Allowed values: `'optional'` | `'warn-if-missing'` | `'required'`.
|
|
76
|
+
* @param options.silent - Suppress all output (even errors, exit code only).
|
|
77
|
+
* @param options.strictMode - Sets the baseline ruleset (true = strict, false = lenient).
|
|
78
|
+
* This is only a starting point: rule-specific options (e.g., `treatEmptyValueAsNull`,
|
|
79
|
+
* `onDuplicateKey`, etc.) can override parts of that ruleset. If any overrides are given,
|
|
80
|
+
* the effective mode becomes **custom** rather than purely strict/lenient.
|
|
81
|
+
* @param options.treatEmptyValueAsNull - How to treat an explicitly empty value on the
|
|
82
|
+
* right-hand side of '='. Allowed values: `'allow'` | `'allow-with-warning'` | `'disallow'`.
|
|
83
|
+
* @param options.throwOnError - Will throw on first parse error encountered.
|
|
84
|
+
* NOTE: Current default is `true`. The default will change to `false` in the next
|
|
85
|
+
* release. To avoid breaking changes, set this option explicitly.
|
|
86
|
+
*
|
|
87
|
+
* @returns {ParsedObject | YiniParseResult} The parsed YINI content.
|
|
88
|
+
*
|
|
89
|
+
* By default (`includeMetadata = false`), this method returns a plain JavaScript object:
|
|
90
|
+
*
|
|
91
|
+
* `
|
|
92
|
+
* export type ParsedObject = any
|
|
93
|
+
* `
|
|
94
|
+
*
|
|
95
|
+
* If `includeMetadata = true`, the return value is wrapped in a container that also
|
|
96
|
+
* includes parsing metadata:
|
|
38
97
|
*
|
|
39
|
-
*
|
|
98
|
+
* `
|
|
99
|
+
* export interface YiniParseResult {
|
|
100
|
+
* result: ParsedObject
|
|
101
|
+
* meta: ResultMetadata
|
|
102
|
+
* }
|
|
103
|
+
* `
|
|
40
104
|
*/
|
|
41
|
-
static parse(yiniContent: string, options?:
|
|
105
|
+
static parse(yiniContent: string, options?: ParseOptions): ParsedObject | YiniParseResult;
|
|
42
106
|
/**
|
|
43
107
|
* Parse a YINI file into a JavaScript object.
|
|
44
108
|
*
|
|
45
|
-
* @param yiniFile
|
|
46
|
-
* @param strictMode
|
|
47
|
-
* @param failLevel
|
|
48
|
-
* - `'auto'` (default)
|
|
49
|
-
* - `
|
|
50
|
-
* - `
|
|
51
|
-
* - `
|
|
52
|
-
* @param
|
|
53
|
-
*
|
|
54
|
-
* @returns
|
|
109
|
+
* @param yiniFile Path to the YINI file.
|
|
110
|
+
* @param strictMode If `true`, enforce strict parsing rules (e.g. require `/END`, disallow trailing commas).
|
|
111
|
+
* @param failLevel Preferred bail sensitivity level, controls if and when parsing should stop on problems:
|
|
112
|
+
* - `'auto'` (default) : Auto‑select level (strict → `'errors'`, lenient → `'ignore-errors'`)
|
|
113
|
+
* - `'ignore-errors'` : Continue parsing despite errors; log them and attempt recovery.
|
|
114
|
+
* - `'errors'` : Stop parsing on the first error.
|
|
115
|
+
* - `'warnings-and-errors'` : Stop parsing on the first warning **or** error.
|
|
116
|
+
* @param includeMetadata If `true`, return additional metadata (e.g. warnings, statistics) alongside the parsed object.
|
|
117
|
+
*
|
|
118
|
+
* @returns {ParsedObject | YiniParseResult} The parsed YINI content.
|
|
119
|
+
*
|
|
120
|
+
* By default (`includeMetadata = false`), this method returns a plain JavaScript object:
|
|
121
|
+
*
|
|
122
|
+
* `
|
|
123
|
+
* export type ParsedObject = any
|
|
124
|
+
* `
|
|
125
|
+
*
|
|
126
|
+
* If `includeMetadata = true`, the return value is wrapped in a container that also
|
|
127
|
+
* includes parsing metadata:
|
|
128
|
+
*
|
|
129
|
+
* `
|
|
130
|
+
* export interface YiniParseResult {
|
|
131
|
+
* result: ParsedObject
|
|
132
|
+
* meta: ResultMetadata
|
|
133
|
+
* }
|
|
134
|
+
* `
|
|
55
135
|
*/
|
|
56
|
-
static parseFile(filePath: string, strictMode?: boolean, failLevel?:
|
|
136
|
+
static parseFile(filePath: string, strictMode?: boolean, failLevel?: PreferredFailLevel, includeMetadata?: boolean): ParsedObject | YiniParseResult;
|
|
57
137
|
/**
|
|
58
138
|
* Parse a YINI file into a JavaScript object, using an options object for configuration.
|
|
59
139
|
*
|
|
60
140
|
* @param yiniFile Path to the YINI file.
|
|
61
141
|
* @param options Optional settings to customize parsing and/or results, useful if you need more control.
|
|
142
|
+
* For all options, see types/ParseOptions.
|
|
143
|
+
*
|
|
144
|
+
* @param options.failLevel - Preferred bail sensitivity level, controls if and when parsing should stop on problems:
|
|
145
|
+
* Accepts:
|
|
146
|
+
* `'ignore-errors'` - Continue despite errors, persist and try to recover.
|
|
147
|
+
* `'errors'` - Stop parsing on the first error.
|
|
148
|
+
* `'warnings-and-errors'` - Stop parsing on the first warning or error.
|
|
149
|
+
* (Type: TPreferredFailLevel; exact behavior is implementation-defined.)
|
|
150
|
+
* @param options.includeDiagnostics - Include diagnostics in the returned metadata.
|
|
151
|
+
* Requires: `includeMetadata = true`. Ignored otherwise.
|
|
152
|
+
* @param options.includeMetadata - Attach a metadata object to the parse result
|
|
153
|
+
* (e.g., timings, diagnostics).
|
|
154
|
+
* @param options.includeTiming - Include timing information for parser phases in metadata.
|
|
155
|
+
* Requires: `includeMetadata = true`. Ignored otherwise.
|
|
156
|
+
* @param options.onDuplicateKey - Strategy/handler when encountering a duplicate key.
|
|
157
|
+
* Allowed values: `'warn-and-keep-first'` | `'warn-and-overwrite'` | `'keep-first'` (silent, first wins) | `'overwrite'` (silent, last wins) | `'error'`.
|
|
158
|
+
* @param options.preserveUndefinedInMeta - Keep properties with value `undefined` inside
|
|
159
|
+
* the returned metadata. Requires: `includeMetadata = true`. Ignored otherwise.
|
|
160
|
+
* @param options.quiet - Show only errors, will suppress warnings and messages sent to the console/log.
|
|
161
|
+
* Does not affect warnings included in returned metadata.
|
|
162
|
+
* @param options.requireDocTerminator - Controls whether a document terminator is required.
|
|
163
|
+
* Allowed values: `'optional'` | `'warn-if-missing'` | `'required'`.
|
|
164
|
+
* @param options.silent - Suppress all output (even errors, exit code only).
|
|
165
|
+
* @param options.strictMode - Sets the baseline ruleset (true = strict, false = lenient).
|
|
166
|
+
* This is only a starting point: rule-specific options (e.g., `treatEmptyValueAsNull`,
|
|
167
|
+
* `onDuplicateKey`, etc.) can override parts of that ruleset. If any overrides are given,
|
|
168
|
+
* the effective mode becomes **custom** rather than purely strict/lenient.
|
|
169
|
+
* @param options.treatEmptyValueAsNull - How to treat an explicitly empty value on the
|
|
170
|
+
* right-hand side of '='. Allowed values: `'allow'` | `'allow-with-warning'` | `'disallow'`.
|
|
171
|
+
* @param options.throwOnError - Will throw on first parse error encountered.
|
|
172
|
+
* NOTE: Current default is `true`. The default will change to `false` in the next
|
|
173
|
+
* release. To avoid breaking changes, set this option explicitly.
|
|
174
|
+
*
|
|
175
|
+
* @returns {ParsedObject | YiniParseResult} The parsed YINI content.
|
|
176
|
+
*
|
|
177
|
+
* By default (`includeMetadata = false`), this method returns a plain JavaScript object:
|
|
178
|
+
*
|
|
179
|
+
* `
|
|
180
|
+
* export type ParsedObject = any
|
|
181
|
+
* `
|
|
182
|
+
*
|
|
183
|
+
* If `includeMetadata = true`, the return value is wrapped in a container that also
|
|
184
|
+
* includes parsing metadata:
|
|
62
185
|
*
|
|
63
|
-
*
|
|
186
|
+
* `
|
|
187
|
+
* export interface YiniParseResult {
|
|
188
|
+
* result: ParsedObject
|
|
189
|
+
* meta: ResultMetadata
|
|
190
|
+
* }
|
|
191
|
+
* `
|
|
64
192
|
*/
|
|
65
|
-
static parseFile(filePath: string, options?:
|
|
193
|
+
static parseFile(filePath: string, options?: ParseOptions): ParsedObject | YiniParseResult;
|
|
66
194
|
}
|