yaml 1.8.2 → 1.9.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/browser/dist/Anchors.js +10 -13
- package/browser/dist/Document.js +72 -67
- package/browser/dist/addComment.js +1 -1
- package/browser/dist/cst/Alias.js +12 -8
- package/browser/dist/cst/BlankLine.js +16 -20
- package/browser/dist/cst/BlockValue.js +14 -10
- package/browser/dist/cst/Collection.js +17 -13
- package/browser/dist/cst/CollectionItem.js +15 -11
- package/browser/dist/cst/Comment.js +13 -9
- package/browser/dist/cst/Directive.js +13 -9
- package/browser/dist/cst/Document.js +17 -13
- package/browser/dist/cst/FlowCollection.js +17 -13
- package/browser/dist/cst/Node.js +3 -5
- package/browser/dist/cst/ParseContext.js +12 -14
- package/browser/dist/cst/PlainValue.js +12 -8
- package/browser/dist/cst/QuoteDouble.js +13 -9
- package/browser/dist/cst/QuoteSingle.js +13 -9
- package/browser/dist/cst/Range.js +2 -5
- package/browser/dist/cst/parse.js +3 -3
- package/browser/dist/errors.js +23 -8
- package/browser/dist/foldFlowLines.js +1 -1
- package/browser/dist/index.js +71 -21
- package/browser/dist/listTagNames.js +5 -5
- package/browser/dist/schema/Alias.js +30 -34
- package/browser/dist/schema/Collection.js +40 -47
- package/browser/dist/schema/Map.js +39 -56
- package/browser/dist/schema/Merge.js +37 -46
- package/browser/dist/schema/Node.js +2 -5
- package/browser/dist/schema/Pair.js +36 -13
- package/browser/dist/schema/Scalar.js +13 -9
- package/browser/dist/schema/Seq.js +27 -25
- package/browser/dist/schema/index.js +25 -39
- package/browser/dist/schema/parseMap.js +8 -8
- package/browser/dist/schema/parseSeq.js +5 -5
- package/browser/dist/schema/parseUtils.js +11 -15
- package/browser/dist/stringify.js +2 -1
- package/browser/dist/tags/core.js +39 -23
- package/browser/dist/tags/failsafe/index.js +4 -4
- package/browser/dist/tags/failsafe/map.js +15 -18
- package/browser/dist/tags/failsafe/seq.js +14 -18
- package/browser/dist/tags/failsafe/string.js +1 -1
- package/browser/dist/tags/index.js +10 -10
- package/browser/dist/tags/json.js +27 -26
- package/browser/dist/tags/options.js +3 -0
- package/browser/dist/tags/yaml-1.1/binary.js +10 -8
- package/browser/dist/tags/yaml-1.1/index.js +75 -43
- package/browser/dist/tags/yaml-1.1/omap.js +34 -39
- package/browser/dist/tags/yaml-1.1/pairs.js +17 -20
- package/browser/dist/tags/yaml-1.1/set.js +27 -23
- package/browser/dist/test-events.js +4 -4
- package/browser/dist/toJSON.js +3 -4
- package/browser/dist/warnings.js +29 -18
- package/browser/index.js +1 -1
- package/browser/map.js +4 -2
- package/browser/pair.js +4 -2
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +4 -2
- package/browser/schema.js +11 -6
- package/browser/seq.js +4 -2
- package/browser/types/binary.js +5 -6
- package/browser/types/omap.js +4 -2
- package/browser/types/pairs.js +4 -2
- package/browser/types/set.js +4 -2
- package/browser/types/timestamp.js +5 -9
- package/browser/types.js +12 -10
- package/browser/util.js +16 -13
- package/dist/Anchors.js +13 -18
- package/dist/Document.js +52 -48
- package/dist/addComment.js +1 -4
- package/dist/constants.js +0 -3
- package/dist/cst/Alias.js +8 -13
- package/dist/cst/BlankLine.js +8 -24
- package/dist/cst/BlockValue.js +12 -17
- package/dist/cst/Collection.js +22 -27
- package/dist/cst/CollectionItem.js +16 -21
- package/dist/cst/Comment.js +6 -11
- package/dist/cst/Directive.js +7 -12
- package/dist/cst/Document.js +23 -28
- package/dist/cst/FlowCollection.js +21 -26
- package/dist/cst/Node.js +4 -9
- package/dist/cst/ParseContext.js +38 -43
- package/dist/cst/PlainValue.js +10 -15
- package/dist/cst/QuoteDouble.js +9 -14
- package/dist/cst/QuoteSingle.js +9 -14
- package/dist/cst/Range.js +2 -5
- package/dist/cst/parse.js +5 -10
- package/dist/cst/source-utils.js +0 -3
- package/dist/errors.js +4 -9
- package/dist/foldFlowLines.js +1 -4
- package/dist/index.js +59 -17
- package/dist/listTagNames.js +9 -14
- package/dist/schema/Alias.js +12 -17
- package/dist/schema/Collection.js +16 -20
- package/dist/schema/Map.js +12 -17
- package/dist/schema/Merge.js +13 -18
- package/dist/schema/Node.js +2 -5
- package/dist/schema/Pair.js +44 -31
- package/dist/schema/Scalar.js +6 -11
- package/dist/schema/Seq.js +9 -14
- package/dist/schema/index.js +22 -27
- package/dist/schema/parseMap.js +19 -28
- package/dist/schema/parseSeq.js +10 -15
- package/dist/schema/parseUtils.js +0 -3
- package/dist/stringify.js +6 -12
- package/dist/tags/core.js +34 -26
- package/dist/tags/failsafe/index.js +6 -11
- package/dist/tags/failsafe/map.js +8 -13
- package/dist/tags/failsafe/seq.js +8 -13
- package/dist/tags/failsafe/string.js +3 -6
- package/dist/tags/index.js +20 -29
- package/dist/tags/json.js +26 -22
- package/dist/tags/options.js +5 -4
- package/dist/tags/yaml-1.1/binary.js +11 -11
- package/dist/tags/yaml-1.1/index.js +69 -38
- package/dist/tags/yaml-1.1/omap.js +19 -24
- package/dist/tags/yaml-1.1/pairs.js +12 -17
- package/dist/tags/yaml-1.1/set.js +12 -21
- package/dist/tags/yaml-1.1/timestamp.js +0 -3
- package/dist/test-events.js +4 -9
- package/dist/toJSON.js +3 -5
- package/dist/warnings.js +31 -22
- package/index.d.ts +358 -0
- package/index.js +1 -1
- package/map.js +1 -1
- package/package.json +29 -23
- package/pair.js +1 -1
- package/parse-cst.d.ts +187 -0
- package/parse-cst.js +1 -1
- package/scalar.js +1 -1
- package/schema.js +2 -2
- package/seq.js +1 -1
- package/types/binary.js +1 -1
- package/types/omap.js +1 -1
- package/types/pairs.js +1 -1
- package/types/set.js +1 -1
- package/types/timestamp.js +1 -1
- package/types.d.ts +393 -0
- package/types.js +7 -6
- package/types.mjs +6 -5
- package/util.d.ts +86 -0
- package/util.js +6 -5
- package/util.mjs +4 -3
package/dist/schema/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
3
|
+
exports.Schema = void 0;
|
|
7
4
|
|
|
8
5
|
var _warnings = require("../warnings");
|
|
9
6
|
|
|
@@ -17,17 +14,15 @@ var _tags = require("../tags");
|
|
|
17
14
|
|
|
18
15
|
var _string = require("../tags/failsafe/string");
|
|
19
16
|
|
|
20
|
-
var _Alias =
|
|
17
|
+
var _Alias = require("./Alias");
|
|
21
18
|
|
|
22
|
-
var _Collection =
|
|
19
|
+
var _Collection = require("./Collection");
|
|
23
20
|
|
|
24
|
-
var _Node =
|
|
21
|
+
var _Node = require("./Node");
|
|
25
22
|
|
|
26
|
-
var _Pair =
|
|
23
|
+
var _Pair = require("./Pair");
|
|
27
24
|
|
|
28
|
-
var _Scalar =
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
var _Scalar = require("./Scalar");
|
|
31
26
|
|
|
32
27
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
28
|
|
|
@@ -85,7 +80,7 @@ class Schema {
|
|
|
85
80
|
}
|
|
86
81
|
|
|
87
82
|
createNode(value, wrapScalars, tag, ctx) {
|
|
88
|
-
if (value instanceof _Node.
|
|
83
|
+
if (value instanceof _Node.Node) return value;
|
|
89
84
|
let tagObj;
|
|
90
85
|
|
|
91
86
|
if (tag) {
|
|
@@ -99,7 +94,7 @@ class Schema {
|
|
|
99
94
|
|
|
100
95
|
if (!tagObj) {
|
|
101
96
|
if (typeof value.toJSON === 'function') value = value.toJSON();
|
|
102
|
-
if (typeof value !== 'object') return wrapScalars ? new _Scalar.
|
|
97
|
+
if (typeof value !== 'object') return wrapScalars ? new _Scalar.Scalar(value) : value;
|
|
103
98
|
tagObj = value instanceof Map ? _tags.tags.map : value[Symbol.iterator] ? _tags.tags.seq : _tags.tags.map;
|
|
104
99
|
}
|
|
105
100
|
}
|
|
@@ -119,7 +114,7 @@ class Schema {
|
|
|
119
114
|
const prev = ctx.prevObjects.get(value);
|
|
120
115
|
|
|
121
116
|
if (prev) {
|
|
122
|
-
const alias = new _Alias.
|
|
117
|
+
const alias = new _Alias.Alias(prev); // leaves source dirty; must be cleaned by caller
|
|
123
118
|
|
|
124
119
|
ctx.aliasNodes.push(alias);
|
|
125
120
|
return alias;
|
|
@@ -129,15 +124,15 @@ class Schema {
|
|
|
129
124
|
ctx.prevObjects.set(value, obj);
|
|
130
125
|
}
|
|
131
126
|
|
|
132
|
-
obj.node = tagObj.createNode ? tagObj.createNode(this, value, ctx) : wrapScalars ? new _Scalar.
|
|
133
|
-
if (tag && obj.node instanceof _Node.
|
|
127
|
+
obj.node = tagObj.createNode ? tagObj.createNode(this, value, ctx) : wrapScalars ? new _Scalar.Scalar(value) : value;
|
|
128
|
+
if (tag && obj.node instanceof _Node.Node) obj.node.tag = tag;
|
|
134
129
|
return obj.node;
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
createPair(key, value, ctx) {
|
|
138
133
|
const k = this.createNode(key, ctx.wrapScalars, null, ctx);
|
|
139
134
|
const v = this.createNode(value, ctx.wrapScalars, null, ctx);
|
|
140
|
-
return new _Pair.
|
|
135
|
+
return new _Pair.Pair(k, v);
|
|
141
136
|
} // falls back to string on no match
|
|
142
137
|
|
|
143
138
|
|
|
@@ -156,7 +151,7 @@ class Schema {
|
|
|
156
151
|
|
|
157
152
|
if (match) {
|
|
158
153
|
let res = resolve.apply(null, match);
|
|
159
|
-
if (!(res instanceof _Scalar.
|
|
154
|
+
if (!(res instanceof _Scalar.Scalar)) res = new _Scalar.Scalar(res);
|
|
160
155
|
if (format) res.format = format;
|
|
161
156
|
return res;
|
|
162
157
|
}
|
|
@@ -164,7 +159,7 @@ class Schema {
|
|
|
164
159
|
}
|
|
165
160
|
|
|
166
161
|
if (this.tags.scalarFallback) str = this.tags.scalarFallback(str);
|
|
167
|
-
return new _Scalar.
|
|
162
|
+
return new _Scalar.Scalar(str);
|
|
168
163
|
} // sets node.resolved on success
|
|
169
164
|
|
|
170
165
|
|
|
@@ -180,7 +175,7 @@ class Schema {
|
|
|
180
175
|
try {
|
|
181
176
|
if (generic) {
|
|
182
177
|
let res = generic.resolve(doc, node);
|
|
183
|
-
if (!(res instanceof _Collection.
|
|
178
|
+
if (!(res instanceof _Collection.Collection)) res = new _Scalar.Scalar(res);
|
|
184
179
|
node.resolved = res;
|
|
185
180
|
} else {
|
|
186
181
|
const str = (0, _string.resolveString)(doc, node);
|
|
@@ -219,7 +214,7 @@ class Schema {
|
|
|
219
214
|
}
|
|
220
215
|
|
|
221
216
|
getTagObject(item) {
|
|
222
|
-
if (item instanceof _Alias.
|
|
217
|
+
if (item instanceof _Alias.Alias) return _Alias.Alias;
|
|
223
218
|
|
|
224
219
|
if (item.tag) {
|
|
225
220
|
const match = this.tags.filter(t => t.tag === item.tag);
|
|
@@ -228,7 +223,7 @@ class Schema {
|
|
|
228
223
|
|
|
229
224
|
let tagObj, obj;
|
|
230
225
|
|
|
231
|
-
if (item instanceof _Scalar.
|
|
226
|
+
if (item instanceof _Scalar.Scalar) {
|
|
232
227
|
obj = item.value; // TODO: deprecate/remove class check
|
|
233
228
|
|
|
234
229
|
const match = this.tags.filter(t => t.identify && t.identify(obj) || t.class && obj instanceof t.class);
|
|
@@ -271,7 +266,7 @@ class Schema {
|
|
|
271
266
|
stringify(item, ctx, onComment, onChompKeep) {
|
|
272
267
|
let tagObj;
|
|
273
268
|
|
|
274
|
-
if (!(item instanceof _Node.
|
|
269
|
+
if (!(item instanceof _Node.Node)) {
|
|
275
270
|
const createCtx = {
|
|
276
271
|
aliasNodes: [],
|
|
277
272
|
onTagObj: o => tagObj = o,
|
|
@@ -294,17 +289,17 @@ class Schema {
|
|
|
294
289
|
}
|
|
295
290
|
|
|
296
291
|
ctx.tags = this;
|
|
297
|
-
if (item instanceof _Pair.
|
|
292
|
+
if (item instanceof _Pair.Pair) return item.toString(ctx, onComment, onChompKeep);
|
|
298
293
|
if (!tagObj) tagObj = this.getTagObject(item);
|
|
299
294
|
const props = this.stringifyProps(item, tagObj, ctx);
|
|
300
295
|
if (props.length > 0) ctx.indentAtStart = (ctx.indentAtStart || 0) + props.length + 1;
|
|
301
|
-
const str = typeof tagObj.stringify === 'function' ? tagObj.stringify(item, ctx, onComment, onChompKeep) : item instanceof _Collection.
|
|
302
|
-
return props ? item instanceof _Collection.
|
|
296
|
+
const str = typeof tagObj.stringify === 'function' ? tagObj.stringify(item, ctx, onComment, onChompKeep) : item instanceof _Collection.Collection ? item.toString(ctx, onComment, onChompKeep) : (0, _stringify.stringifyString)(item, ctx, onComment, onChompKeep);
|
|
297
|
+
return props ? item instanceof _Collection.Collection && str[0] !== '{' && str[0] !== '[' ? `${props}\n${ctx.indent}${str}` : `${props} ${str}` : str;
|
|
303
298
|
}
|
|
304
299
|
|
|
305
300
|
}
|
|
306
301
|
|
|
307
|
-
exports.
|
|
302
|
+
exports.Schema = Schema;
|
|
308
303
|
|
|
309
304
|
_defineProperty(Schema, "defaultPrefix", 'tag:yaml.org,2002:');
|
|
310
305
|
|
package/dist/schema/parseMap.js
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = parseMap;
|
|
3
|
+
exports.parseMap = parseMap;
|
|
7
4
|
|
|
8
5
|
var _constants = require("../constants");
|
|
9
6
|
|
|
10
|
-
var _PlainValue =
|
|
7
|
+
var _PlainValue = require("../cst/PlainValue");
|
|
11
8
|
|
|
12
9
|
var _errors = require("../errors");
|
|
13
10
|
|
|
14
|
-
var _Map =
|
|
11
|
+
var _Map = require("./Map");
|
|
15
12
|
|
|
16
|
-
var _Merge =
|
|
13
|
+
var _Merge = require("./Merge");
|
|
17
14
|
|
|
18
|
-
var _Pair =
|
|
15
|
+
var _Pair = require("./Pair");
|
|
19
16
|
|
|
20
17
|
var _parseUtils = require("./parseUtils");
|
|
21
18
|
|
|
22
|
-
var _Alias =
|
|
19
|
+
var _Alias = require("./Alias");
|
|
23
20
|
|
|
24
|
-
var _Collection =
|
|
25
|
-
|
|
26
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
var _Collection = require("./Collection");
|
|
31
22
|
|
|
32
23
|
function parseMap(doc, cst) {
|
|
33
24
|
if (cst.type !== _constants.Type.MAP && cst.type !== _constants.Type.FLOW_MAP) {
|
|
@@ -40,7 +31,7 @@ function parseMap(doc, cst) {
|
|
|
40
31
|
comments,
|
|
41
32
|
items
|
|
42
33
|
} = cst.type === _constants.Type.FLOW_MAP ? resolveFlowMapItems(doc, cst) : resolveBlockMapItems(doc, cst);
|
|
43
|
-
const map = new _Map.
|
|
34
|
+
const map = new _Map.YAMLMap();
|
|
44
35
|
map.items = items;
|
|
45
36
|
(0, _parseUtils.resolveComments)(map, comments);
|
|
46
37
|
let hasCollectionKey = false;
|
|
@@ -49,14 +40,14 @@ function parseMap(doc, cst) {
|
|
|
49
40
|
const {
|
|
50
41
|
key: iKey
|
|
51
42
|
} = items[i];
|
|
52
|
-
if (iKey instanceof _Collection.
|
|
43
|
+
if (iKey instanceof _Collection.Collection) hasCollectionKey = true;
|
|
53
44
|
|
|
54
45
|
if (doc.schema.merge && iKey && iKey.value === _Merge.MERGE_KEY) {
|
|
55
|
-
items[i] = new _Merge.
|
|
46
|
+
items[i] = new _Merge.Merge(items[i]);
|
|
56
47
|
const sources = items[i].value.items;
|
|
57
48
|
let error = null;
|
|
58
49
|
sources.some(node => {
|
|
59
|
-
if (node instanceof _Alias.
|
|
50
|
+
if (node instanceof _Alias.Alias) {
|
|
60
51
|
// During parsing, alias sources are CST nodes; to account for
|
|
61
52
|
// circular references their resolved values can't be used here.
|
|
62
53
|
const {
|
|
@@ -160,7 +151,7 @@ function resolveBlockMapItems(doc, cst) {
|
|
|
160
151
|
break;
|
|
161
152
|
|
|
162
153
|
case _constants.Type.MAP_KEY:
|
|
163
|
-
if (key !== undefined) items.push(new _Pair.
|
|
154
|
+
if (key !== undefined) items.push(new _Pair.Pair(key));
|
|
164
155
|
if (item.error) doc.errors.push(item.error);
|
|
165
156
|
key = doc.resolveNode(item.node);
|
|
166
157
|
keyStart = null;
|
|
@@ -182,7 +173,7 @@ function resolveBlockMapItems(doc, cst) {
|
|
|
182
173
|
// Comments on an empty mapping value need to be preserved, so we
|
|
183
174
|
// need to construct a minimal empty node here to use instead of the
|
|
184
175
|
// missing `item.node`. -- eemeli/yaml#19
|
|
185
|
-
valueNode = new _PlainValue.
|
|
176
|
+
valueNode = new _PlainValue.PlainValue(_constants.Type.PLAIN, []);
|
|
186
177
|
valueNode.context = {
|
|
187
178
|
parent: item,
|
|
188
179
|
src: item.context.src
|
|
@@ -204,7 +195,7 @@ function resolveBlockMapItems(doc, cst) {
|
|
|
204
195
|
}
|
|
205
196
|
}
|
|
206
197
|
|
|
207
|
-
const pair = new _Pair.
|
|
198
|
+
const pair = new _Pair.Pair(key, doc.resolveNode(valueNode));
|
|
208
199
|
resolvePairComment(item, pair);
|
|
209
200
|
items.push(pair);
|
|
210
201
|
(0, _parseUtils.checkKeyLength)(doc.errors, cst, i, key, keyStart);
|
|
@@ -214,7 +205,7 @@ function resolveBlockMapItems(doc, cst) {
|
|
|
214
205
|
break;
|
|
215
206
|
|
|
216
207
|
default:
|
|
217
|
-
if (key !== undefined) items.push(new _Pair.
|
|
208
|
+
if (key !== undefined) items.push(new _Pair.Pair(key));
|
|
218
209
|
key = doc.resolveNode(item);
|
|
219
210
|
keyStart = item.range.start;
|
|
220
211
|
if (item.error) doc.errors.push(item.error);
|
|
@@ -244,7 +235,7 @@ function resolveBlockMapItems(doc, cst) {
|
|
|
244
235
|
}
|
|
245
236
|
}
|
|
246
237
|
|
|
247
|
-
if (key !== undefined) items.push(new _Pair.
|
|
238
|
+
if (key !== undefined) items.push(new _Pair.Pair(key));
|
|
248
239
|
return {
|
|
249
240
|
comments,
|
|
250
241
|
items
|
|
@@ -289,7 +280,7 @@ function resolveFlowMapItems(doc, cst) {
|
|
|
289
280
|
}
|
|
290
281
|
|
|
291
282
|
if (key !== undefined) {
|
|
292
|
-
items.push(new _Pair.
|
|
283
|
+
items.push(new _Pair.Pair(key));
|
|
293
284
|
key = undefined;
|
|
294
285
|
keyStart = null;
|
|
295
286
|
|
|
@@ -328,14 +319,14 @@ function resolveFlowMapItems(doc, cst) {
|
|
|
328
319
|
keyStart = explicitKey ? null : item.range.start; // TODO: add error for non-explicit multiline plain key
|
|
329
320
|
} else {
|
|
330
321
|
if (next !== ',') doc.errors.push(new _errors.YAMLSemanticError(item, 'Indicator : missing in flow map entry'));
|
|
331
|
-
items.push(new _Pair.
|
|
322
|
+
items.push(new _Pair.Pair(key, doc.resolveNode(item)));
|
|
332
323
|
key = undefined;
|
|
333
324
|
explicitKey = false;
|
|
334
325
|
}
|
|
335
326
|
}
|
|
336
327
|
|
|
337
328
|
(0, _parseUtils.checkFlowCollectionEnd)(doc.errors, cst);
|
|
338
|
-
if (key !== undefined) items.push(new _Pair.
|
|
329
|
+
if (key !== undefined) items.push(new _Pair.Pair(key));
|
|
339
330
|
return {
|
|
340
331
|
comments,
|
|
341
332
|
items
|
package/dist/schema/parseSeq.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = parseSeq;
|
|
3
|
+
exports.parseSeq = parseSeq;
|
|
7
4
|
|
|
8
5
|
var _constants = require("../constants");
|
|
9
6
|
|
|
10
7
|
var _errors = require("../errors");
|
|
11
8
|
|
|
12
|
-
var _Pair =
|
|
9
|
+
var _Pair = require("./Pair");
|
|
13
10
|
|
|
14
11
|
var _parseUtils = require("./parseUtils");
|
|
15
12
|
|
|
16
|
-
var _Seq =
|
|
13
|
+
var _Seq = require("./Seq");
|
|
17
14
|
|
|
18
|
-
var _Collection =
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
var _Collection = require("./Collection");
|
|
21
16
|
|
|
22
17
|
function parseSeq(doc, cst) {
|
|
23
18
|
if (cst.type !== _constants.Type.SEQ && cst.type !== _constants.Type.FLOW_SEQ) {
|
|
@@ -30,11 +25,11 @@ function parseSeq(doc, cst) {
|
|
|
30
25
|
comments,
|
|
31
26
|
items
|
|
32
27
|
} = cst.type === _constants.Type.FLOW_SEQ ? resolveFlowSeqItems(doc, cst) : resolveBlockSeqItems(doc, cst);
|
|
33
|
-
const seq = new _Seq.
|
|
28
|
+
const seq = new _Seq.YAMLSeq();
|
|
34
29
|
seq.items = items;
|
|
35
30
|
(0, _parseUtils.resolveComments)(seq, comments);
|
|
36
31
|
|
|
37
|
-
if (!doc.options.mapAsMap && items.some(it => it instanceof _Pair.
|
|
32
|
+
if (!doc.options.mapAsMap && items.some(it => it instanceof _Pair.Pair && it.key instanceof _Collection.Collection)) {
|
|
38
33
|
const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.';
|
|
39
34
|
doc.warnings.push(new _errors.YAMLWarning(cst, warn));
|
|
40
35
|
}
|
|
@@ -106,7 +101,7 @@ function resolveFlowSeqItems(doc, cst) {
|
|
|
106
101
|
|
|
107
102
|
if (char !== ':' && (explicitKey || key !== undefined)) {
|
|
108
103
|
if (explicitKey && key === undefined) key = next ? items.pop() : null;
|
|
109
|
-
items.push(new _Pair.
|
|
104
|
+
items.push(new _Pair.Pair(key));
|
|
110
105
|
explicitKey = false;
|
|
111
106
|
key = undefined;
|
|
112
107
|
keyStart = null;
|
|
@@ -120,7 +115,7 @@ function resolveFlowSeqItems(doc, cst) {
|
|
|
120
115
|
if (next === ',') {
|
|
121
116
|
key = items.pop();
|
|
122
117
|
|
|
123
|
-
if (key instanceof _Pair.
|
|
118
|
+
if (key instanceof _Pair.Pair) {
|
|
124
119
|
const msg = 'Chaining flow sequence pairs is invalid';
|
|
125
120
|
const err = new _errors.YAMLSemanticError(cst, msg);
|
|
126
121
|
err.offset = offset;
|
|
@@ -162,7 +157,7 @@ function resolveFlowSeqItems(doc, cst) {
|
|
|
162
157
|
if (key === undefined) {
|
|
163
158
|
items.push(value);
|
|
164
159
|
} else {
|
|
165
|
-
items.push(new _Pair.
|
|
160
|
+
items.push(new _Pair.Pair(key, value));
|
|
166
161
|
key = undefined;
|
|
167
162
|
}
|
|
168
163
|
|
|
@@ -172,7 +167,7 @@ function resolveFlowSeqItems(doc, cst) {
|
|
|
172
167
|
}
|
|
173
168
|
|
|
174
169
|
(0, _parseUtils.checkFlowCollectionEnd)(doc.errors, cst);
|
|
175
|
-
if (key !== undefined) items.push(new _Pair.
|
|
170
|
+
if (key !== undefined) items.push(new _Pair.Pair(key));
|
|
176
171
|
return {
|
|
177
172
|
comments,
|
|
178
173
|
items
|
package/dist/stringify.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
3
|
exports.stringifyNumber = stringifyNumber;
|
|
7
4
|
exports.stringifyString = stringifyString;
|
|
8
5
|
|
|
@@ -10,14 +7,10 @@ var _addComment = require("./addComment");
|
|
|
10
7
|
|
|
11
8
|
var _constants = require("./constants");
|
|
12
9
|
|
|
13
|
-
var _foldFlowLines =
|
|
10
|
+
var _foldFlowLines = require("./foldFlowLines");
|
|
14
11
|
|
|
15
12
|
var _options = require("./tags/options");
|
|
16
13
|
|
|
17
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
18
|
-
|
|
19
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
|
-
|
|
21
14
|
const getFoldOptions = ({
|
|
22
15
|
indentAtStart
|
|
23
16
|
}) => indentAtStart ? Object.assign({
|
|
@@ -30,6 +23,7 @@ function stringifyNumber({
|
|
|
30
23
|
tag,
|
|
31
24
|
value
|
|
32
25
|
}) {
|
|
26
|
+
if (typeof value === 'bigint') return String(value);
|
|
33
27
|
if (!isFinite(value)) return isNaN(value) ? '.nan' : value < 0 ? '-.inf' : '.inf';
|
|
34
28
|
let n = JSON.stringify(value);
|
|
35
29
|
|
|
@@ -162,7 +156,7 @@ function doubleQuotedString(value, ctx) {
|
|
|
162
156
|
}
|
|
163
157
|
|
|
164
158
|
str = start ? str + json.slice(start) : json;
|
|
165
|
-
return implicitKey ? str : (0, _foldFlowLines.
|
|
159
|
+
return implicitKey ? str : (0, _foldFlowLines.foldFlowLines)(str, indent, _foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx));
|
|
166
160
|
}
|
|
167
161
|
|
|
168
162
|
function singleQuotedString(value, ctx) {
|
|
@@ -179,7 +173,7 @@ function singleQuotedString(value, ctx) {
|
|
|
179
173
|
}
|
|
180
174
|
|
|
181
175
|
const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
|
|
182
|
-
return implicitKey ? res : (0, _foldFlowLines.
|
|
176
|
+
return implicitKey ? res : (0, _foldFlowLines.foldFlowLines)(res, indent, _foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
|
|
183
177
|
}
|
|
184
178
|
|
|
185
179
|
function blockString({
|
|
@@ -244,7 +238,7 @@ function blockString({
|
|
|
244
238
|
value = value.replace(/\n+/g, '\n$&').replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
245
239
|
// ^ ind.line ^ empty ^ capture next empty lines only at end of indent
|
|
246
240
|
.replace(/\n+/g, `$&${indent}`);
|
|
247
|
-
const body = (0, _foldFlowLines.
|
|
241
|
+
const body = (0, _foldFlowLines.foldFlowLines)(`${wsStart}${value}${wsEnd}`, indent, _foldFlowLines.FOLD_BLOCK, _options.strOptions.fold);
|
|
248
242
|
return `${header}\n${indent}${body}`;
|
|
249
243
|
}
|
|
250
244
|
|
|
@@ -289,7 +283,7 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
289
283
|
return doubleQuotedString(value, ctx);
|
|
290
284
|
}
|
|
291
285
|
|
|
292
|
-
const body = implicitKey ? str : (0, _foldFlowLines.
|
|
286
|
+
const body = implicitKey ? str : (0, _foldFlowLines.foldFlowLines)(str, indent, _foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
|
|
293
287
|
|
|
294
288
|
if (comment && !inFlow && (body.indexOf('\n') !== -1 || comment.indexOf('\n') !== -1)) {
|
|
295
289
|
if (onComment) onComment();
|
package/dist/tags/core.js
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.floatObj = exports.expObj = exports.nanObj = exports.hexObj = exports.intObj = exports.octObj = exports.boolObj = exports.nullObj = void 0;
|
|
3
|
+
exports.core = exports.floatObj = exports.expObj = exports.nanObj = exports.hexObj = exports.intObj = exports.octObj = exports.boolObj = exports.nullObj = void 0;
|
|
7
4
|
|
|
8
|
-
var _Scalar =
|
|
5
|
+
var _Scalar = require("../schema/Scalar");
|
|
9
6
|
|
|
10
7
|
var _stringify = require("../stringify");
|
|
11
8
|
|
|
12
|
-
var _failsafe =
|
|
9
|
+
var _failsafe = require("./failsafe");
|
|
13
10
|
|
|
14
11
|
var _options = require("./options");
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
/* global BigInt */
|
|
14
|
+
const intIdentify = value => typeof value === 'bigint' || Number.isInteger(value);
|
|
15
|
+
|
|
16
|
+
const intResolve = (src, part, radix) => _options.intOptions.asBigInt ? BigInt(src) : parseInt(part, radix);
|
|
17
|
+
|
|
18
|
+
function intStringify(node, radix, prefix) {
|
|
19
|
+
const {
|
|
20
|
+
value
|
|
21
|
+
} = node;
|
|
22
|
+
if (intIdentify(value) && value >= 0) return prefix + value.toString(radix);
|
|
23
|
+
return (0, _stringify.stringifyNumber)(node);
|
|
24
|
+
}
|
|
17
25
|
|
|
18
26
|
const nullObj = {
|
|
19
27
|
identify: value => value == null,
|
|
20
|
-
createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.
|
|
28
|
+
createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.Scalar(null) : null,
|
|
21
29
|
default: true,
|
|
22
30
|
tag: 'tag:yaml.org,2002:null',
|
|
23
31
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
@@ -39,36 +47,35 @@ const boolObj = {
|
|
|
39
47
|
};
|
|
40
48
|
exports.boolObj = boolObj;
|
|
41
49
|
const octObj = {
|
|
42
|
-
identify: value =>
|
|
50
|
+
identify: value => intIdentify(value) && value >= 0,
|
|
43
51
|
default: true,
|
|
44
52
|
tag: 'tag:yaml.org,2002:int',
|
|
45
53
|
format: 'OCT',
|
|
46
54
|
test: /^0o([0-7]+)$/,
|
|
47
|
-
resolve: (str, oct) =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}) => '0o' + value.toString(8)
|
|
55
|
+
resolve: (str, oct) => intResolve(str, oct, 8),
|
|
56
|
+
options: _options.intOptions,
|
|
57
|
+
stringify: node => intStringify(node, 8, '0o')
|
|
51
58
|
};
|
|
52
59
|
exports.octObj = octObj;
|
|
53
60
|
const intObj = {
|
|
54
|
-
identify:
|
|
61
|
+
identify: intIdentify,
|
|
55
62
|
default: true,
|
|
56
63
|
tag: 'tag:yaml.org,2002:int',
|
|
57
64
|
test: /^[-+]?[0-9]+$/,
|
|
58
|
-
resolve: str =>
|
|
65
|
+
resolve: str => intResolve(str, str, 10),
|
|
66
|
+
options: _options.intOptions,
|
|
59
67
|
stringify: _stringify.stringifyNumber
|
|
60
68
|
};
|
|
61
69
|
exports.intObj = intObj;
|
|
62
70
|
const hexObj = {
|
|
63
|
-
identify: value =>
|
|
71
|
+
identify: value => intIdentify(value) && value >= 0,
|
|
64
72
|
default: true,
|
|
65
73
|
tag: 'tag:yaml.org,2002:int',
|
|
66
74
|
format: 'HEX',
|
|
67
75
|
test: /^0x([0-9a-fA-F]+)$/,
|
|
68
|
-
resolve: (str, hex) =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}) => '0x' + value.toString(16)
|
|
76
|
+
resolve: (str, hex) => intResolve(str, hex, 16),
|
|
77
|
+
options: _options.intOptions,
|
|
78
|
+
stringify: node => intStringify(node, 16, '0x')
|
|
72
79
|
};
|
|
73
80
|
exports.hexObj = hexObj;
|
|
74
81
|
const nanObj = {
|
|
@@ -85,7 +92,7 @@ const expObj = {
|
|
|
85
92
|
default: true,
|
|
86
93
|
tag: 'tag:yaml.org,2002:float',
|
|
87
94
|
format: 'EXP',
|
|
88
|
-
test: /^[-+]?(
|
|
95
|
+
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
89
96
|
resolve: str => parseFloat(str),
|
|
90
97
|
stringify: ({
|
|
91
98
|
value
|
|
@@ -96,10 +103,11 @@ const floatObj = {
|
|
|
96
103
|
identify: value => typeof value === 'number',
|
|
97
104
|
default: true,
|
|
98
105
|
tag: 'tag:yaml.org,2002:float',
|
|
99
|
-
test: /^[-+]?(
|
|
106
|
+
test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
|
|
100
107
|
|
|
101
|
-
resolve(str,
|
|
102
|
-
const
|
|
108
|
+
resolve(str, frac1, frac2) {
|
|
109
|
+
const frac = frac1 || frac2;
|
|
110
|
+
const node = new _Scalar.Scalar(parseFloat(str));
|
|
103
111
|
if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
|
|
104
112
|
return node;
|
|
105
113
|
},
|
|
@@ -108,6 +116,6 @@ const floatObj = {
|
|
|
108
116
|
};
|
|
109
117
|
exports.floatObj = floatObj;
|
|
110
118
|
|
|
111
|
-
|
|
119
|
+
const core = _failsafe.failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);
|
|
112
120
|
|
|
113
|
-
exports.
|
|
121
|
+
exports.core = core;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
3
|
+
exports.failsafe = void 0;
|
|
7
4
|
|
|
8
|
-
var _map =
|
|
5
|
+
var _map = require("./map");
|
|
9
6
|
|
|
10
|
-
var _seq =
|
|
7
|
+
var _seq = require("./seq");
|
|
11
8
|
|
|
12
|
-
var _string =
|
|
9
|
+
var _string = require("./string");
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _default = [_map.default, _seq.default, _string.default];
|
|
17
|
-
exports.default = _default;
|
|
11
|
+
const failsafe = [_map.map, _seq.seq, _string.string];
|
|
12
|
+
exports.failsafe = failsafe;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
3
|
+
exports.map = void 0;
|
|
7
4
|
|
|
8
|
-
var _Map =
|
|
5
|
+
var _Map = require("../../schema/Map");
|
|
9
6
|
|
|
10
|
-
var _parseMap =
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
var _parseMap = require("../../schema/parseMap");
|
|
13
8
|
|
|
14
9
|
function createMap(schema, obj, ctx) {
|
|
15
|
-
const map = new _Map.
|
|
10
|
+
const map = new _Map.YAMLMap(schema);
|
|
16
11
|
|
|
17
12
|
if (obj instanceof Map) {
|
|
18
13
|
for (const [key, value] of obj) map.items.push(schema.createPair(key, value, ctx));
|
|
@@ -27,11 +22,11 @@ function createMap(schema, obj, ctx) {
|
|
|
27
22
|
return map;
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
const map = {
|
|
31
26
|
createNode: createMap,
|
|
32
27
|
default: true,
|
|
33
|
-
nodeClass: _Map.
|
|
28
|
+
nodeClass: _Map.YAMLMap,
|
|
34
29
|
tag: 'tag:yaml.org,2002:map',
|
|
35
|
-
resolve: _parseMap.
|
|
30
|
+
resolve: _parseMap.parseMap
|
|
36
31
|
};
|
|
37
|
-
exports.
|
|
32
|
+
exports.map = map;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
3
|
+
exports.seq = void 0;
|
|
7
4
|
|
|
8
|
-
var _parseSeq =
|
|
5
|
+
var _parseSeq = require("../../schema/parseSeq");
|
|
9
6
|
|
|
10
|
-
var _Seq =
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
var _Seq = require("../../schema/Seq");
|
|
13
8
|
|
|
14
9
|
function createSeq(schema, obj, ctx) {
|
|
15
|
-
const seq = new _Seq.
|
|
10
|
+
const seq = new _Seq.YAMLSeq(schema);
|
|
16
11
|
|
|
17
12
|
if (obj && obj[Symbol.iterator]) {
|
|
18
13
|
for (const it of obj) {
|
|
@@ -24,11 +19,11 @@ function createSeq(schema, obj, ctx) {
|
|
|
24
19
|
return seq;
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
const seq = {
|
|
28
23
|
createNode: createSeq,
|
|
29
24
|
default: true,
|
|
30
|
-
nodeClass: _Seq.
|
|
25
|
+
nodeClass: _Seq.YAMLSeq,
|
|
31
26
|
tag: 'tag:yaml.org,2002:seq',
|
|
32
|
-
resolve: _parseSeq.
|
|
27
|
+
resolve: _parseSeq.parseSeq
|
|
33
28
|
};
|
|
34
|
-
exports.
|
|
29
|
+
exports.seq = seq;
|