1 | import { Document } from './index'
|
---|
2 | import { CST } from './parse-cst'
|
---|
3 | import { AST, Pair, Scalar, Schema } from './types'
|
---|
4 |
|
---|
5 | export function findPair(items: any[], key: Scalar | any): Pair | undefined
|
---|
6 |
|
---|
7 | export function parseMap(doc: Document, cst: CST.Map): AST.BlockMap
|
---|
8 | export function parseMap(doc: Document, cst: CST.FlowMap): AST.FlowMap
|
---|
9 | export function parseSeq(doc: Document, cst: CST.Seq): AST.BlockSeq
|
---|
10 | export function parseSeq(doc: Document, cst: CST.FlowSeq): AST.FlowSeq
|
---|
11 |
|
---|
12 | export function stringifyNumber(item: Scalar): string
|
---|
13 | export function stringifyString(
|
---|
14 | item: Scalar,
|
---|
15 | ctx: Schema.StringifyContext,
|
---|
16 | onComment?: () => void,
|
---|
17 | onChompKeep?: () => void
|
---|
18 | ): string
|
---|
19 |
|
---|
20 | export function toJSON(
|
---|
21 | value: any,
|
---|
22 | arg?: any,
|
---|
23 | ctx?: Schema.CreateNodeContext
|
---|
24 | ): any
|
---|
25 |
|
---|
26 | export enum Type {
|
---|
27 | ALIAS = 'ALIAS',
|
---|
28 | BLANK_LINE = 'BLANK_LINE',
|
---|
29 | BLOCK_FOLDED = 'BLOCK_FOLDED',
|
---|
30 | BLOCK_LITERAL = 'BLOCK_LITERAL',
|
---|
31 | COMMENT = 'COMMENT',
|
---|
32 | DIRECTIVE = 'DIRECTIVE',
|
---|
33 | DOCUMENT = 'DOCUMENT',
|
---|
34 | FLOW_MAP = 'FLOW_MAP',
|
---|
35 | FLOW_SEQ = 'FLOW_SEQ',
|
---|
36 | MAP = 'MAP',
|
---|
37 | MAP_KEY = 'MAP_KEY',
|
---|
38 | MAP_VALUE = 'MAP_VALUE',
|
---|
39 | PLAIN = 'PLAIN',
|
---|
40 | QUOTE_DOUBLE = 'QUOTE_DOUBLE',
|
---|
41 | QUOTE_SINGLE = 'QUOTE_SINGLE',
|
---|
42 | SEQ = 'SEQ',
|
---|
43 | SEQ_ITEM = 'SEQ_ITEM'
|
---|
44 | }
|
---|
45 |
|
---|
46 | interface LinePos {
|
---|
47 | line: number
|
---|
48 | col: number
|
---|
49 | }
|
---|
50 |
|
---|
51 | export class YAMLError extends Error {
|
---|
52 | name:
|
---|
53 | | 'YAMLReferenceError'
|
---|
54 | | 'YAMLSemanticError'
|
---|
55 | | 'YAMLSyntaxError'
|
---|
56 | | 'YAMLWarning'
|
---|
57 | message: string
|
---|
58 | source?: CST.Node
|
---|
59 |
|
---|
60 | nodeType?: Type
|
---|
61 | range?: CST.Range
|
---|
62 | linePos?: { start: LinePos; end: LinePos }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Drops `source` and adds `nodeType`, `range` and `linePos`, as well as
|
---|
66 | * adding details to `message`. Run automatically for document errors if
|
---|
67 | * the `prettyErrors` option is set.
|
---|
68 | */
|
---|
69 | makePretty(): void
|
---|
70 | }
|
---|
71 |
|
---|
72 | export class YAMLReferenceError extends YAMLError {
|
---|
73 | name: 'YAMLReferenceError'
|
---|
74 | }
|
---|
75 |
|
---|
76 | export class YAMLSemanticError extends YAMLError {
|
---|
77 | name: 'YAMLSemanticError'
|
---|
78 | }
|
---|
79 |
|
---|
80 | export class YAMLSyntaxError extends YAMLError {
|
---|
81 | name: 'YAMLSyntaxError'
|
---|
82 | }
|
---|
83 |
|
---|
84 | export class YAMLWarning extends YAMLError {
|
---|
85 | name: 'YAMLWarning'
|
---|
86 | }
|
---|