@robinpath/yaml
v0.1.3
Published
Parse, stringify, and manipulate YAML data
Readme
@robinpath/yaml
Parse, stringify, and manipulate YAML data
Why use this module?
The yaml module lets you:
- Parse a YAML string into a JavaScript object, array, or value
- Convert a JavaScript value into a YAML string
- Read and parse a YAML file from disk
- Write a value as YAML to a file on disk
- Parse a multi-document YAML string into an array of documents
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/yamlQuick Start
No credentials needed — start using it right away:
yaml.stringify $dataAvailable Functions
| Function | Description |
|----------|-------------|
| yaml.parse | Parse a YAML string into a JavaScript object, array, or value |
| yaml.stringify | Convert a JavaScript value into a YAML string |
| yaml.parseFile | Read and parse a YAML file from disk |
| yaml.writeFile | Write a value as YAML to a file on disk |
| yaml.parseAll | Parse a multi-document YAML string into an array of documents |
| yaml.isValid | Check whether a string is valid YAML |
| yaml.get | Parse YAML and retrieve a nested value by dot-path |
| yaml.toJSON | Convert a YAML string to a JSON string |
| yaml.fromJSON | Convert a JSON string to a YAML string |
Examples
Convert a JavaScript value into a YAML string
yaml.stringify $dataRead and parse a YAML file from disk
yaml.parseFile "config.yaml"Write a value as YAML to a file on disk
yaml.writeFile "output.yaml" $dataIntegration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/yaml";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
yaml.stringify $data
`);Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
