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 type { YAMLMap } from './YAMLMap.js';
|
9 | import type { YAMLSeq } from './YAMLSeq.js';
|
10 | export type Node<T = unknown> = Alias | Scalar<T> | YAMLMap<unknown, T> | YAMLSeq<T>;
|
11 |
|
12 | 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 {
|
13 | [key: string]: any;
|
14 | } ? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> : T extends {
|
15 | [key: number]: any;
|
16 | } ? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> : Node;
|
17 | export type ParsedNode = Alias.Parsed | Scalar.Parsed | YAMLMap.Parsed | YAMLSeq.Parsed;
|
18 | export type Range = [number, number, number];
|
19 | export declare abstract class NodeBase {
|
20 | readonly [NODE_TYPE]: symbol;
|
21 |
|
22 | comment?: string | null;
|
23 |
|
24 | commentBefore?: string | null;
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | range?: Range | null;
|
32 |
|
33 | spaceBefore?: boolean;
|
34 |
|
35 | srcToken?: Token;
|
36 |
|
37 | tag?: string;
|
38 |
|
39 | abstract toJSON(): any;
|
40 | abstract toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
41 | constructor(type: symbol);
|
42 | /** Create a copy of this node. */
|
43 | clone(): NodeBase;
|
44 | /** A plain JavaScript representation of this node. */
|
45 | toJS(doc: Document<Node, boolean>, { mapAsMap, maxAliasCount, onAnchor, reviver }?: ToJSOptions): any;
|
46 | }
|