yaml 2.0.0-2 → 2.0.0-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +46 -26
- package/browser/dist/compose/compose-collection.js +59 -0
- package/browser/dist/compose/compose-doc.js +39 -0
- package/browser/dist/compose/compose-node.js +72 -0
- package/browser/dist/compose/compose-scalar.js +74 -0
- package/browser/dist/compose/composer.js +218 -0
- package/browser/dist/compose/resolve-block-map.js +93 -0
- package/browser/dist/compose/resolve-block-scalar.js +185 -0
- package/browser/dist/compose/resolve-block-seq.js +40 -0
- package/browser/dist/compose/resolve-end.js +37 -0
- package/browser/dist/compose/resolve-flow-collection.js +189 -0
- package/browser/dist/compose/resolve-flow-scalar.js +211 -0
- package/browser/dist/compose/resolve-props.js +126 -0
- package/browser/dist/compose/util-contains-newline.js +34 -0
- package/browser/dist/compose/util-empty-scalar-position.js +27 -0
- package/browser/dist/compose/util-map-includes.js +17 -0
- package/browser/dist/doc/Document.js +251 -348
- package/browser/dist/doc/anchors.js +72 -0
- package/browser/dist/doc/applyReviver.js +41 -28
- package/browser/dist/doc/createNode.js +71 -55
- package/browser/dist/doc/directives.js +161 -0
- package/browser/dist/errors.js +50 -72
- package/browser/dist/index.js +17 -73
- package/browser/dist/log.js +11 -7
- package/browser/dist/nodes/Alias.js +94 -0
- package/browser/dist/nodes/Collection.js +133 -0
- package/browser/dist/nodes/Node.js +41 -0
- package/browser/dist/nodes/Pair.js +28 -0
- package/browser/dist/nodes/Scalar.js +23 -0
- package/browser/dist/nodes/YAMLMap.js +116 -0
- package/browser/dist/nodes/YAMLSeq.js +105 -0
- package/browser/dist/nodes/addPairToJSMap.js +103 -0
- package/browser/dist/nodes/toJS.js +35 -0
- package/browser/dist/options.js +14 -95
- package/browser/dist/parse/cst-scalar.js +219 -0
- package/browser/dist/parse/cst-stringify.js +61 -0
- package/browser/dist/parse/cst-visit.js +97 -0
- package/browser/dist/parse/cst.js +98 -0
- package/browser/dist/parse/lexer.js +656 -0
- package/browser/dist/parse/line-counter.js +39 -0
- package/browser/dist/parse/parser.js +876 -0
- package/browser/dist/public-api.js +101 -0
- package/browser/dist/schema/Schema.js +23 -0
- package/browser/dist/schema/common/map.js +42 -0
- package/browser/dist/schema/common/null.js +13 -0
- package/browser/dist/schema/common/seq.js +33 -0
- package/browser/dist/schema/common/string.js +14 -0
- package/browser/dist/schema/core/bool.js +19 -0
- package/browser/dist/schema/core/float.js +40 -0
- package/browser/dist/schema/core/int.js +38 -0
- package/browser/dist/schema/core/schema.js +23 -0
- package/browser/dist/schema/json/schema.js +62 -0
- package/browser/dist/schema/tags.js +79 -0
- package/browser/dist/schema/yaml-1.1/binary.js +66 -0
- package/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/browser/dist/schema/yaml-1.1/float.js +43 -0
- package/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/browser/dist/schema/yaml-1.1/omap.js +73 -0
- package/browser/dist/schema/yaml-1.1/pairs.js +77 -0
- package/browser/dist/schema/yaml-1.1/schema.js +37 -0
- package/browser/dist/schema/yaml-1.1/set.js +87 -0
- package/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/browser/dist/stringify/foldFlowLines.js +121 -139
- package/browser/dist/stringify/stringify.js +87 -72
- package/browser/dist/stringify/stringifyCollection.js +122 -0
- package/browser/dist/stringify/stringifyComment.js +14 -0
- package/browser/dist/stringify/stringifyDocument.js +64 -0
- package/browser/dist/stringify/stringifyNumber.js +20 -23
- package/browser/dist/stringify/stringifyPair.js +111 -0
- package/browser/dist/stringify/stringifyString.js +295 -322
- package/browser/dist/util.js +4 -4
- package/browser/dist/visit.js +146 -0
- package/browser/index.js +4 -1
- package/dist/compose/compose-collection.d.ts +5 -0
- package/dist/compose/compose-collection.js +61 -0
- package/dist/compose/compose-doc.d.ts +6 -0
- package/dist/compose/compose-doc.js +41 -0
- package/dist/compose/compose-node.d.ts +25 -0
- package/dist/compose/compose-node.js +75 -0
- package/dist/compose/compose-scalar.d.ts +5 -0
- package/dist/compose/compose-scalar.js +76 -0
- package/dist/compose/composer.d.ts +62 -0
- package/dist/compose/composer.js +222 -0
- package/dist/compose/resolve-block-map.d.ts +6 -0
- package/dist/compose/resolve-block-map.js +95 -0
- package/dist/compose/resolve-block-scalar.d.ts +10 -0
- package/dist/compose/resolve-block-scalar.js +187 -0
- package/dist/compose/resolve-block-seq.d.ts +5 -0
- package/dist/compose/resolve-block-seq.js +42 -0
- package/dist/compose/resolve-end.d.ts +6 -0
- package/dist/compose/resolve-end.js +39 -0
- package/dist/compose/resolve-flow-collection.d.ts +6 -0
- package/dist/compose/resolve-flow-collection.js +191 -0
- package/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/dist/compose/resolve-flow-scalar.js +213 -0
- package/dist/compose/resolve-props.d.ts +21 -0
- package/dist/compose/resolve-props.js +128 -0
- package/dist/compose/util-contains-newline.d.ts +2 -0
- package/dist/compose/util-contains-newline.js +36 -0
- package/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/dist/compose/util-empty-scalar-position.js +29 -0
- package/dist/compose/util-map-includes.d.ts +4 -0
- package/dist/compose/util-map-includes.js +19 -0
- package/dist/doc/Document.d.ts +130 -0
- package/dist/doc/Document.js +250 -347
- package/dist/doc/anchors.d.ts +24 -0
- package/dist/doc/anchors.js +77 -0
- package/dist/doc/applyReviver.d.ts +9 -0
- package/dist/doc/applyReviver.js +41 -28
- package/dist/doc/createNode.d.ts +16 -0
- package/dist/doc/createNode.js +71 -55
- package/dist/doc/directives.d.ts +46 -0
- package/dist/doc/directives.js +163 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +51 -74
- package/dist/index.d.ts +19 -0
- package/dist/index.js +40 -71
- package/dist/log.d.ts +3 -0
- package/dist/log.js +11 -6
- package/dist/nodes/Alias.d.ts +24 -0
- package/dist/nodes/Alias.js +96 -0
- package/dist/nodes/Collection.d.ts +67 -0
- package/dist/nodes/Collection.js +137 -0
- package/dist/nodes/Node.d.ts +48 -0
- package/dist/nodes/Node.js +59 -0
- package/dist/nodes/Pair.d.ts +16 -0
- package/dist/nodes/Pair.js +31 -0
- package/dist/nodes/Scalar.d.ts +40 -0
- package/dist/nodes/Scalar.js +26 -0
- package/dist/nodes/YAMLMap.d.ts +39 -0
- package/dist/nodes/YAMLMap.js +119 -0
- package/dist/nodes/YAMLSeq.d.ts +53 -0
- package/dist/nodes/YAMLSeq.js +107 -0
- package/dist/nodes/addPairToJSMap.d.ts +3 -0
- package/dist/nodes/addPairToJSMap.js +105 -0
- package/dist/nodes/toJS.d.ts +30 -0
- package/dist/nodes/toJS.js +37 -0
- package/dist/options.d.ts +278 -0
- package/dist/options.js +13 -96
- package/dist/parse/cst-scalar.d.ts +58 -0
- package/dist/parse/cst-scalar.js +223 -0
- package/dist/parse/cst-stringify.d.ts +8 -0
- package/dist/parse/cst-stringify.js +63 -0
- package/dist/parse/cst-visit.d.ts +39 -0
- package/dist/parse/cst-visit.js +99 -0
- package/dist/parse/cst.d.ts +106 -0
- package/dist/parse/cst.js +112 -0
- package/dist/parse/lexer.d.ts +85 -0
- package/dist/parse/lexer.js +658 -0
- package/dist/parse/line-counter.d.ts +22 -0
- package/dist/parse/line-counter.js +41 -0
- package/dist/parse/parser.d.ts +84 -0
- package/dist/parse/parser.js +880 -0
- package/dist/public-api.d.ts +43 -0
- package/dist/public-api.js +106 -0
- package/dist/schema/Schema.d.ts +16 -0
- package/dist/schema/Schema.js +25 -0
- package/dist/schema/common/map.d.ts +2 -0
- package/dist/schema/common/map.js +44 -0
- package/dist/schema/common/null.d.ts +4 -0
- package/dist/schema/common/null.js +15 -0
- package/dist/schema/common/seq.d.ts +2 -0
- package/dist/schema/common/seq.js +35 -0
- package/dist/schema/common/string.d.ts +2 -0
- package/dist/schema/common/string.js +16 -0
- package/dist/schema/core/bool.d.ts +4 -0
- package/dist/schema/core/bool.js +21 -0
- package/dist/schema/core/float.d.ts +4 -0
- package/dist/schema/core/float.js +44 -0
- package/dist/schema/core/int.d.ts +4 -0
- package/dist/schema/core/int.js +42 -0
- package/dist/schema/core/schema.d.ts +1 -0
- package/dist/schema/core/schema.js +25 -0
- package/dist/schema/json/schema.d.ts +2 -0
- package/dist/schema/json/schema.js +64 -0
- package/dist/schema/tags.d.ts +41 -0
- package/dist/schema/tags.js +82 -0
- package/dist/schema/types.d.ts +82 -0
- package/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/dist/schema/yaml-1.1/binary.js +68 -0
- package/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/dist/schema/yaml-1.1/bool.js +29 -0
- package/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/dist/schema/yaml-1.1/float.js +47 -0
- package/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/dist/schema/yaml-1.1/int.js +76 -0
- package/dist/schema/yaml-1.1/omap.d.ts +21 -0
- package/dist/schema/yaml-1.1/omap.js +76 -0
- package/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/dist/schema/yaml-1.1/pairs.js +81 -0
- package/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/dist/schema/yaml-1.1/schema.js +39 -0
- package/dist/schema/yaml-1.1/set.d.ts +22 -0
- package/dist/schema/yaml-1.1/set.js +90 -0
- package/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/dist/stringify/foldFlowLines.d.ts +34 -0
- package/dist/stringify/foldFlowLines.js +121 -139
- package/dist/stringify/stringify.d.ts +18 -0
- package/dist/stringify/stringify.js +87 -71
- package/dist/stringify/stringifyCollection.d.ts +21 -0
- package/dist/stringify/stringifyCollection.js +124 -0
- package/dist/stringify/stringifyComment.d.ts +2 -0
- package/dist/stringify/stringifyComment.js +17 -0
- package/dist/stringify/stringifyDocument.d.ts +3 -0
- package/dist/stringify/stringifyDocument.js +66 -0
- package/dist/stringify/stringifyNumber.d.ts +2 -0
- package/dist/stringify/stringifyNumber.js +20 -23
- package/dist/stringify/stringifyPair.d.ts +3 -0
- package/dist/stringify/stringifyPair.js +113 -0
- package/dist/stringify/stringifyString.d.ts +3 -0
- package/dist/stringify/stringifyString.js +295 -322
- package/dist/test-events.d.ts +4 -0
- package/dist/test-events.js +124 -148
- package/dist/util.d.ts +6 -0
- package/dist/util.js +9 -12
- package/dist/visit.d.ts +63 -0
- package/dist/visit.js +148 -0
- package/package.json +31 -39
- package/util.js +2 -14
- package/browser/dist/_virtual/_rollupPluginBabelHelpers.js +0 -16
- package/browser/dist/ast/Alias.js +0 -95
- package/browser/dist/ast/Collection.js +0 -192
- package/browser/dist/ast/Merge.js +0 -71
- package/browser/dist/ast/Node.js +0 -3
- package/browser/dist/ast/Pair.js +0 -200
- package/browser/dist/ast/Scalar.js +0 -21
- package/browser/dist/ast/YAMLMap.js +0 -91
- package/browser/dist/ast/YAMLSeq.js +0 -67
- package/browser/dist/ast/toJS.js +0 -29
- package/browser/dist/ast/visit.js +0 -83
- package/browser/dist/constants.js +0 -40
- package/browser/dist/cst/Alias.js +0 -26
- package/browser/dist/cst/BlankLine.js +0 -34
- package/browser/dist/cst/BlockValue.js +0 -240
- package/browser/dist/cst/Collection.js +0 -259
- package/browser/dist/cst/CollectionItem.js +0 -123
- package/browser/dist/cst/Comment.js +0 -27
- package/browser/dist/cst/Directive.js +0 -53
- package/browser/dist/cst/Document.js +0 -262
- package/browser/dist/cst/FlowCollection.js +0 -201
- package/browser/dist/cst/Node.js +0 -355
- package/browser/dist/cst/ParseContext.js +0 -234
- package/browser/dist/cst/PlainValue.js +0 -171
- package/browser/dist/cst/QuoteDouble.js +0 -224
- package/browser/dist/cst/QuoteSingle.js +0 -100
- package/browser/dist/cst/Range.js +0 -56
- package/browser/dist/cst/parse.js +0 -46
- package/browser/dist/cst/source-utils.js +0 -169
- package/browser/dist/doc/Anchors.js +0 -115
- package/browser/dist/doc/Schema.js +0 -34
- package/browser/dist/doc/getSchemaTags.js +0 -33
- package/browser/dist/doc/listTagNames.js +0 -27
- package/browser/dist/doc/parseContents.js +0 -60
- package/browser/dist/doc/parseDirectives.js +0 -107
- package/browser/dist/resolve/collection-utils.js +0 -86
- package/browser/dist/resolve/resolveMap.js +0 -315
- package/browser/dist/resolve/resolveNode.js +0 -173
- package/browser/dist/resolve/resolveScalar.js +0 -20
- package/browser/dist/resolve/resolveSeq.js +0 -170
- package/browser/dist/resolve/resolveTag.js +0 -107
- package/browser/dist/resolve/resolveTagName.js +0 -87
- package/browser/dist/stringify/addComment.js +0 -10
- package/browser/dist/stringify/stringifyTag.js +0 -28
- package/browser/dist/tags/core.js +0 -128
- package/browser/dist/tags/failsafe/index.js +0 -7
- package/browser/dist/tags/failsafe/map.js +0 -37
- package/browser/dist/tags/failsafe/seq.js +0 -34
- package/browser/dist/tags/failsafe/string.js +0 -20
- package/browser/dist/tags/index.js +0 -39
- package/browser/dist/tags/json.js +0 -62
- package/browser/dist/tags/options.js +0 -31
- package/browser/dist/tags/yaml-1.1/binary.js +0 -83
- package/browser/dist/tags/yaml-1.1/index.js +0 -174
- package/browser/dist/tags/yaml-1.1/omap.js +0 -86
- package/browser/dist/tags/yaml-1.1/pairs.js +0 -62
- package/browser/dist/tags/yaml-1.1/set.js +0 -78
- package/browser/dist/tags/yaml-1.1/timestamp.js +0 -101
- package/browser/dist/types.js +0 -10
- package/cst.d.ts +0 -185
- package/dist/_virtual/_rollupPluginBabelHelpers.js +0 -18
- package/dist/ast/Alias.js +0 -97
- package/dist/ast/Collection.js +0 -196
- package/dist/ast/Merge.js +0 -74
- package/dist/ast/Node.js +0 -5
- package/dist/ast/Pair.js +0 -203
- package/dist/ast/Scalar.js +0 -24
- package/dist/ast/YAMLMap.js +0 -94
- package/dist/ast/YAMLSeq.js +0 -69
- package/dist/ast/toJS.js +0 -31
- package/dist/ast/visit.js +0 -85
- package/dist/constants.js +0 -46
- package/dist/cst/Alias.js +0 -28
- package/dist/cst/BlankLine.js +0 -36
- package/dist/cst/BlockValue.js +0 -243
- package/dist/cst/Collection.js +0 -262
- package/dist/cst/CollectionItem.js +0 -125
- package/dist/cst/Comment.js +0 -29
- package/dist/cst/Directive.js +0 -55
- package/dist/cst/Document.js +0 -264
- package/dist/cst/FlowCollection.js +0 -203
- package/dist/cst/Node.js +0 -357
- package/dist/cst/ParseContext.js +0 -236
- package/dist/cst/PlainValue.js +0 -173
- package/dist/cst/QuoteDouble.js +0 -226
- package/dist/cst/QuoteSingle.js +0 -102
- package/dist/cst/Range.js +0 -58
- package/dist/cst/parse.js +0 -48
- package/dist/cst/source-utils.js +0 -173
- package/dist/doc/Anchors.js +0 -117
- package/dist/doc/Schema.js +0 -36
- package/dist/doc/getSchemaTags.js +0 -35
- package/dist/doc/listTagNames.js +0 -29
- package/dist/doc/parseContents.js +0 -62
- package/dist/doc/parseDirectives.js +0 -109
- package/dist/resolve/collection-utils.js +0 -91
- package/dist/resolve/resolveMap.js +0 -317
- package/dist/resolve/resolveNode.js +0 -175
- package/dist/resolve/resolveScalar.js +0 -22
- package/dist/resolve/resolveSeq.js +0 -172
- package/dist/resolve/resolveTag.js +0 -109
- package/dist/resolve/resolveTagName.js +0 -89
- package/dist/stringify/addComment.js +0 -13
- package/dist/stringify/stringifyTag.js +0 -30
- package/dist/tags/core.js +0 -138
- package/dist/tags/failsafe/index.js +0 -9
- package/dist/tags/failsafe/map.js +0 -39
- package/dist/tags/failsafe/seq.js +0 -36
- package/dist/tags/failsafe/string.js +0 -22
- package/dist/tags/index.js +0 -42
- package/dist/tags/json.js +0 -64
- package/dist/tags/options.js +0 -37
- package/dist/tags/yaml-1.1/binary.js +0 -85
- package/dist/tags/yaml-1.1/index.js +0 -176
- package/dist/tags/yaml-1.1/omap.js +0 -89
- package/dist/tags/yaml-1.1/pairs.js +0 -66
- package/dist/tags/yaml-1.1/set.js +0 -81
- package/dist/tags/yaml-1.1/timestamp.js +0 -105
- package/dist/types.js +0 -29
- package/index.d.ts +0 -519
- package/index.js +0 -1
- package/types.d.ts +0 -379
- package/types.js +0 -17
- package/types.mjs +0 -17
- package/util.d.ts +0 -76
- package/util.mjs +0 -15
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { Scalar } from '../../ast/Scalar.js';
|
|
2
|
-
import { stringifyNumber } from '../../stringify/stringifyNumber.js';
|
|
3
|
-
import { failsafe } from '../failsafe/index.js';
|
|
4
|
-
import { nullOptions, boolOptions, intOptions } from '../options.js';
|
|
5
|
-
import { binary } from './binary.js';
|
|
6
|
-
import { omap } from './omap.js';
|
|
7
|
-
import { pairs } from './pairs.js';
|
|
8
|
-
import { set } from './set.js';
|
|
9
|
-
import { intTime, floatTime, timestamp } from './timestamp.js';
|
|
10
|
-
|
|
11
|
-
/* global BigInt */
|
|
12
|
-
|
|
13
|
-
const boolStringify = ({
|
|
14
|
-
value,
|
|
15
|
-
sourceStr
|
|
16
|
-
}) => {
|
|
17
|
-
const boolObj = value ? trueObj : falseObj;
|
|
18
|
-
if (sourceStr && boolObj.test.test(sourceStr)) return sourceStr;
|
|
19
|
-
return value ? boolOptions.trueStr : boolOptions.falseStr;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const boolResolve = (value, str) => {
|
|
23
|
-
const node = new Scalar(value);
|
|
24
|
-
node.sourceStr = str;
|
|
25
|
-
return node;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const trueObj = {
|
|
29
|
-
identify: value => value === true,
|
|
30
|
-
default: true,
|
|
31
|
-
tag: 'tag:yaml.org,2002:bool',
|
|
32
|
-
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
33
|
-
resolve: str => boolResolve(true, str),
|
|
34
|
-
options: boolOptions,
|
|
35
|
-
stringify: boolStringify
|
|
36
|
-
};
|
|
37
|
-
const falseObj = {
|
|
38
|
-
identify: value => value === false,
|
|
39
|
-
default: true,
|
|
40
|
-
tag: 'tag:yaml.org,2002:bool',
|
|
41
|
-
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
|
|
42
|
-
resolve: str => boolResolve(false, str),
|
|
43
|
-
options: boolOptions,
|
|
44
|
-
stringify: boolStringify
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const intIdentify = value => typeof value === 'bigint' || Number.isInteger(value);
|
|
48
|
-
|
|
49
|
-
function intResolve(str, offset, radix) {
|
|
50
|
-
const sign = str[0];
|
|
51
|
-
if (sign === '-' || sign === '+') offset += 1;
|
|
52
|
-
str = str.substring(offset).replace(/_/g, '');
|
|
53
|
-
|
|
54
|
-
if (intOptions.asBigInt) {
|
|
55
|
-
switch (radix) {
|
|
56
|
-
case 2:
|
|
57
|
-
str = "0b".concat(str);
|
|
58
|
-
break;
|
|
59
|
-
|
|
60
|
-
case 8:
|
|
61
|
-
str = "0o".concat(str);
|
|
62
|
-
break;
|
|
63
|
-
|
|
64
|
-
case 16:
|
|
65
|
-
str = "0x".concat(str);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const n = BigInt(str);
|
|
70
|
-
return sign === '-' ? BigInt(-1) * n : n;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const n = parseInt(str, radix);
|
|
74
|
-
return sign === '-' ? -1 * n : n;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function intStringify(node, radix, prefix) {
|
|
78
|
-
const {
|
|
79
|
-
value
|
|
80
|
-
} = node;
|
|
81
|
-
|
|
82
|
-
if (intIdentify(value)) {
|
|
83
|
-
const str = value.toString(radix);
|
|
84
|
-
return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return stringifyNumber(node);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const yaml11 = failsafe.concat([{
|
|
91
|
-
identify: value => value == null,
|
|
92
|
-
createNode: (schema, value, ctx) => ctx.wrapScalars ? new Scalar(null) : null,
|
|
93
|
-
default: true,
|
|
94
|
-
tag: 'tag:yaml.org,2002:null',
|
|
95
|
-
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
96
|
-
resolve: str => {
|
|
97
|
-
const node = new Scalar(null);
|
|
98
|
-
node.sourceStr = str;
|
|
99
|
-
return node;
|
|
100
|
-
},
|
|
101
|
-
options: nullOptions,
|
|
102
|
-
stringify: ({
|
|
103
|
-
sourceStr
|
|
104
|
-
}) => sourceStr !== null && sourceStr !== void 0 ? sourceStr : nullOptions.nullStr
|
|
105
|
-
}, trueObj, falseObj, {
|
|
106
|
-
identify: intIdentify,
|
|
107
|
-
default: true,
|
|
108
|
-
tag: 'tag:yaml.org,2002:int',
|
|
109
|
-
format: 'BIN',
|
|
110
|
-
test: /^[-+]?0b[0-1_]+$/,
|
|
111
|
-
resolve: str => intResolve(str, 2, 2),
|
|
112
|
-
stringify: node => intStringify(node, 2, '0b')
|
|
113
|
-
}, {
|
|
114
|
-
identify: intIdentify,
|
|
115
|
-
default: true,
|
|
116
|
-
tag: 'tag:yaml.org,2002:int',
|
|
117
|
-
format: 'OCT',
|
|
118
|
-
test: /^[-+]?0[0-7_]+$/,
|
|
119
|
-
resolve: str => intResolve(str, 1, 8),
|
|
120
|
-
stringify: node => intStringify(node, 8, '0')
|
|
121
|
-
}, {
|
|
122
|
-
identify: intIdentify,
|
|
123
|
-
default: true,
|
|
124
|
-
tag: 'tag:yaml.org,2002:int',
|
|
125
|
-
test: /^[-+]?[0-9][0-9_]*$/,
|
|
126
|
-
resolve: str => intResolve(str, 0, 10),
|
|
127
|
-
stringify: stringifyNumber
|
|
128
|
-
}, {
|
|
129
|
-
identify: intIdentify,
|
|
130
|
-
default: true,
|
|
131
|
-
tag: 'tag:yaml.org,2002:int',
|
|
132
|
-
format: 'HEX',
|
|
133
|
-
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
134
|
-
resolve: str => intResolve(str, 2, 16),
|
|
135
|
-
stringify: node => intStringify(node, 16, '0x')
|
|
136
|
-
}, {
|
|
137
|
-
identify: value => typeof value === 'number',
|
|
138
|
-
default: true,
|
|
139
|
-
tag: 'tag:yaml.org,2002:float',
|
|
140
|
-
test: /^[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN)$/,
|
|
141
|
-
resolve: str => str.slice(-3).toLowerCase() === 'nan' ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
142
|
-
stringify: stringifyNumber
|
|
143
|
-
}, {
|
|
144
|
-
identify: value => typeof value === 'number',
|
|
145
|
-
default: true,
|
|
146
|
-
tag: 'tag:yaml.org,2002:float',
|
|
147
|
-
format: 'EXP',
|
|
148
|
-
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
149
|
-
resolve: str => parseFloat(str.replace(/_/g, '')),
|
|
150
|
-
stringify: ({
|
|
151
|
-
value
|
|
152
|
-
}) => Number(value).toExponential()
|
|
153
|
-
}, {
|
|
154
|
-
identify: value => typeof value === 'number',
|
|
155
|
-
default: true,
|
|
156
|
-
tag: 'tag:yaml.org,2002:float',
|
|
157
|
-
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
158
|
-
|
|
159
|
-
resolve(str) {
|
|
160
|
-
const node = new Scalar(parseFloat(str.replace(/_/g, '')));
|
|
161
|
-
const dot = str.indexOf('.');
|
|
162
|
-
|
|
163
|
-
if (dot !== -1) {
|
|
164
|
-
const f = str.substring(dot + 1).replace(/_/g, '');
|
|
165
|
-
if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return node;
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
stringify: stringifyNumber
|
|
172
|
-
}], binary, omap, pairs, set, intTime, floatTime, timestamp);
|
|
173
|
-
|
|
174
|
-
export { yaml11 };
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { Pair } from '../../ast/Pair.js';
|
|
3
|
-
import { Scalar } from '../../ast/Scalar.js';
|
|
4
|
-
import { YAMLMap } from '../../ast/YAMLMap.js';
|
|
5
|
-
import { YAMLSeq } from '../../ast/YAMLSeq.js';
|
|
6
|
-
import { toJS } from '../../ast/toJS.js';
|
|
7
|
-
import { parsePairs, createPairs } from './pairs.js';
|
|
8
|
-
|
|
9
|
-
class YAMLOMap extends YAMLSeq {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
|
|
13
|
-
_defineProperty(this, "add", YAMLMap.prototype.add.bind(this));
|
|
14
|
-
|
|
15
|
-
_defineProperty(this, "delete", YAMLMap.prototype.delete.bind(this));
|
|
16
|
-
|
|
17
|
-
_defineProperty(this, "get", YAMLMap.prototype.get.bind(this));
|
|
18
|
-
|
|
19
|
-
_defineProperty(this, "has", YAMLMap.prototype.has.bind(this));
|
|
20
|
-
|
|
21
|
-
_defineProperty(this, "set", YAMLMap.prototype.set.bind(this));
|
|
22
|
-
|
|
23
|
-
this.tag = YAMLOMap.tag;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
toJSON(_, ctx) {
|
|
27
|
-
const map = new Map();
|
|
28
|
-
if (ctx && ctx.onCreate) ctx.onCreate(map);
|
|
29
|
-
|
|
30
|
-
for (const pair of this.items) {
|
|
31
|
-
let key, value;
|
|
32
|
-
|
|
33
|
-
if (pair instanceof Pair) {
|
|
34
|
-
key = toJS(pair.key, '', ctx);
|
|
35
|
-
value = toJS(pair.value, key, ctx);
|
|
36
|
-
} else {
|
|
37
|
-
key = toJS(pair, '', ctx);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
|
|
41
|
-
map.set(key, value);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return map;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
_defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
|
|
50
|
-
|
|
51
|
-
function parseOMap(seq, onError) {
|
|
52
|
-
const pairs = parsePairs(seq, onError);
|
|
53
|
-
const seenKeys = [];
|
|
54
|
-
|
|
55
|
-
for (const {
|
|
56
|
-
key
|
|
57
|
-
} of pairs.items) {
|
|
58
|
-
if (key instanceof Scalar) {
|
|
59
|
-
if (seenKeys.includes(key.value)) {
|
|
60
|
-
onError("Ordered maps must not include duplicate keys: ".concat(key.value));
|
|
61
|
-
} else {
|
|
62
|
-
seenKeys.push(key.value);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return Object.assign(new YAMLOMap(), pairs);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function createOMap(schema, iterable, ctx) {
|
|
71
|
-
const pairs = createPairs(schema, iterable, ctx);
|
|
72
|
-
const omap = new YAMLOMap();
|
|
73
|
-
omap.items = pairs.items;
|
|
74
|
-
return omap;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const omap = {
|
|
78
|
-
identify: value => value instanceof Map,
|
|
79
|
-
nodeClass: YAMLOMap,
|
|
80
|
-
default: false,
|
|
81
|
-
tag: 'tag:yaml.org,2002:omap',
|
|
82
|
-
resolve: parseOMap,
|
|
83
|
-
createNode: createOMap
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export { YAMLOMap, omap };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Pair, createPair } from '../../ast/Pair.js';
|
|
2
|
-
import { YAMLMap } from '../../ast/YAMLMap.js';
|
|
3
|
-
import { YAMLSeq } from '../../ast/YAMLSeq.js';
|
|
4
|
-
|
|
5
|
-
function parsePairs(seq, onError) {
|
|
6
|
-
if (seq instanceof YAMLSeq) {
|
|
7
|
-
for (let i = 0; i < seq.items.length; ++i) {
|
|
8
|
-
let item = seq.items[i];
|
|
9
|
-
if (item instanceof Pair) continue;else if (item instanceof YAMLMap) {
|
|
10
|
-
if (item.items.length > 1) onError('Each pair must have its own sequence indicator');
|
|
11
|
-
const pair = item.items[0] || new Pair();
|
|
12
|
-
if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore;
|
|
13
|
-
if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment;
|
|
14
|
-
item = pair;
|
|
15
|
-
}
|
|
16
|
-
seq.items[i] = item instanceof Pair ? item : new Pair(item);
|
|
17
|
-
}
|
|
18
|
-
} else onError('Expected a sequence for this tag');
|
|
19
|
-
|
|
20
|
-
return seq;
|
|
21
|
-
}
|
|
22
|
-
function createPairs(schema, iterable, ctx) {
|
|
23
|
-
const {
|
|
24
|
-
replacer
|
|
25
|
-
} = ctx;
|
|
26
|
-
const pairs = new YAMLSeq(schema);
|
|
27
|
-
pairs.tag = 'tag:yaml.org,2002:pairs';
|
|
28
|
-
let i = 0;
|
|
29
|
-
|
|
30
|
-
for (let it of iterable) {
|
|
31
|
-
if (typeof replacer === 'function') it = replacer.call(iterable, String(i++), it);
|
|
32
|
-
let key, value;
|
|
33
|
-
|
|
34
|
-
if (Array.isArray(it)) {
|
|
35
|
-
if (it.length === 2) {
|
|
36
|
-
key = it[0];
|
|
37
|
-
value = it[1];
|
|
38
|
-
} else throw new TypeError("Expected [key, value] tuple: ".concat(it));
|
|
39
|
-
} else if (it && it instanceof Object) {
|
|
40
|
-
const keys = Object.keys(it);
|
|
41
|
-
|
|
42
|
-
if (keys.length === 1) {
|
|
43
|
-
key = keys[0];
|
|
44
|
-
value = it[key];
|
|
45
|
-
} else throw new TypeError("Expected { key: value } tuple: ".concat(it));
|
|
46
|
-
} else {
|
|
47
|
-
key = it;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
pairs.items.push(createPair(key, value, ctx));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return pairs;
|
|
54
|
-
}
|
|
55
|
-
const pairs = {
|
|
56
|
-
default: false,
|
|
57
|
-
tag: 'tag:yaml.org,2002:pairs',
|
|
58
|
-
resolve: parsePairs,
|
|
59
|
-
createNode: createPairs
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export { createPairs, pairs, parsePairs };
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { Pair, createPair } from '../../ast/Pair.js';
|
|
3
|
-
import { Scalar } from '../../ast/Scalar.js';
|
|
4
|
-
import { YAMLMap, findPair } from '../../ast/YAMLMap.js';
|
|
5
|
-
|
|
6
|
-
class YAMLSet extends YAMLMap {
|
|
7
|
-
constructor(schema) {
|
|
8
|
-
super(schema);
|
|
9
|
-
this.tag = YAMLSet.tag;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
add(key) {
|
|
13
|
-
const pair = key instanceof Pair ? key : new Pair(key);
|
|
14
|
-
const prev = findPair(this.items, pair.key);
|
|
15
|
-
if (!prev) this.items.push(pair);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
get(key, keepPair) {
|
|
19
|
-
const pair = findPair(this.items, key);
|
|
20
|
-
return !keepPair && pair instanceof Pair ? pair.key instanceof Scalar ? pair.key.value : pair.key : pair;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
set(key, value) {
|
|
24
|
-
if (typeof value !== 'boolean') throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat(typeof value));
|
|
25
|
-
const prev = findPair(this.items, key);
|
|
26
|
-
|
|
27
|
-
if (prev && !value) {
|
|
28
|
-
this.items.splice(this.items.indexOf(prev), 1);
|
|
29
|
-
} else if (!prev && value) {
|
|
30
|
-
this.items.push(new Pair(key));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
toJSON(_, ctx) {
|
|
35
|
-
return super.toJSON(_, ctx, Set);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
toString(ctx, onComment, onChompKeep) {
|
|
39
|
-
if (!ctx) return JSON.stringify(this);
|
|
40
|
-
if (this.hasAllNullValues()) return super.toString(ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
|
|
46
|
-
|
|
47
|
-
function parseSet(map, onError) {
|
|
48
|
-
if (map instanceof YAMLMap) {
|
|
49
|
-
if (map.hasAllNullValues()) return Object.assign(new YAMLSet(), map);else onError('Set items must all have null values');
|
|
50
|
-
} else onError('Expected a mapping for this tag');
|
|
51
|
-
|
|
52
|
-
return map;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function createSet(schema, iterable, ctx) {
|
|
56
|
-
const {
|
|
57
|
-
replacer
|
|
58
|
-
} = ctx;
|
|
59
|
-
const set = new YAMLSet(schema);
|
|
60
|
-
|
|
61
|
-
for (let value of iterable) {
|
|
62
|
-
if (typeof replacer === 'function') value = replacer.call(iterable, value, value);
|
|
63
|
-
set.items.push(createPair(value, null, ctx));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return set;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const set = {
|
|
70
|
-
identify: value => value instanceof Set,
|
|
71
|
-
nodeClass: YAMLSet,
|
|
72
|
-
default: false,
|
|
73
|
-
tag: 'tag:yaml.org,2002:set',
|
|
74
|
-
resolve: parseSet,
|
|
75
|
-
createNode: createSet
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export { YAMLSet, set };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { intOptions } from '../options.js';
|
|
2
|
-
import { stringifyNumber } from '../../stringify/stringifyNumber.js';
|
|
3
|
-
|
|
4
|
-
/* global BigInt */
|
|
5
|
-
|
|
6
|
-
const parseSexagesimal = (str, isInt) => {
|
|
7
|
-
const sign = str[0];
|
|
8
|
-
const parts = sign === '-' || sign === '+' ? str.substring(1) : str;
|
|
9
|
-
|
|
10
|
-
const num = n => isInt && intOptions.asBigInt ? BigInt(n) : Number(n);
|
|
11
|
-
|
|
12
|
-
const res = parts.replace(/_/g, '').split(':').reduce((res, p) => res * num(60) + num(p), num(0));
|
|
13
|
-
return sign === '-' ? num(-1) * res : res;
|
|
14
|
-
}; // hhhh:mm:ss.sss
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const stringifySexagesimal = ({
|
|
18
|
-
value
|
|
19
|
-
}) => {
|
|
20
|
-
let num = n => n;
|
|
21
|
-
|
|
22
|
-
if (typeof value === 'bigint') num = n => BigInt(n);else if (isNaN(value) || !isFinite(value)) return stringifyNumber(value);
|
|
23
|
-
let sign = '';
|
|
24
|
-
|
|
25
|
-
if (value < 0) {
|
|
26
|
-
sign = '-';
|
|
27
|
-
value *= num(-1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const _60 = num(60);
|
|
31
|
-
|
|
32
|
-
const parts = [value % _60]; // seconds, including ms
|
|
33
|
-
|
|
34
|
-
if (value < 60) {
|
|
35
|
-
parts.unshift(0); // at least one : is required
|
|
36
|
-
} else {
|
|
37
|
-
value = (value - parts[0]) / _60;
|
|
38
|
-
parts.unshift(value % _60); // minutes
|
|
39
|
-
|
|
40
|
-
if (value >= 60) {
|
|
41
|
-
value = (value - parts[0]) / _60;
|
|
42
|
-
parts.unshift(value); // hours
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return sign + parts.map(n => n < 10 ? '0' + String(n) : String(n)).join(':').replace(/000000\d*$/, '') // % 60 may introduce error
|
|
47
|
-
;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const intTime = {
|
|
51
|
-
identify: value => typeof value === 'bigint' || Number.isInteger(value),
|
|
52
|
-
default: true,
|
|
53
|
-
tag: 'tag:yaml.org,2002:int',
|
|
54
|
-
format: 'TIME',
|
|
55
|
-
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
56
|
-
resolve: str => parseSexagesimal(str, true),
|
|
57
|
-
stringify: stringifySexagesimal
|
|
58
|
-
};
|
|
59
|
-
const floatTime = {
|
|
60
|
-
identify: value => typeof value === 'number',
|
|
61
|
-
default: true,
|
|
62
|
-
tag: 'tag:yaml.org,2002:float',
|
|
63
|
-
format: 'TIME',
|
|
64
|
-
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
65
|
-
resolve: str => parseSexagesimal(str, false),
|
|
66
|
-
stringify: stringifySexagesimal
|
|
67
|
-
};
|
|
68
|
-
const timestamp = {
|
|
69
|
-
identify: value => value instanceof Date,
|
|
70
|
-
default: true,
|
|
71
|
-
tag: 'tag:yaml.org,2002:timestamp',
|
|
72
|
-
// If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
|
|
73
|
-
// may be omitted altogether, resulting in a date format. In such a case, the time part is
|
|
74
|
-
// assumed to be 00:00:00Z (start of day, UTC).
|
|
75
|
-
test: RegExp('^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd
|
|
76
|
-
'(?:' + // time is optional
|
|
77
|
-
'(?:t|T|[ \\t]+)' + // t | T | whitespace
|
|
78
|
-
'([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)?
|
|
79
|
-
'(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
|
|
80
|
-
')?$'),
|
|
81
|
-
|
|
82
|
-
resolve(str) {
|
|
83
|
-
let [, year, month, day, hour, minute, second, millisec, tz] = str.match(timestamp.test);
|
|
84
|
-
if (millisec) millisec = (millisec + '00').substr(1, 3);
|
|
85
|
-
let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0);
|
|
86
|
-
|
|
87
|
-
if (tz && tz !== 'Z') {
|
|
88
|
-
let d = parseSexagesimal(tz, false);
|
|
89
|
-
if (Math.abs(d) < 30) d *= 60;
|
|
90
|
-
date -= 60000 * d;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return new Date(date);
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
stringify: ({
|
|
97
|
-
value
|
|
98
|
-
}) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export { floatTime, intTime, timestamp };
|
package/browser/dist/types.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { binaryOptions, boolOptions, intOptions, nullOptions, strOptions } from './tags/options.js';
|
|
2
|
-
export { Schema } from './doc/Schema.js';
|
|
3
|
-
export { Alias } from './ast/Alias.js';
|
|
4
|
-
export { Collection } from './ast/Collection.js';
|
|
5
|
-
export { Merge } from './ast/Merge.js';
|
|
6
|
-
export { Node } from './ast/Node.js';
|
|
7
|
-
export { Pair } from './ast/Pair.js';
|
|
8
|
-
export { Scalar } from './ast/Scalar.js';
|
|
9
|
-
export { YAMLMap } from './ast/YAMLMap.js';
|
|
10
|
-
export { YAMLSeq } from './ast/YAMLSeq.js';
|
package/cst.d.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { Type, YAMLSyntaxError } from './util'
|
|
2
|
-
|
|
3
|
-
export namespace CST {
|
|
4
|
-
interface Range {
|
|
5
|
-
start: number
|
|
6
|
-
end: number
|
|
7
|
-
origStart?: number
|
|
8
|
-
origEnd?: number
|
|
9
|
-
isEmpty(): boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface ParseContext {
|
|
13
|
-
/** Node starts at beginning of line */
|
|
14
|
-
atLineStart: boolean
|
|
15
|
-
/** true if currently in a collection context */
|
|
16
|
-
inCollection: boolean
|
|
17
|
-
/** true if currently in a flow context */
|
|
18
|
-
inFlow: boolean
|
|
19
|
-
/** Current level of indentation */
|
|
20
|
-
indent: number
|
|
21
|
-
/** Start of the current line */
|
|
22
|
-
lineStart: number
|
|
23
|
-
/** The parent of the node */
|
|
24
|
-
parent: Node
|
|
25
|
-
/** Source of the YAML document */
|
|
26
|
-
src: string
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface Node {
|
|
30
|
-
context: ParseContext | null
|
|
31
|
-
/** if not null, indicates a parser failure */
|
|
32
|
-
error: YAMLSyntaxError | null
|
|
33
|
-
/** span of context.src parsed into this node */
|
|
34
|
-
range: Range | null
|
|
35
|
-
valueRange: Range | null
|
|
36
|
-
/** anchors, tags and comments */
|
|
37
|
-
props: Range[]
|
|
38
|
-
/** specific node type */
|
|
39
|
-
type: Type
|
|
40
|
-
/** if non-null, overrides source value */
|
|
41
|
-
value: string | null
|
|
42
|
-
|
|
43
|
-
readonly anchor: string | null
|
|
44
|
-
readonly comment: string | null
|
|
45
|
-
readonly hasComment: boolean
|
|
46
|
-
readonly hasProps: boolean
|
|
47
|
-
readonly jsonLike: boolean
|
|
48
|
-
readonly rangeAsLinePos: null | {
|
|
49
|
-
start: { line: number; col: number }
|
|
50
|
-
end?: { line: number; col: number }
|
|
51
|
-
}
|
|
52
|
-
readonly rawValue: string | null
|
|
53
|
-
readonly tag:
|
|
54
|
-
| null
|
|
55
|
-
| { verbatim: string }
|
|
56
|
-
| { handle: string; suffix: string }
|
|
57
|
-
readonly valueRangeContainsNewline: boolean
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface Alias extends Node {
|
|
61
|
-
type: Type.ALIAS
|
|
62
|
-
/** contain the anchor without the * prefix */
|
|
63
|
-
readonly rawValue: string
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type Scalar = BlockValue | PlainValue | QuoteValue
|
|
67
|
-
|
|
68
|
-
interface BlockValue extends Node {
|
|
69
|
-
type: Type.BLOCK_FOLDED | Type.BLOCK_LITERAL
|
|
70
|
-
chomping: 'CLIP' | 'KEEP' | 'STRIP'
|
|
71
|
-
blockIndent: number | null
|
|
72
|
-
header: Range
|
|
73
|
-
readonly strValue: string | null
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
interface BlockFolded extends BlockValue {
|
|
77
|
-
type: Type.BLOCK_FOLDED
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
interface BlockLiteral extends BlockValue {
|
|
81
|
-
type: Type.BLOCK_LITERAL
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
interface PlainValue extends Node {
|
|
85
|
-
type: Type.PLAIN
|
|
86
|
-
readonly strValue: string | null
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
interface QuoteValue extends Node {
|
|
90
|
-
type: Type.QUOTE_DOUBLE | Type.QUOTE_SINGLE
|
|
91
|
-
readonly strValue:
|
|
92
|
-
| null
|
|
93
|
-
| string
|
|
94
|
-
| { str: string; errors: YAMLSyntaxError[] }
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
interface QuoteDouble extends QuoteValue {
|
|
98
|
-
type: Type.QUOTE_DOUBLE
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
interface QuoteSingle extends QuoteValue {
|
|
102
|
-
type: Type.QUOTE_SINGLE
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
interface Comment extends Node {
|
|
106
|
-
type: Type.COMMENT
|
|
107
|
-
readonly anchor: null
|
|
108
|
-
readonly comment: string
|
|
109
|
-
readonly rawValue: null
|
|
110
|
-
readonly tag: null
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
interface BlankLine extends Node {
|
|
114
|
-
type: Type.BLANK_LINE
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
interface MapItem extends Node {
|
|
118
|
-
type: Type.MAP_KEY | Type.MAP_VALUE
|
|
119
|
-
node: ContentNode | null
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
interface MapKey extends MapItem {
|
|
123
|
-
type: Type.MAP_KEY
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
interface MapValue extends MapItem {
|
|
127
|
-
type: Type.MAP_VALUE
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
interface Map extends Node {
|
|
131
|
-
type: Type.MAP
|
|
132
|
-
/** implicit keys are not wrapped */
|
|
133
|
-
items: Array<BlankLine | Comment | Alias | Scalar | MapItem>
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
interface SeqItem extends Node {
|
|
137
|
-
type: Type.SEQ_ITEM
|
|
138
|
-
node: ContentNode | null
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
interface Seq extends Node {
|
|
142
|
-
type: Type.SEQ
|
|
143
|
-
items: Array<BlankLine | Comment | SeqItem>
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
interface FlowChar {
|
|
147
|
-
char: '{' | '}' | '[' | ']' | ',' | '?' | ':'
|
|
148
|
-
offset: number
|
|
149
|
-
origOffset?: number
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
interface FlowCollection extends Node {
|
|
153
|
-
type: Type.FLOW_MAP | Type.FLOW_SEQ
|
|
154
|
-
items: Array<
|
|
155
|
-
FlowChar | BlankLine | Comment | Alias | Scalar | FlowCollection
|
|
156
|
-
>
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
interface FlowMap extends FlowCollection {
|
|
160
|
-
type: Type.FLOW_MAP
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
interface FlowSeq extends FlowCollection {
|
|
164
|
-
type: Type.FLOW_SEQ
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
type ContentNode = Alias | Scalar | Map | Seq | FlowCollection
|
|
168
|
-
|
|
169
|
-
interface Directive extends Node {
|
|
170
|
-
type: Type.DIRECTIVE
|
|
171
|
-
name: string
|
|
172
|
-
readonly anchor: null
|
|
173
|
-
readonly parameters: string[]
|
|
174
|
-
readonly tag: null
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
interface Document extends Node {
|
|
178
|
-
type: Type.DOCUMENT
|
|
179
|
-
directives: Array<BlankLine | Comment | Directive>
|
|
180
|
-
contents: Array<BlankLine | Comment | ContentNode>
|
|
181
|
-
readonly anchor: null
|
|
182
|
-
readonly comment: null
|
|
183
|
-
readonly tag: null
|
|
184
|
-
}
|
|
185
|
-
}
|