Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/aether/deps.ts>YAML.visitAsync

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

Apply an async visitor to an AST node or document.

Walks through the tree (depth-first) starting from node, calling a visitor function with three arguments:

  • key: For sequence values and map Pair, the node's index in the collection. Within a Pair, 'key' or 'value', correspondingly. null for the root node.
  • node: The current node.
  • path: The ancestry of the current node.

The return value of the visitor may be used to control the traversal:

  • Promise: Must resolve to one of the following values
  • undefined (default): Do nothing and continue
  • visit.SKIP: Do not visit the children of this node, continue with next sibling
  • visit.BREAK: Terminate traversal completely
  • visit.REMOVE: Remove the current node, then continue with the next one
  • Node: Replace the current node, then continue by visiting it
  • number: While iterating the items of a sequence or map, set the index of the next step. This is useful especially if the index of the current node has changed.

If visitor is a single function, it will be called with all values encountered in the tree, including e.g. null values. Alternatively, separate visitor functions may be defined for each Map, Pair, Seq, Alias and Scalar node. To define the same visitor function for more than one node type, use the Collection (map and seq), Value (map, seq & scalar) and Node (alias, map, seq & scalar) targets. Of all these, only the most specific defined one will be used for each node.

Parameters

node: Node | Document | null
visitor: asyncVisitor

Returns

Promise<void>