2023-03-14 07:40:02 +00:00
|
|
|
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-03-18 12:36:00 +00:00
|
|
|
// This module is browser compatible.
|
2023-03-14 07:40:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@linkcode parse} and {@linkcode stringify} for handling
|
2024-01-31 22:19:46 +00:00
|
|
|
* {@link https://yaml.org/ | YAML} encoded data.
|
2023-03-14 07:40:02 +00:00
|
|
|
*
|
|
|
|
* Ported from
|
2024-01-31 22:19:46 +00:00
|
|
|
* {@link https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da | js-yaml v3.13.1}.
|
2023-03-14 07:40:02 +00:00
|
|
|
*
|
2024-07-06 08:35:15 +00:00
|
|
|
* Use {@linkcode parseAll} for parsing multiple documents in a single YAML
|
|
|
|
* string.
|
2024-06-28 10:28:55 +00:00
|
|
|
*
|
2024-07-25 06:48:11 +00:00
|
|
|
* This package generally supports
|
|
|
|
* {@link https://yaml.org/spec/1.2.2/ | YAML 1.2.x} (latest) and some
|
|
|
|
* {@link https://yaml.org/spec/1.1/current.html | YAML 1.1} features that are
|
|
|
|
* commonly used in the wild.
|
|
|
|
*
|
|
|
|
* Supported YAML 1.1 features include:
|
|
|
|
* - {@link https://yaml.org/type/merge.html | Merge} type (`<<` symbol)
|
|
|
|
*
|
|
|
|
* Unsupported YAML 1.1 features include:
|
|
|
|
* - Yes, No, On, Off literals for bool type
|
|
|
|
* - Sexagesimal numbers (e.g. `3:25:45`)
|
|
|
|
*
|
2023-03-14 07:40:02 +00:00
|
|
|
* ```ts
|
2024-06-28 10:28:55 +00:00
|
|
|
* import { parse, stringify } from "@std/yaml";
|
|
|
|
* import { assertEquals } from "@std/assert";
|
2023-03-14 07:40:02 +00:00
|
|
|
*
|
|
|
|
* const data = parse(`
|
|
|
|
* foo: bar
|
|
|
|
* baz:
|
|
|
|
* - qux
|
|
|
|
* - quux
|
|
|
|
* `);
|
2024-06-28 10:28:55 +00:00
|
|
|
* assertEquals(data, { foo: "bar", baz: [ "qux", "quux" ] });
|
2023-03-14 07:40:02 +00:00
|
|
|
*
|
|
|
|
* const yaml = stringify({ foo: "bar", baz: ["qux", "quux"] });
|
2024-06-28 10:28:55 +00:00
|
|
|
* assertEquals(yaml, `foo: bar
|
|
|
|
* baz:
|
|
|
|
* - qux
|
|
|
|
* - quux
|
|
|
|
* `);
|
2023-03-14 07:40:02 +00:00
|
|
|
* ```
|
|
|
|
*
|
2024-07-06 08:35:15 +00:00
|
|
|
* ## Limitations
|
|
|
|
* - `binary` type is currently not stable.
|
|
|
|
*
|
2023-03-14 07:40:02 +00:00
|
|
|
* @module
|
|
|
|
*/
|
|
|
|
|
|
|
|
export * from "./parse.ts";
|
|
|
|
export * from "./stringify.ts";
|