parseDocumentText
Call Signature
Section titled “Call Signature”parseDocumentText(
text,options):Promise<FormattedParseResult<{[key:string]:any; }>>
Defined in: packages/core/src/parser/document-text.ts:108
Read document text in YAML, JSON or TOML and validate it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text | string |
options | ParseDocumentTextOptions & object |
Returns
Section titled “Returns”Promise<FormattedParseResult<{[key: string]: any; }>>
Remarks
Section titled “Remarks”The format comes from options.format, else from options.signals, else
from the text itself: a first { is JSON, key = value lines with no
key: line are TOML, and anything else is YAML.
The promise never rejects because of what the text says: a syntax error,
an invalid document or an unexpected exception all resolve as an error
result. Every result, and every error in it, carries format.
Example
Section titled “Example”const result = await parseDocumentText(text, { kind: "map", signals: { url: "maps/city.json" },});if (!result.success) console.error(result.format, result.errors);Call Signature
Section titled “Call Signature”parseDocumentText(
text,options):Promise<FormattedParseResult<{[key:string]:any; }>>
Defined in: packages/core/src/parser/document-text.ts:112
Read document text in YAML, JSON or TOML and validate it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text | string |
options | ParseDocumentTextOptions & object |
Returns
Section titled “Returns”Promise<FormattedParseResult<{[key: string]: any; }>>
Remarks
Section titled “Remarks”The format comes from options.format, else from options.signals, else
from the text itself: a first { is JSON, key = value lines with no
key: line are TOML, and anything else is YAML.
The promise never rejects because of what the text says: a syntax error,
an invalid document or an unexpected exception all resolve as an error
result. Every result, and every error in it, carries format.
Example
Section titled “Example”const result = await parseDocumentText(text, { kind: "map", signals: { url: "maps/city.json" },});if (!result.success) console.error(result.format, result.errors);Call Signature
Section titled “Call Signature”parseDocumentText(
text,options?):Promise<DocumentTextResult>
Defined in: packages/core/src/parser/document-text.ts:116
Read document text in YAML, JSON or TOML and validate it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text | string |
options? | ParseDocumentTextOptions & object |
Returns
Section titled “Returns”Promise<DocumentTextResult>
Remarks
Section titled “Remarks”The format comes from options.format, else from options.signals, else
from the text itself: a first { is JSON, key = value lines with no
key: line are TOML, and anything else is YAML.
The promise never rejects because of what the text says: a syntax error,
an invalid document or an unexpected exception all resolve as an error
result. Every result, and every error in it, carries format.
Example
Section titled “Example”const result = await parseDocumentText(text, { kind: "map", signals: { url: "maps/city.json" },});if (!result.success) console.error(result.format, result.errors);