readDocumentValue
readDocumentValue(
text,options?):Promise<DocumentValueResult>
Defined in: packages/core/src/parser/document-value.ts:71
Read document text in YAML, JSON or TOML as a plain value, without validating or normalizing it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text | string |
options | ReadDocumentValueOptions |
Returns
Section titled “Returns”Promise<DocumentValueResult>
Remarks
Section titled “Remarks”The format is picked as parseDocumentText picks it: format, else
the signals, else the text itself. Empty YAML or JSON is null; empty
TOML is an empty table.
The promise never rejects because of what the text says: a syntax error,
a refused merge fan-out or an alias bomb resolve as { success: false },
with the errors worded for the format and positioned. A failed download
of the TOML reader rejects, as it does for parseDocumentText.
Example
Section titled “Example”const read = await readDocumentValue(text, { signals: { fileName: "data.toml" } });if (read.success) use(read.value);else console.error(read.errors[0].message);