yaml 1.9.1 → 1.10.2
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/README.md +25 -25
- package/browser/dist/PlainValue-b8036b75.js +1275 -0
- package/browser/dist/Schema-e94716c8.js +682 -0
- package/browser/dist/index.js +860 -27
- package/browser/dist/legacy-exports.js +3 -0
- package/browser/dist/package.json +1 -0
- package/browser/dist/parse-cst.js +1904 -0
- package/browser/dist/resolveSeq-492ab440.js +2419 -0
- package/browser/dist/types.js +4 -0
- package/browser/dist/util.js +2 -0
- package/browser/dist/warnings-df54cb69.js +499 -0
- package/browser/index.js +1 -1
- package/browser/map.js +2 -4
- package/browser/pair.js +2 -4
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +2 -4
- package/browser/schema.js +7 -10
- package/browser/seq.js +2 -4
- package/browser/types/binary.js +7 -5
- package/browser/types/omap.js +3 -4
- package/browser/types/pairs.js +3 -4
- package/browser/types/set.js +3 -4
- package/browser/types/timestamp.js +9 -5
- package/browser/types.js +1 -13
- package/browser/util.js +1 -18
- package/dist/Document-9b4560a1.js +757 -0
- package/dist/PlainValue-ec8e588e.js +876 -0
- package/dist/Schema-88e323a7.js +525 -0
- package/dist/index.js +20 -84
- package/dist/legacy-exports.js +16 -0
- package/dist/parse-cst.js +1753 -0
- package/dist/resolveSeq-d03cb037.js +2161 -0
- package/dist/test-events.js +11 -9
- package/dist/types.js +23 -0
- package/dist/util.js +19 -0
- package/dist/warnings-1000a372.js +416 -0
- package/index.d.ts +23 -9
- package/map.js +2 -2
- package/package.json +27 -42
- package/pair.js +2 -2
- package/parse-cst.d.ts +4 -0
- package/parse-cst.js +1 -1
- package/scalar.js +2 -2
- package/schema.js +8 -6
- package/seq.js +2 -2
- package/types/binary.js +3 -2
- package/types/omap.js +3 -2
- package/types/pairs.js +3 -2
- package/types/set.js +3 -2
- package/types/timestamp.js +6 -6
- package/types.d.ts +113 -98
- package/types.js +16 -11
- package/types.mjs +15 -19
- package/util.js +14 -14
- package/util.mjs +13 -20
- package/browser/dist/Anchors.js +0 -130
- package/browser/dist/Document.js +0 -824
- package/browser/dist/addComment.js +0 -8
- package/browser/dist/constants.js +0 -26
- package/browser/dist/cst/Alias.js +0 -46
- package/browser/dist/cst/BlankLine.js +0 -52
- package/browser/dist/cst/BlockValue.js +0 -251
- package/browser/dist/cst/Collection.js +0 -278
- package/browser/dist/cst/CollectionItem.js +0 -140
- package/browser/dist/cst/Comment.js +0 -44
- package/browser/dist/cst/Directive.js +0 -76
- package/browser/dist/cst/Document.js +0 -286
- package/browser/dist/cst/FlowCollection.js +0 -220
- package/browser/dist/cst/Node.js +0 -386
- package/browser/dist/cst/ParseContext.js +0 -246
- package/browser/dist/cst/PlainValue.js +0 -170
- package/browser/dist/cst/QuoteDouble.js +0 -245
- package/browser/dist/cst/QuoteSingle.js +0 -120
- package/browser/dist/cst/Range.js +0 -64
- package/browser/dist/cst/parse.js +0 -48
- package/browser/dist/cst/source-utils.js +0 -168
- package/browser/dist/errors.js +0 -127
- package/browser/dist/foldFlowLines.js +0 -138
- package/browser/dist/listTagNames.js +0 -28
- package/browser/dist/schema/Alias.js +0 -135
- package/browser/dist/schema/Collection.js +0 -260
- package/browser/dist/schema/Map.js +0 -161
- package/browser/dist/schema/Merge.js +0 -118
- package/browser/dist/schema/Node.js +0 -4
- package/browser/dist/schema/Pair.js +0 -194
- package/browser/dist/schema/Scalar.js +0 -42
- package/browser/dist/schema/Seq.js +0 -116
- package/browser/dist/schema/index.js +0 -368
- package/browser/dist/schema/parseMap.js +0 -312
- package/browser/dist/schema/parseSeq.js +0 -168
- package/browser/dist/schema/parseUtils.js +0 -106
- package/browser/dist/stringify.js +0 -332
- package/browser/dist/tags/core.js +0 -141
- package/browser/dist/tags/failsafe/index.js +0 -4
- package/browser/dist/tags/failsafe/map.js +0 -53
- package/browser/dist/tags/failsafe/seq.js +0 -39
- package/browser/dist/tags/failsafe/string.js +0 -28
- package/browser/dist/tags/index.js +0 -36
- package/browser/dist/tags/json.js +0 -77
- package/browser/dist/tags/options.js +0 -26
- package/browser/dist/tags/yaml-1.1/binary.js +0 -87
- package/browser/dist/tags/yaml-1.1/index.js +0 -189
- package/browser/dist/tags/yaml-1.1/omap.js +0 -137
- package/browser/dist/tags/yaml-1.1/pairs.js +0 -78
- package/browser/dist/tags/yaml-1.1/set.js +0 -118
- package/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
- package/browser/dist/test-events.js +0 -163
- package/browser/dist/toJSON.js +0 -19
- package/browser/dist/warnings.js +0 -39
- package/dist/Anchors.js +0 -120
- package/dist/Document.js +0 -714
- package/dist/addComment.js +0 -14
- package/dist/constants.js +0 -31
- package/dist/cst/Alias.js +0 -33
- package/dist/cst/BlankLine.js +0 -40
- package/dist/cst/BlockValue.js +0 -243
- package/dist/cst/Collection.js +0 -266
- package/dist/cst/CollectionItem.js +0 -135
- package/dist/cst/Comment.js +0 -33
- package/dist/cst/Directive.js +0 -59
- package/dist/cst/Document.js +0 -276
- package/dist/cst/FlowCollection.js +0 -213
- package/dist/cst/Node.js +0 -360
- package/dist/cst/ParseContext.js +0 -253
- package/dist/cst/PlainValue.js +0 -156
- package/dist/cst/QuoteDouble.js +0 -232
- package/dist/cst/QuoteSingle.js +0 -108
- package/dist/cst/Range.js +0 -60
- package/dist/cst/parse.js +0 -50
- package/dist/cst/source-utils.js +0 -175
- package/dist/errors.js +0 -97
- package/dist/foldFlowLines.js +0 -143
- package/dist/listTagNames.js +0 -33
- package/dist/schema/Alias.js +0 -105
- package/dist/schema/Collection.js +0 -184
- package/dist/schema/Map.js +0 -98
- package/dist/schema/Merge.js +0 -75
- package/dist/schema/Node.js +0 -7
- package/dist/schema/Pair.js +0 -174
- package/dist/schema/Scalar.js +0 -26
- package/dist/schema/Seq.js +0 -73
- package/dist/schema/index.js +0 -310
- package/dist/schema/parseMap.js +0 -334
- package/dist/schema/parseSeq.js +0 -175
- package/dist/schema/parseUtils.js +0 -101
- package/dist/stringify.js +0 -352
- package/dist/tags/core.js +0 -121
- package/dist/tags/failsafe/index.js +0 -12
- package/dist/tags/failsafe/map.js +0 -32
- package/dist/tags/failsafe/seq.js +0 -29
- package/dist/tags/failsafe/string.js +0 -37
- package/dist/tags/index.js +0 -53
- package/dist/tags/json.js +0 -64
- package/dist/tags/options.js +0 -36
- package/dist/tags/yaml-1.1/binary.js +0 -94
- package/dist/tags/yaml-1.1/index.js +0 -162
- package/dist/tags/yaml-1.1/omap.js +0 -100
- package/dist/tags/yaml-1.1/pairs.js +0 -75
- package/dist/tags/yaml-1.1/set.js +0 -82
- package/dist/tags/yaml-1.1/timestamp.js +0 -90
- package/dist/toJSON.js +0 -21
- package/dist/warnings.js +0 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Eemeli Aro <eemeli@gmail.com>",
|
|
6
6
|
"repository": "github:eemeli/yaml",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"parser",
|
|
11
11
|
"stringifier"
|
|
12
12
|
],
|
|
13
|
-
"homepage": "https://eemeli.org/yaml/",
|
|
13
|
+
"homepage": "https://eemeli.org/yaml/v1/",
|
|
14
14
|
"files": [
|
|
15
15
|
"browser/",
|
|
16
16
|
"dist/",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"*.d.ts",
|
|
19
19
|
"*.js",
|
|
20
20
|
"*.mjs",
|
|
21
|
-
"
|
|
21
|
+
"!*config.js"
|
|
22
22
|
],
|
|
23
23
|
"type": "commonjs",
|
|
24
24
|
"main": "./index.js",
|
|
@@ -42,33 +42,33 @@
|
|
|
42
42
|
},
|
|
43
43
|
"exports": {
|
|
44
44
|
".": "./index.js",
|
|
45
|
-
"./": "./",
|
|
46
45
|
"./parse-cst": "./parse-cst.js",
|
|
47
46
|
"./types": [
|
|
48
47
|
{
|
|
49
|
-
"default": "./types.js",
|
|
50
48
|
"import": "./types.mjs"
|
|
51
49
|
},
|
|
52
50
|
"./types.js"
|
|
53
51
|
],
|
|
54
52
|
"./util": [
|
|
55
53
|
{
|
|
56
|
-
"default": "./util.js",
|
|
57
54
|
"import": "./util.mjs"
|
|
58
55
|
},
|
|
59
56
|
"./util.js"
|
|
60
|
-
]
|
|
57
|
+
],
|
|
58
|
+
"./": "./"
|
|
61
59
|
},
|
|
62
60
|
"scripts": {
|
|
63
|
-
"
|
|
61
|
+
"build": "npm run build:node && npm run build:browser",
|
|
62
|
+
"build:browser": "rollup -c rollup.browser-config.js",
|
|
63
|
+
"build:node": "rollup -c rollup.node-config.js",
|
|
64
64
|
"clean": "git clean -fdxe node_modules",
|
|
65
|
-
"dist:build": "babel src/ --out-dir dist/",
|
|
66
|
-
"build": "npm run dist:build && npm run browser:build",
|
|
67
|
-
"prettier": "prettier --write .",
|
|
68
65
|
"lint": "eslint src/",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"test
|
|
66
|
+
"prettier": "prettier --write .",
|
|
67
|
+
"start": "cross-env TRACE_LEVEL=log npm run build:node && node -i -e 'YAML=require(\".\")'",
|
|
68
|
+
"test": "jest",
|
|
69
|
+
"test:browsers": "cd playground && npm test",
|
|
70
|
+
"test:dist": "npm run build:node && jest",
|
|
71
|
+
"test:types": "tsc --lib ES2017 --noEmit tests/typings.ts",
|
|
72
72
|
"docs:install": "cd docs-slate && bundle install",
|
|
73
73
|
"docs:deploy": "cd docs-slate && ./deploy.sh",
|
|
74
74
|
"docs": "cd docs-slate && bundle exec middleman server",
|
|
@@ -76,18 +76,6 @@
|
|
|
76
76
|
"prepublishOnly": "npm run clean && npm test && npm run build"
|
|
77
77
|
},
|
|
78
78
|
"browserslist": "> 0.5%, not dead",
|
|
79
|
-
"jest": {
|
|
80
|
-
"collectCoverageFrom": [
|
|
81
|
-
"src/**/*.js"
|
|
82
|
-
],
|
|
83
|
-
"testMatch": [
|
|
84
|
-
"**/tests/**/*.js"
|
|
85
|
-
],
|
|
86
|
-
"testPathIgnorePatterns": [
|
|
87
|
-
"tests/common",
|
|
88
|
-
"tests/cst/common"
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
79
|
"prettier": {
|
|
92
80
|
"arrowParens": "avoid",
|
|
93
81
|
"semi": false,
|
|
@@ -95,25 +83,22 @@
|
|
|
95
83
|
"trailingComma": "none"
|
|
96
84
|
},
|
|
97
85
|
"devDependencies": {
|
|
98
|
-
"@babel/
|
|
99
|
-
"@babel/
|
|
100
|
-
"@babel/
|
|
101
|
-
"@
|
|
102
|
-
"@babel/preset-env": "^7.9.5",
|
|
86
|
+
"@babel/core": "^7.12.10",
|
|
87
|
+
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
|
88
|
+
"@babel/preset-env": "^7.12.11",
|
|
89
|
+
"@rollup/plugin-babel": "^5.2.3",
|
|
103
90
|
"babel-eslint": "^10.1.0",
|
|
104
|
-
"babel-jest": "^
|
|
91
|
+
"babel-jest": "^26.6.3",
|
|
105
92
|
"babel-plugin-trace": "^1.1.0",
|
|
106
93
|
"common-tags": "^1.8.0",
|
|
107
|
-
"cross-env": "^7.0.
|
|
108
|
-
"eslint": "^
|
|
109
|
-
"eslint-config-prettier": "^
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
"dependencies": {
|
|
116
|
-
"@babel/runtime": "^7.9.2"
|
|
94
|
+
"cross-env": "^7.0.3",
|
|
95
|
+
"eslint": "^7.19.0",
|
|
96
|
+
"eslint-config-prettier": "^7.2.0",
|
|
97
|
+
"fast-check": "^2.12.0",
|
|
98
|
+
"jest": "^26.6.3",
|
|
99
|
+
"prettier": "^2.2.1",
|
|
100
|
+
"rollup": "^2.38.2",
|
|
101
|
+
"typescript": "^4.1.3"
|
|
117
102
|
},
|
|
118
103
|
"engines": {
|
|
119
104
|
"node": ">= 6"
|
package/pair.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/
|
|
2
|
-
require('./dist/
|
|
1
|
+
module.exports = require('./dist/types').Pair
|
|
2
|
+
require('./dist/legacy-exports').warnFileDeprecation(__filename)
|
package/parse-cst.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export namespace CST {
|
|
|
51
51
|
readonly hasComment: boolean
|
|
52
52
|
readonly hasProps: boolean
|
|
53
53
|
readonly jsonLike: boolean
|
|
54
|
+
readonly rangeAsLinePos: null | {
|
|
55
|
+
start: { line: number; col: number }
|
|
56
|
+
end?: { line: number; col: number }
|
|
57
|
+
}
|
|
54
58
|
readonly rawValue: string | null
|
|
55
59
|
readonly tag:
|
|
56
60
|
| null
|
package/parse-cst.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./dist/cst
|
|
1
|
+
module.exports = require('./dist/parse-cst').parse
|
package/scalar.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/
|
|
2
|
-
require('./dist/
|
|
1
|
+
module.exports = require('./dist/types').Scalar
|
|
2
|
+
require('./dist/legacy-exports').warnFileDeprecation(__filename)
|
package/schema.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
module.exports.nullOptions = opt.nullOptions
|
|
4
|
-
module.exports.strOptions = opt.strOptions
|
|
5
|
-
module.exports.stringify = require('./dist/stringify').stringifyString
|
|
1
|
+
const types = require('./dist/types')
|
|
2
|
+
const util = require('./dist/util')
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
module.exports = types.Schema
|
|
5
|
+
module.exports.nullOptions = types.nullOptions
|
|
6
|
+
module.exports.strOptions = types.strOptions
|
|
7
|
+
module.exports.stringify = util.stringifyString
|
|
8
|
+
|
|
9
|
+
require('./dist/legacy-exports').warnFileDeprecation(__filename)
|
package/seq.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/
|
|
2
|
-
require('./dist/
|
|
1
|
+
module.exports = require('./dist/types').YAMLSeq
|
|
2
|
+
require('./dist/legacy-exports').warnFileDeprecation(__filename)
|
package/types/binary.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const legacy = require('../dist/legacy-exports')
|
|
5
|
+
exports.binary = legacy.binary
|
|
5
6
|
exports.default = [exports.binary]
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
legacy.warnFileDeprecation(__filename)
|
package/types/omap.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const legacy = require('../dist/legacy-exports')
|
|
2
|
+
module.exports = legacy.omap
|
|
3
|
+
legacy.warnFileDeprecation(__filename)
|
package/types/pairs.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const legacy = require('../dist/legacy-exports')
|
|
2
|
+
module.exports = legacy.pairs
|
|
3
|
+
legacy.warnFileDeprecation(__filename)
|
package/types/set.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const legacy = require('../dist/legacy-exports')
|
|
2
|
+
module.exports = legacy.set
|
|
3
|
+
legacy.warnFileDeprecation(__filename)
|
package/types/timestamp.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
exports.default = [
|
|
6
|
-
exports.floatTime =
|
|
7
|
-
exports.intTime =
|
|
8
|
-
exports.timestamp =
|
|
4
|
+
const legacy = require('../dist/legacy-exports')
|
|
5
|
+
exports.default = [legacy.intTime, legacy.floatTime, legacy.timestamp]
|
|
6
|
+
exports.floatTime = legacy.floatTime
|
|
7
|
+
exports.intTime = legacy.intTime
|
|
8
|
+
exports.timestamp = legacy.timestamp
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
legacy.warnFileDeprecation(__filename)
|
package/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export class Schema {
|
|
|
22
22
|
constructor(options: Schema.Options)
|
|
23
23
|
/**
|
|
24
24
|
* Convert any value into a `Node` using this schema, recursively turning
|
|
25
|
-
* objects into
|
|
25
|
+
* objects into collections.
|
|
26
26
|
*
|
|
27
27
|
* @param wrapScalars If `true`, also wraps plain values in `Scalar` objects;
|
|
28
28
|
* if undefined or `false` and `value` is not an object, it will be returned
|
|
@@ -35,7 +35,14 @@ export class Schema {
|
|
|
35
35
|
wrapScalars?: boolean,
|
|
36
36
|
tag?: string,
|
|
37
37
|
ctx?: Schema.CreateNodeContext
|
|
38
|
-
):
|
|
38
|
+
): Node
|
|
39
|
+
/**
|
|
40
|
+
* Convert a key and a value into a `Pair` using this schema, recursively
|
|
41
|
+
* wrapping all values as `Scalar` or `Collection` nodes.
|
|
42
|
+
*
|
|
43
|
+
* @param ctx To not wrap scalars, use a context `{ wrapScalars: false }`
|
|
44
|
+
*/
|
|
45
|
+
createPair(key: any, value: any, ctx?: Schema.CreateNodeContext): Pair
|
|
39
46
|
merge: boolean
|
|
40
47
|
name: Schema.Name
|
|
41
48
|
sortMapEntries: ((a: Pair, b: Pair) => number) | null
|
|
@@ -147,7 +154,7 @@ export namespace Schema {
|
|
|
147
154
|
* type with the `+` chomping indicator.
|
|
148
155
|
*/
|
|
149
156
|
stringify?: (
|
|
150
|
-
item:
|
|
157
|
+
item: Node,
|
|
151
158
|
ctx: Schema.StringifyContext,
|
|
152
159
|
onComment?: () => void,
|
|
153
160
|
onChompKeep?: () => void
|
|
@@ -170,7 +177,7 @@ export namespace Schema {
|
|
|
170
177
|
* Turns a CST node into an AST node. If returning a non-`Node` value, the
|
|
171
178
|
* output will be wrapped as a `Scalar`.
|
|
172
179
|
*/
|
|
173
|
-
resolve(doc: Document, cstNode: CST.Node):
|
|
180
|
+
resolve(doc: Document, cstNode: CST.Node): Node | any
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
interface DefaultTag extends BaseTag {
|
|
@@ -183,7 +190,7 @@ export namespace Schema {
|
|
|
183
190
|
/**
|
|
184
191
|
* Alternative form used by default tags; called with `test` match results.
|
|
185
192
|
*/
|
|
186
|
-
resolve(...match: string[]):
|
|
193
|
+
resolve(...match: string[]): Node | any
|
|
187
194
|
/**
|
|
188
195
|
* Together with `default` allows for values to be stringified without an
|
|
189
196
|
* explicit tag and detected using a regular expression. For most cases, it's
|
|
@@ -194,7 +201,29 @@ export namespace Schema {
|
|
|
194
201
|
}
|
|
195
202
|
}
|
|
196
203
|
|
|
197
|
-
export class
|
|
204
|
+
export class Node {
|
|
205
|
+
/** A comment on or immediately after this */
|
|
206
|
+
comment?: string | null
|
|
207
|
+
/** A comment before this */
|
|
208
|
+
commentBefore?: string | null
|
|
209
|
+
/** Only available when `keepCstNodes` is set to `true` */
|
|
210
|
+
cstNode?: CST.Node
|
|
211
|
+
/**
|
|
212
|
+
* The [start, end] range of characters of the source parsed
|
|
213
|
+
* into this node (undefined for pairs or if not parsed)
|
|
214
|
+
*/
|
|
215
|
+
range?: [number, number] | null
|
|
216
|
+
/** A blank line before this node and its commentBefore */
|
|
217
|
+
spaceBefore?: boolean
|
|
218
|
+
/** A fully qualified tag, if required */
|
|
219
|
+
tag?: string
|
|
220
|
+
/** A plain JS representation of this node */
|
|
221
|
+
toJSON(arg?: any): any
|
|
222
|
+
/** The type of this node */
|
|
223
|
+
type?: Type | Pair.Type
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export class Scalar extends Node {
|
|
198
227
|
constructor(value: any)
|
|
199
228
|
type?: Scalar.Type
|
|
200
229
|
/**
|
|
@@ -203,6 +232,8 @@ export class Scalar extends AST.Node {
|
|
|
203
232
|
*/
|
|
204
233
|
format?: 'BIN' | 'HEX' | 'OCT' | 'TIME'
|
|
205
234
|
value: any
|
|
235
|
+
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): any
|
|
236
|
+
toString(): string
|
|
206
237
|
}
|
|
207
238
|
export namespace Scalar {
|
|
208
239
|
type Type =
|
|
@@ -213,15 +244,27 @@ export namespace Scalar {
|
|
|
213
244
|
| Type.QUOTE_SINGLE
|
|
214
245
|
}
|
|
215
246
|
|
|
216
|
-
export class
|
|
247
|
+
export class Alias extends Node {
|
|
248
|
+
type: Type.ALIAS
|
|
249
|
+
source: Node
|
|
250
|
+
cstNode?: CST.Alias
|
|
251
|
+
toString(ctx: Schema.StringifyContext): string
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export class Pair extends Node {
|
|
217
255
|
constructor(key: any, value?: any)
|
|
218
|
-
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
|
|
219
256
|
type: Pair.Type.PAIR | Pair.Type.MERGE_PAIR
|
|
220
257
|
/** Always Node or null when parsed, but can be set to anything. */
|
|
221
258
|
key: any
|
|
222
259
|
/** Always Node or null when parsed, but can be set to anything. */
|
|
223
260
|
value: any
|
|
224
261
|
cstNode?: never // no corresponding cstNode
|
|
262
|
+
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
|
|
263
|
+
toString(
|
|
264
|
+
ctx?: Schema.StringifyContext,
|
|
265
|
+
onComment?: () => void,
|
|
266
|
+
onChompKeep?: () => void
|
|
267
|
+
): string
|
|
225
268
|
}
|
|
226
269
|
export namespace Pair {
|
|
227
270
|
enum Type {
|
|
@@ -230,14 +273,66 @@ export namespace Pair {
|
|
|
230
273
|
}
|
|
231
274
|
}
|
|
232
275
|
|
|
233
|
-
export class
|
|
276
|
+
export class Merge extends Pair {
|
|
277
|
+
type: Pair.Type.MERGE_PAIR
|
|
278
|
+
/** Always Scalar('<<'), defined by the type specification */
|
|
279
|
+
key: AST.PlainValue
|
|
280
|
+
/** Always YAMLSeq<Alias(Map)>, stringified as *A if length = 1 */
|
|
281
|
+
value: YAMLSeq
|
|
282
|
+
toString(ctx?: Schema.StringifyContext, onComment?: () => void): string
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export class Collection extends Node {
|
|
286
|
+
type?: Type.MAP | Type.FLOW_MAP | Type.SEQ | Type.FLOW_SEQ | Type.DOCUMENT
|
|
287
|
+
items: any[]
|
|
288
|
+
schema?: Schema
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
|
292
|
+
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
293
|
+
* that already exists in the map.
|
|
294
|
+
*/
|
|
295
|
+
add(value: any): void
|
|
296
|
+
addIn(path: Iterable<any>, value: any): void
|
|
297
|
+
/**
|
|
298
|
+
* Removes a value from the collection.
|
|
299
|
+
* @returns `true` if the item was found and removed.
|
|
300
|
+
*/
|
|
301
|
+
delete(key: any): boolean
|
|
302
|
+
deleteIn(path: Iterable<any>): boolean
|
|
303
|
+
/**
|
|
304
|
+
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
305
|
+
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
306
|
+
* `true` (collections are always returned intact).
|
|
307
|
+
*/
|
|
308
|
+
get(key: any, keepScalar?: boolean): any
|
|
309
|
+
getIn(path: Iterable<any>, keepScalar?: boolean): any
|
|
310
|
+
/**
|
|
311
|
+
* Checks if the collection includes a value with the key `key`.
|
|
312
|
+
*/
|
|
313
|
+
has(key: any): boolean
|
|
314
|
+
hasIn(path: Iterable<any>): boolean
|
|
315
|
+
/**
|
|
316
|
+
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
317
|
+
* boolean to add/remove the item from the set.
|
|
318
|
+
*/
|
|
319
|
+
set(key: any, value: any): void
|
|
320
|
+
setIn(path: Iterable<any>, value: any): void
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export class YAMLMap extends Collection {
|
|
234
324
|
type?: Type.FLOW_MAP | Type.MAP
|
|
235
|
-
items: Array<Pair
|
|
325
|
+
items: Array<Pair>
|
|
236
326
|
hasAllNullValues(): boolean
|
|
237
327
|
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
|
|
328
|
+
toString(
|
|
329
|
+
ctx?: Schema.StringifyContext,
|
|
330
|
+
onComment?: () => void,
|
|
331
|
+
onChompKeep?: () => void
|
|
332
|
+
): string
|
|
238
333
|
}
|
|
239
334
|
|
|
240
|
-
export class YAMLSeq extends
|
|
335
|
+
export class YAMLSeq extends Collection {
|
|
241
336
|
type?: Type.FLOW_SEQ | Type.SEQ
|
|
242
337
|
delete(key: number | string | Scalar): boolean
|
|
243
338
|
get(key: number | string | Scalar, keepScalar?: boolean): any
|
|
@@ -245,80 +340,14 @@ export class YAMLSeq extends AST.Collection {
|
|
|
245
340
|
set(key: number | string | Scalar, value: any): void
|
|
246
341
|
hasAllNullValues(): boolean
|
|
247
342
|
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): any[]
|
|
343
|
+
toString(
|
|
344
|
+
ctx?: Schema.StringifyContext,
|
|
345
|
+
onComment?: () => void,
|
|
346
|
+
onChompKeep?: () => void
|
|
347
|
+
): string
|
|
248
348
|
}
|
|
249
349
|
|
|
250
350
|
export namespace AST {
|
|
251
|
-
type AstNode = ScalarNode | CollectionNode | Alias
|
|
252
|
-
|
|
253
|
-
type ScalarNode =
|
|
254
|
-
| BlockFolded
|
|
255
|
-
| BlockLiteral
|
|
256
|
-
| PlainValue
|
|
257
|
-
| QuoteDouble
|
|
258
|
-
| QuoteSingle
|
|
259
|
-
|
|
260
|
-
type CollectionNode = FlowMap | BlockMap | FlowSeq | BlockSeq
|
|
261
|
-
|
|
262
|
-
class Node {
|
|
263
|
-
/** A comment on or immediately after this */
|
|
264
|
-
comment?: string | null
|
|
265
|
-
/** A comment before this */
|
|
266
|
-
commentBefore?: string | null
|
|
267
|
-
/** Only available when `keepCstNodes` is set to `true` */
|
|
268
|
-
cstNode?: CST.Node
|
|
269
|
-
/**
|
|
270
|
-
* The [start, end] range of characters of the source parsed
|
|
271
|
-
* into this node (undefined for pairs or if not parsed)
|
|
272
|
-
*/
|
|
273
|
-
range?: [number, number] | null
|
|
274
|
-
/** A blank line before this node and its commentBefore */
|
|
275
|
-
spaceBefore?: boolean
|
|
276
|
-
/** A fully qualified tag, if required */
|
|
277
|
-
tag?: string
|
|
278
|
-
/** A plain JS representation of this node */
|
|
279
|
-
toJSON(arg?: any, ctx?: NodeToJsonContext): any
|
|
280
|
-
/** The type of this node */
|
|
281
|
-
type?: Type | Pair.Type
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
class Collection extends Node {
|
|
285
|
-
type?: Type.MAP | Type.FLOW_MAP | Type.SEQ | Type.FLOW_SEQ | Type.DOCUMENT
|
|
286
|
-
items: any[]
|
|
287
|
-
schema?: Schema
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
|
291
|
-
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
292
|
-
* that already exists in the map.
|
|
293
|
-
*/
|
|
294
|
-
add(value: any): void
|
|
295
|
-
addIn(path: Iterable<any>, value: any): void
|
|
296
|
-
/**
|
|
297
|
-
* Removes a value from the collection.
|
|
298
|
-
* @returns `true` if the item was found and removed.
|
|
299
|
-
*/
|
|
300
|
-
delete(key: any): boolean
|
|
301
|
-
deleteIn(path: Iterable<any>): boolean
|
|
302
|
-
/**
|
|
303
|
-
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
304
|
-
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
305
|
-
* `true` (collections are always returned intact).
|
|
306
|
-
*/
|
|
307
|
-
get(key: any, keepScalar?: boolean): any
|
|
308
|
-
getIn(path: Iterable<any>, keepScalar?: boolean): any
|
|
309
|
-
/**
|
|
310
|
-
* Checks if the collection includes a value with the key `key`.
|
|
311
|
-
*/
|
|
312
|
-
has(key: any): boolean
|
|
313
|
-
hasIn(path: Iterable<any>): boolean
|
|
314
|
-
/**
|
|
315
|
-
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
316
|
-
* boolean to add/remove the item from the set.
|
|
317
|
-
*/
|
|
318
|
-
set(key: any, value: any): void
|
|
319
|
-
setIn(path: Iterable<any>, value: any): void
|
|
320
|
-
}
|
|
321
|
-
|
|
322
351
|
interface NodeToJsonContext {
|
|
323
352
|
anchors?: any[]
|
|
324
353
|
doc: Document
|
|
@@ -354,20 +383,6 @@ export namespace AST {
|
|
|
354
383
|
cstNode?: CST.QuoteSingle
|
|
355
384
|
}
|
|
356
385
|
|
|
357
|
-
interface Alias extends Node {
|
|
358
|
-
type: Type.ALIAS
|
|
359
|
-
source: AstNode
|
|
360
|
-
cstNode?: CST.Alias
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
interface Merge extends Pair {
|
|
364
|
-
type: Pair.Type.MERGE_PAIR
|
|
365
|
-
/** Always Scalar('<<'), defined by the type specification */
|
|
366
|
-
key: PlainValue
|
|
367
|
-
/** Always YAMLSeq<Alias(Map)>, stringified as *A if length = 1 */
|
|
368
|
-
value: YAMLSeq
|
|
369
|
-
}
|
|
370
|
-
|
|
371
386
|
interface FlowMap extends YAMLMap {
|
|
372
387
|
type: Type.FLOW_MAP
|
|
373
388
|
cstNode?: CST.FlowMap
|
|
@@ -380,13 +395,13 @@ export namespace AST {
|
|
|
380
395
|
|
|
381
396
|
interface FlowSeq extends YAMLSeq {
|
|
382
397
|
type: Type.FLOW_SEQ
|
|
383
|
-
items: Array<
|
|
398
|
+
items: Array<Node>
|
|
384
399
|
cstNode?: CST.FlowSeq
|
|
385
400
|
}
|
|
386
401
|
|
|
387
402
|
interface BlockSeq extends YAMLSeq {
|
|
388
403
|
type: Type.SEQ
|
|
389
|
-
items: Array<
|
|
404
|
+
items: Array<Node | null>
|
|
390
405
|
cstNode?: CST.Seq
|
|
391
406
|
}
|
|
392
407
|
}
|
package/types.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.binaryOptions = opt.binaryOptions
|
|
3
|
-
exports.boolOptions = opt.boolOptions
|
|
4
|
-
exports.intOptions = opt.intOptions
|
|
5
|
-
exports.nullOptions = opt.nullOptions
|
|
6
|
-
exports.strOptions = opt.strOptions
|
|
1
|
+
const types = require('./dist/types')
|
|
7
2
|
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
3
|
+
exports.binaryOptions = types.binaryOptions
|
|
4
|
+
exports.boolOptions = types.boolOptions
|
|
5
|
+
exports.intOptions = types.intOptions
|
|
6
|
+
exports.nullOptions = types.nullOptions
|
|
7
|
+
exports.strOptions = types.strOptions
|
|
8
|
+
|
|
9
|
+
exports.Schema = types.Schema
|
|
10
|
+
exports.Alias = types.Alias
|
|
11
|
+
exports.Collection = types.Collection
|
|
12
|
+
exports.Merge = types.Merge
|
|
13
|
+
exports.Node = types.Node
|
|
14
|
+
exports.Pair = types.Pair
|
|
15
|
+
exports.Scalar = types.Scalar
|
|
16
|
+
exports.YAMLMap = types.YAMLMap
|
|
17
|
+
exports.YAMLSeq = types.YAMLSeq
|
package/types.mjs
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const binaryOptions = opt.binaryOptions
|
|
3
|
-
export const boolOptions = opt.boolOptions
|
|
4
|
-
export const intOptions = opt.intOptions
|
|
5
|
-
export const nullOptions = opt.nullOptions
|
|
6
|
-
export const strOptions = opt.strOptions
|
|
1
|
+
import types from './dist/types.js'
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
export const
|
|
3
|
+
export const binaryOptions = types.binaryOptions
|
|
4
|
+
export const boolOptions = types.boolOptions
|
|
5
|
+
export const intOptions = types.intOptions
|
|
6
|
+
export const nullOptions = types.nullOptions
|
|
7
|
+
export const strOptions = types.strOptions
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export const
|
|
19
|
-
|
|
20
|
-
import scalar from './dist/schema/Scalar.js'
|
|
21
|
-
export const Scalar = scalar.Scalar
|
|
9
|
+
export const Schema = types.Schema
|
|
10
|
+
export const Alias = types.Alias
|
|
11
|
+
export const Collection = types.Collection
|
|
12
|
+
export const Merge = types.Merge
|
|
13
|
+
export const Node = types.Node
|
|
14
|
+
export const Pair = types.Pair
|
|
15
|
+
export const Scalar = types.Scalar
|
|
16
|
+
export const YAMLMap = types.YAMLMap
|
|
17
|
+
export const YAMLSeq = types.YAMLSeq
|
package/util.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
exports.parseMap = require('./dist/schema/parseMap').parseMap
|
|
3
|
-
exports.parseSeq = require('./dist/schema/parseSeq').parseSeq
|
|
1
|
+
const util = require('./dist/util')
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.Type = require('./dist/constants').Type
|
|
3
|
+
exports.findPair = util.findPair
|
|
4
|
+
exports.toJSON = util.toJSON
|
|
5
|
+
exports.parseMap = util.parseMap
|
|
6
|
+
exports.parseSeq = util.parseSeq
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
8
|
+
exports.stringifyNumber = util.stringifyNumber
|
|
9
|
+
exports.stringifyString = util.stringifyString
|
|
10
|
+
exports.Type = util.Type
|
|
11
|
+
|
|
12
|
+
exports.YAMLError = util.YAMLError
|
|
13
|
+
exports.YAMLReferenceError = util.YAMLReferenceError
|
|
14
|
+
exports.YAMLSemanticError = util.YAMLSemanticError
|
|
15
|
+
exports.YAMLSyntaxError = util.YAMLSyntaxError
|
|
16
|
+
exports.YAMLWarning = util.YAMLWarning
|