Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/aether/deps.ts>YAML.Document

A Deno library to interface with the Discord API
Latest
namespace YAML.Document
import { YAML } from "https://deno.land/x/aether@v0.0.3/deps.ts";
const { Document } = YAML;
class YAML.Document
import { YAML } from "https://deno.land/x/aether@v0.0.3/deps.ts";
const { Document } = YAML;

Constructors

new
Document(value?: any, options?: )
new
Document(
value: any,
replacer: null | Replacer,
)

Type Parameters

optional
T extends Node = Node

Properties

comment: string | null

A comment immediately after this Document

commentBefore: string | null

A comment before this Document

contents: T | null

The document contents.

optional
directives: Directives
errors: YAMLError[]

Errors encountered during parsing.

options: Required<Omit<ParseOptions & DocumentOptions, "_directives" | "lineCounter" | "version">>
optional
range: Range

The [start, value-end, node-end] character offsets for the part of the source parsed into this document (undefined if not parsed). The value-end and node-end positions are themselves not included in their respective ranges.

schema: Schema

The schema used with the document. Use setSchema() to change.

warnings: YAMLWarning[]

Warnings encountered during parsing.

readonly
[NODE_TYPE]: symbol

Methods

add(value: any): void

Adds a value to the document.

addIn(path: Iterable<unknown>, value: unknown): void

Adds a value to the document.

Create a deep copy of this Document and its contents.

Custom Node values that inherit from Object still refer to their original instances.

createAlias(node: Scalar | YAMLMap | YAMLSeq, name?: string): Alias

Create a new Alias node, ensuring that the target node has the required anchor.

If node already has an anchor, name is ignored. Otherwise, the node.anchor value will be set to name, or if an anchor with that name is already present in the document, name will be used as a prefix for a new unique anchor. If name is undefined, the generated anchor will use 'a' as a prefix.

createNode<T = unknown>(value: T, options?: CreateNodeOptions): NodeType<T>

Convert any value into a Node using the current schema, recursively turning objects into collections.

createNode<T = unknown>(
value: T,
replacer: Replacer | CreateNodeOptions | null,
): NodeType<T>
createPair<K extends Node = Node, V extends Node = Node>(
key: unknown,
value: unknown,
): Pair<K, V>

Convert a key and a value into a Pair using the current schema, recursively wrapping all values as Scalar or Collection nodes.

delete(key: unknown): boolean

Removes a value from the document.

deleteIn(path: Iterable<unknown> | null): boolean

Removes a value from the document.

get(key: unknown, keepScalar?: boolean): unknown

Returns item at key, or undefined if not found. By default unwraps scalar values from their surrounding node; to disable set keepScalar to true (collections are always returned intact).

getIn(path: Iterable<unknown> | null, keepScalar?: boolean): unknown

Returns item at path, or undefined if not found. By default unwraps scalar values from their surrounding node; to disable set keepScalar to true (collections are always returned intact).

has(key: unknown): boolean

Checks if the document includes a value with the key key.

hasIn(path: Iterable<unknown> | null): boolean

Checks if the document includes a value at path.

set(key: any, value: unknown): void

Sets a value in this document. For !!set, value needs to be a boolean to add/remove the item from the set.

setIn(path: Iterable<unknown> | null, value: unknown): void

Sets a value in this document. For !!set, value needs to be a boolean to add/remove the item from the set.

setSchema(version:
| "1.1"
| "1.2"
| "next"
| null
, options?: SchemaOptions
): void

Change the YAML version and schema used by the document. A null version disables support for directives, explicit tags, anchors, and aliases. It also requires the schema option to be given as a Schema instance value.

Overrides all previously set schema options.

toJS(opt?: ToJSOptions & { [ignored: string]: unknown; }): any

A plain JavaScript representation of the document contents.

toJSON(jsonArg?: string | null, onAnchor?: ToJSOptions["onAnchor"]): any

A JSON representation of the document contents.

toString(options?: ToStringOptions): string

A YAML representation of the document.