1 | import type { Document } from '../doc/Document.js';
|
2 | import type { ToJSOptions } from '../options.js';
|
3 | import { Token } from '../parse/cst.js';
|
4 | import type { StringifyContext } from '../stringify/stringify.js';
|
5 | import type { Alias } from './Alias.js';
|
6 | import { NODE_TYPE } from './identity.js';
|
7 | import type { Scalar } from './Scalar.js';
|
8 | import { ToJSContext } from './toJS.js';
|
9 | import type { MapLike, YAMLMap } from './YAMLMap.js';
|
10 | import type { YAMLSeq } from './YAMLSeq.js';
|
11 | export type Node<T = unknown> = Alias | Scalar<T> | YAMLMap<unknown, T> | YAMLSeq<T>;
|
12 |
|
13 | export type NodeType<T> = T extends string | number | bigint | boolean | null | undefined ? Scalar<T> : T extends Date ? Scalar<string | Date> : T extends Array<any> ? YAMLSeq<NodeType<T[number]>> : T extends {
|
14 | [key: string]: any;
|
15 | } ? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> : T extends {
|
16 | [key: number]: any;
|
17 | } ? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> : Node;
|
18 | export type ParsedNode = Alias.Parsed | Scalar.Parsed | YAMLMap.Parsed | YAMLSeq.Parsed;
|
19 |
|
20 | export type Range = [number, number, number];
|
21 | export declare abstract class NodeBase {
|
22 | readonly [NODE_TYPE]: symbol;
|
23 |
|
24 | comment?: string | null;
|
25 |
|
26 | commentBefore?: string | null;
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | range?: Range | null;
|
34 |
|
35 | spaceBefore?: boolean;
|
36 |
|
37 | srcToken?: Token;
|
38 |
|
39 | tag?: string;
|
40 | |
41 |
|
42 |
|
43 |
|
44 | addToJSMap?: (ctx: ToJSContext | undefined, map: MapLike, value: unknown) => void;
|
45 |
|
46 | abstract toJSON(): any;
|
47 | abstract toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
48 | constructor(type: symbol);
|
49 | /** Create a copy of this node. */
|
50 | clone(): NodeBase;
|
51 | /** A plain JavaScript representation of this node. */
|
52 | toJS(doc: Document<Node, boolean>, { mapAsMap, maxAliasCount, onAnchor, reviver }?: ToJSOptions): any;
|
53 | }
|