NAME
std/data/yaml - YAML encoding and decoding for ZuzuScript.
SYNOPSIS
from std/data/yaml import YAML;
let codec := new YAML( pretty: true, canonical: true );
let text := codec.encode({ answer: 42, ok: true });
let data := codec.decode(text);
IMPLEMENTATION SUPPORT
This module is supported by zuzu.pl, zuzu-rust, and zuzu-js on Node and Electron. It is partially supported by zuzu-js in the browser: in-memory YAML encode/decode coverage passes, but file-backed load/dump coverage is unsupported because browser filesystem capability is unavailable.
DESCRIPTION
This module provides a YAML class for turning ZuzuScript values into YAML text and parsing YAML text back into ZuzuScript values.
EXPORTS
Classes
YAML({ utf8?: Bool, pretty?: Bool, canonical?: Bool })Constructs a YAML codec. Returns:
YAML.The constructor accepts named options:
utf8(default true)Accepted for API compatibility with
std/data/jsonandstd/data/toml.pretty(default false)Keep the final trailing newline generated by the emitter.
canonical(default false)Accepted for API compatibility with
std/data/jsonandstd/data/toml.
codec.encode(value)Parameters:
valueis any YAML-encodable ZuzuScript value. Returns:String. Encodesvalueas YAML text.codec.encode_binarystring(value)Parameters:
valueis any YAML-encodable ZuzuScript value. Returns:BinaryString. Encodesvalueas UTF-8 YAML bytes.codec.decode(String yaml)Parameters:
yamlis YAML text. Returns: value. Decodes YAML into the equivalent ZuzuScript value.codec.decode_binarystring(BinaryString yaml)Parameters:
yamlis UTF-8 YAML bytes. Returns: value. Decodes YAML into the equivalent ZuzuScript value.codec.load(Path path)Parameters:
pathis astd/ioPath. Returns: value. Reads YAML text frompathand decodes it.codec.dump(Path path, value)Parameters:
pathis astd/ioPathandvalueis any YAML-encodable value. Returns:null. Encodesvalueand writes YAML text topath.
COPYRIGHT AND LICENCE
std/data/yaml is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.