functional-examplesFUNCTIONAL-EXAMPLES
DOCSEXAMPLESAPI
⌘K
GitHubnpm
Guides
  • Getting Started
  • Why functional-examples
  • Core Concepts
  • Plugins
  • Configuration
  • Testing Examples
  • Use Cases
Plugins
  • JavaScript Plugin
  • YAML Manifest Plugin
  • Test Plugin
  • Documentation Plugin
Advanced
  • Custom Extractors
  • Plugin Authoring
  • Snapshot Testing
  • CI Integration
Examples
  • CI Integration
  • Custom Extractor
  • Devkit README Snippets
  • Documentation Plugin
  • Getting Started
  • Getting Started
  • JavaScript Plugin
  • JSON Configuration
  • Metadata Validation
  • Mixed Plugins
  • Multi-Plugin Configuration
  • Plugin Authoring
  • Region Markers
  • Snapshot Testing
  • Test Assertions Reference
  • Test Plugin Example
  • YAML Manifest Plugin
API
  • @functional-examples/devkit
  • @functional-examples/documentation
  • @functional-examples/javascript
  • @functional-examples/test
  • @functional-examples/yaml-manifest
  • functional-examples
  • rehype-typedoc
  • vike-plugin-typedoc
GitHubGitHubnpmNPM
Guides
  • Getting Started
  • Why functional-examples
  • Core Concepts
  • Plugins
  • Configuration
  • Testing Examples
  • Use Cases
Plugins
  • JavaScript Plugin
  • YAML Manifest Plugin
  • Test Plugin
  • Documentation Plugin
Advanced
  • Custom Extractors
  • Plugin Authoring
  • Snapshot Testing
  • CI Integration
Examples
  • CI Integration
  • Custom Extractor
  • Devkit README Snippets
  • Documentation Plugin
  • Getting Started
  • Getting Started
  • JavaScript Plugin
  • JSON Configuration
  • Metadata Validation
  • Mixed Plugins
  • Multi-Plugin Configuration
  • Plugin Authoring
  • Region Markers
  • Snapshot Testing
  • Test Assertions Reference
  • Test Plugin Example
  • YAML Manifest Plugin
API
  • @functional-examples/devkit
  • @functional-examples/documentation
  • @functional-examples/javascript
  • @functional-examples/test
  • @functional-examples/yaml-manifest
  • functional-examples
  • rehype-typedoc
  • vike-plugin-typedoc
GitHubGitHubnpmNPM
TRYPARSEYAML
API/@functional-examples/devkit/tryParseYaml

tryParseYaml

function
function tryParseYaml<T>(
  content: string,
  filePath?: string
): Promise<
  { data: T; success: true } | { error: YamlParseError; success: false }
>;

Try to parse a YAML string, returning a discriminated union result
instead of throwing.

Requires the yaml peer dependency to be installed.

PARAMETERS

NAMETYPEDESCRIPTION
contentstringThe YAML string to parse
filePath?stringOptional file path for error messages

RETURNS

Promise<{ data: T; success: true } | { error: YamlParseError; success: false }>

TYPE PARAMETERS

  • T = unknown