yaml 1.10.0 → 2.0.0-1
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 +10 -11
- package/browser/dist/Schema-ea978338.js +1211 -0
- package/browser/dist/{PlainValue-ff5147c6.js → errors-2634d01a.js} +8 -186
- package/browser/dist/index.js +1174 -121
- package/browser/dist/parse-cst.js +2 -1904
- package/browser/dist/parse-d1ba890f.js +2084 -0
- package/browser/dist/{resolveSeq-04825f30.js → stringifyNumber-d8af95b1.js} +197 -1072
- package/browser/dist/types.js +3 -4
- package/browser/dist/util.js +2 -2
- package/browser/index.js +1 -1
- package/dist/Document-f89a2614.js +1783 -0
- package/dist/Schema-807430ba.js +934 -0
- package/dist/{PlainValue-ec8e588e.js → _rollupPluginBabelHelpers-eed30217.js} +0 -167
- package/dist/index.js +58 -44
- package/dist/parse-3997f544.js +1915 -0
- package/dist/parse-cst.js +3 -1742
- package/dist/stringifyNumber-dea1120c.js +1286 -0
- package/dist/test-events.js +6 -7
- package/dist/types.js +16 -17
- package/dist/util.js +12 -14
- package/index.d.ts +103 -20
- package/index.js +1 -1
- package/package.json +16 -26
- package/types.d.ts +19 -47
- package/util.d.ts +2 -12
- package/util.js +0 -2
- package/util.mjs +0 -3
- package/browser/dist/Schema-2bf2c74e.js +0 -679
- package/browser/dist/legacy-exports.js +0 -3
- package/browser/dist/warnings-0e4b70d3.js +0 -499
- package/browser/map.js +0 -2
- package/browser/pair.js +0 -2
- package/browser/scalar.js +0 -2
- package/browser/schema.js +0 -9
- package/browser/seq.js +0 -2
- package/browser/types/binary.js +0 -8
- package/browser/types/omap.js +0 -3
- package/browser/types/pairs.js +0 -3
- package/browser/types/set.js +0 -3
- package/browser/types/timestamp.js +0 -10
- package/dist/Document-2cf6b08c.js +0 -757
- package/dist/Schema-42e9705c.js +0 -522
- package/dist/legacy-exports.js +0 -16
- package/dist/resolveSeq-4a68b39b.js +0 -2115
- package/dist/warnings-39684f17.js +0 -416
- package/map.js +0 -2
- package/pair.js +0 -2
- package/scalar.js +0 -2
- package/schema.js +0 -9
- package/seq.js +0 -2
- package/types/binary.js +0 -8
- package/types/omap.js +0 -3
- package/types/pairs.js +0 -3
- package/types/set.js +0 -3
- package/types/timestamp.js +0 -10
|
@@ -0,0 +1,1211 @@
|
|
|
1
|
+
import { l as _inherits, m as _createSuper, b as _classCallCheck, r as _possibleConstructorReturn, a as _createClass, h as _createForOfIteratorHelper, e as _slicedToArray, n as _get, o as _getPrototypeOf, _ as _typeof, T as Type, c as _defineProperty, p as _assertThisInitialized } from './errors-2634d01a.js';
|
|
2
|
+
import { P as Pair, Y as YAMLSeq, S as Scalar, d as YAMLMap, j as createPair, e as createNode, c as stringifyString, s as strOptions, n as nullOptions, a as boolOptions, i as intOptions, k as stringifyNumber, b as binaryOptions, t as toJS, l as findPair } from './stringifyNumber-d8af95b1.js';
|
|
3
|
+
|
|
4
|
+
var MERGE_KEY = '<<';
|
|
5
|
+
var Merge = /*#__PURE__*/function (_Pair) {
|
|
6
|
+
_inherits(Merge, _Pair);
|
|
7
|
+
|
|
8
|
+
var _super = _createSuper(Merge);
|
|
9
|
+
|
|
10
|
+
function Merge(pair) {
|
|
11
|
+
var _this;
|
|
12
|
+
|
|
13
|
+
_classCallCheck(this, Merge);
|
|
14
|
+
|
|
15
|
+
if (pair instanceof Pair) {
|
|
16
|
+
var seq = pair.value;
|
|
17
|
+
|
|
18
|
+
if (!(seq instanceof YAMLSeq)) {
|
|
19
|
+
seq = new YAMLSeq();
|
|
20
|
+
seq.items.push(pair.value);
|
|
21
|
+
seq.range = pair.value.range;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_this = _super.call(this, pair.key, seq);
|
|
25
|
+
_this.range = pair.range;
|
|
26
|
+
} else {
|
|
27
|
+
_this = _super.call(this, new Scalar(MERGE_KEY), new YAMLSeq());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_this.type = Pair.Type.MERGE_PAIR;
|
|
31
|
+
return _possibleConstructorReturn(_this);
|
|
32
|
+
} // If the value associated with a merge key is a single mapping node, each of
|
|
33
|
+
// its key/value pairs is inserted into the current mapping, unless the key
|
|
34
|
+
// already exists in it. If the value associated with the merge key is a
|
|
35
|
+
// sequence, then this sequence is expected to contain mapping nodes and each
|
|
36
|
+
// of these nodes is merged in turn according to its order in the sequence.
|
|
37
|
+
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
38
|
+
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
_createClass(Merge, [{
|
|
42
|
+
key: "addToJSMap",
|
|
43
|
+
value: function addToJSMap(ctx, map) {
|
|
44
|
+
var _iterator = _createForOfIteratorHelper(this.value.items),
|
|
45
|
+
_step;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
49
|
+
var source = _step.value.source;
|
|
50
|
+
if (!(source instanceof YAMLMap)) throw new Error('Merge sources must be maps');
|
|
51
|
+
var srcMap = source.toJSON(null, ctx, Map);
|
|
52
|
+
|
|
53
|
+
var _iterator2 = _createForOfIteratorHelper(srcMap),
|
|
54
|
+
_step2;
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
58
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
59
|
+
key = _step2$value[0],
|
|
60
|
+
value = _step2$value[1];
|
|
61
|
+
|
|
62
|
+
if (map instanceof Map) {
|
|
63
|
+
if (!map.has(key)) map.set(key, value);
|
|
64
|
+
} else if (map instanceof Set) {
|
|
65
|
+
map.add(key);
|
|
66
|
+
} else if (!Object.prototype.hasOwnProperty.call(map, key)) {
|
|
67
|
+
Object.defineProperty(map, key, {
|
|
68
|
+
value: value,
|
|
69
|
+
writable: true,
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch (err) {
|
|
76
|
+
_iterator2.e(err);
|
|
77
|
+
} finally {
|
|
78
|
+
_iterator2.f();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (err) {
|
|
82
|
+
_iterator.e(err);
|
|
83
|
+
} finally {
|
|
84
|
+
_iterator.f();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return map;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "toString",
|
|
91
|
+
value: function toString(ctx, onComment) {
|
|
92
|
+
var seq = this.value;
|
|
93
|
+
if (seq.items.length > 1) return _get(_getPrototypeOf(Merge.prototype), "toString", this).call(this, ctx, onComment);
|
|
94
|
+
this.value = seq.items[0];
|
|
95
|
+
|
|
96
|
+
var str = _get(_getPrototypeOf(Merge.prototype), "toString", this).call(this, ctx, onComment);
|
|
97
|
+
|
|
98
|
+
this.value = seq;
|
|
99
|
+
return str;
|
|
100
|
+
}
|
|
101
|
+
}]);
|
|
102
|
+
|
|
103
|
+
return Merge;
|
|
104
|
+
}(Pair);
|
|
105
|
+
|
|
106
|
+
function createMap(schema, obj, ctx) {
|
|
107
|
+
var keepUndefined = ctx.keepUndefined,
|
|
108
|
+
replacer = ctx.replacer;
|
|
109
|
+
var map = new YAMLMap(schema);
|
|
110
|
+
|
|
111
|
+
var add = function add(key, value) {
|
|
112
|
+
if (typeof replacer === 'function') value = replacer.call(obj, key, value);else if (Array.isArray(replacer) && !replacer.includes(key)) return;
|
|
113
|
+
if (value !== undefined || keepUndefined) map.items.push(createPair(key, value, ctx));
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (obj instanceof Map) {
|
|
117
|
+
var _iterator = _createForOfIteratorHelper(obj),
|
|
118
|
+
_step;
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
122
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
123
|
+
key = _step$value[0],
|
|
124
|
+
value = _step$value[1];
|
|
125
|
+
|
|
126
|
+
add(key, value);
|
|
127
|
+
}
|
|
128
|
+
} catch (err) {
|
|
129
|
+
_iterator.e(err);
|
|
130
|
+
} finally {
|
|
131
|
+
_iterator.f();
|
|
132
|
+
}
|
|
133
|
+
} else if (obj && _typeof(obj) === 'object') {
|
|
134
|
+
for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
|
|
135
|
+
var _key = _Object$keys[_i];
|
|
136
|
+
add(_key, obj[_key]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (typeof schema.sortMapEntries === 'function') {
|
|
141
|
+
map.items.sort(schema.sortMapEntries);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return map;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var map = {
|
|
148
|
+
createNode: createMap,
|
|
149
|
+
default: true,
|
|
150
|
+
nodeClass: YAMLMap,
|
|
151
|
+
tag: 'tag:yaml.org,2002:map',
|
|
152
|
+
resolve: function resolve(map) {
|
|
153
|
+
return map;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
function createSeq(schema, obj, ctx) {
|
|
158
|
+
var replacer = ctx.replacer;
|
|
159
|
+
var seq = new YAMLSeq(schema);
|
|
160
|
+
|
|
161
|
+
if (obj && obj[Symbol.iterator]) {
|
|
162
|
+
var i = 0;
|
|
163
|
+
|
|
164
|
+
var _iterator = _createForOfIteratorHelper(obj),
|
|
165
|
+
_step;
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
169
|
+
var it = _step.value;
|
|
170
|
+
|
|
171
|
+
if (typeof replacer === 'function') {
|
|
172
|
+
var key = obj instanceof Set ? it : String(i++);
|
|
173
|
+
it = replacer.call(obj, key, it);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
seq.items.push(createNode(it, null, ctx));
|
|
177
|
+
}
|
|
178
|
+
} catch (err) {
|
|
179
|
+
_iterator.e(err);
|
|
180
|
+
} finally {
|
|
181
|
+
_iterator.f();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return seq;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
var seq = {
|
|
189
|
+
createNode: createSeq,
|
|
190
|
+
default: true,
|
|
191
|
+
nodeClass: YAMLSeq,
|
|
192
|
+
tag: 'tag:yaml.org,2002:seq',
|
|
193
|
+
resolve: function resolve(seq) {
|
|
194
|
+
return seq;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
var string = {
|
|
199
|
+
identify: function identify(value) {
|
|
200
|
+
return typeof value === 'string';
|
|
201
|
+
},
|
|
202
|
+
default: true,
|
|
203
|
+
tag: 'tag:yaml.org,2002:str',
|
|
204
|
+
resolve: function resolve(str) {
|
|
205
|
+
return str;
|
|
206
|
+
},
|
|
207
|
+
stringify: function stringify(item, ctx, onComment, onChompKeep) {
|
|
208
|
+
ctx = Object.assign({
|
|
209
|
+
actualString: true
|
|
210
|
+
}, ctx);
|
|
211
|
+
return stringifyString(item, ctx, onComment, onChompKeep);
|
|
212
|
+
},
|
|
213
|
+
options: strOptions
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
var failsafe = [map, seq, string];
|
|
217
|
+
|
|
218
|
+
/* global BigInt */
|
|
219
|
+
|
|
220
|
+
var intIdentify = function intIdentify(value) {
|
|
221
|
+
return typeof value === 'bigint' || Number.isInteger(value);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
var intResolve = function intResolve(src, offset, radix) {
|
|
225
|
+
return intOptions.asBigInt ? BigInt(src) : parseInt(src.substring(offset), radix);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
function intStringify(node, radix, prefix) {
|
|
229
|
+
var value = node.value;
|
|
230
|
+
if (intIdentify(value) && value >= 0) return prefix + value.toString(radix);
|
|
231
|
+
return stringifyNumber(node);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var nullObj = {
|
|
235
|
+
identify: function identify(value) {
|
|
236
|
+
return value == null;
|
|
237
|
+
},
|
|
238
|
+
createNode: function createNode(schema, value, ctx) {
|
|
239
|
+
return ctx.wrapScalars ? new Scalar(null) : null;
|
|
240
|
+
},
|
|
241
|
+
default: true,
|
|
242
|
+
tag: 'tag:yaml.org,2002:null',
|
|
243
|
+
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
244
|
+
resolve: function resolve(str) {
|
|
245
|
+
var node = new Scalar(null);
|
|
246
|
+
node.sourceStr = str;
|
|
247
|
+
return node;
|
|
248
|
+
},
|
|
249
|
+
options: nullOptions,
|
|
250
|
+
stringify: function stringify(_ref) {
|
|
251
|
+
var sourceStr = _ref.sourceStr;
|
|
252
|
+
return sourceStr !== null && sourceStr !== void 0 ? sourceStr : nullOptions.nullStr;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
var boolObj = {
|
|
256
|
+
identify: function identify(value) {
|
|
257
|
+
return typeof value === 'boolean';
|
|
258
|
+
},
|
|
259
|
+
default: true,
|
|
260
|
+
tag: 'tag:yaml.org,2002:bool',
|
|
261
|
+
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
262
|
+
resolve: function resolve(str) {
|
|
263
|
+
return str[0] === 't' || str[0] === 'T';
|
|
264
|
+
},
|
|
265
|
+
options: boolOptions,
|
|
266
|
+
stringify: function stringify(_ref2) {
|
|
267
|
+
var value = _ref2.value;
|
|
268
|
+
return value ? boolOptions.trueStr : boolOptions.falseStr;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
var octObj = {
|
|
272
|
+
identify: function identify(value) {
|
|
273
|
+
return intIdentify(value) && value >= 0;
|
|
274
|
+
},
|
|
275
|
+
default: true,
|
|
276
|
+
tag: 'tag:yaml.org,2002:int',
|
|
277
|
+
format: 'OCT',
|
|
278
|
+
test: /^0o[0-7]+$/,
|
|
279
|
+
resolve: function resolve(str) {
|
|
280
|
+
return intResolve(str, 2, 8);
|
|
281
|
+
},
|
|
282
|
+
options: intOptions,
|
|
283
|
+
stringify: function stringify(node) {
|
|
284
|
+
return intStringify(node, 8, '0o');
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var intObj = {
|
|
288
|
+
identify: intIdentify,
|
|
289
|
+
default: true,
|
|
290
|
+
tag: 'tag:yaml.org,2002:int',
|
|
291
|
+
test: /^[-+]?[0-9]+$/,
|
|
292
|
+
resolve: function resolve(str) {
|
|
293
|
+
return intResolve(str, 0, 10);
|
|
294
|
+
},
|
|
295
|
+
options: intOptions,
|
|
296
|
+
stringify: stringifyNumber
|
|
297
|
+
};
|
|
298
|
+
var hexObj = {
|
|
299
|
+
identify: function identify(value) {
|
|
300
|
+
return intIdentify(value) && value >= 0;
|
|
301
|
+
},
|
|
302
|
+
default: true,
|
|
303
|
+
tag: 'tag:yaml.org,2002:int',
|
|
304
|
+
format: 'HEX',
|
|
305
|
+
test: /^0x[0-9a-fA-F]+$/,
|
|
306
|
+
resolve: function resolve(str) {
|
|
307
|
+
return intResolve(str, 2, 16);
|
|
308
|
+
},
|
|
309
|
+
options: intOptions,
|
|
310
|
+
stringify: function stringify(node) {
|
|
311
|
+
return intStringify(node, 16, '0x');
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
var nanObj = {
|
|
315
|
+
identify: function identify(value) {
|
|
316
|
+
return typeof value === 'number';
|
|
317
|
+
},
|
|
318
|
+
default: true,
|
|
319
|
+
tag: 'tag:yaml.org,2002:float',
|
|
320
|
+
test: /^(?:[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN))$/,
|
|
321
|
+
resolve: function resolve(str) {
|
|
322
|
+
return str.slice(-3).toLowerCase() === 'nan' ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
|
|
323
|
+
},
|
|
324
|
+
stringify: stringifyNumber
|
|
325
|
+
};
|
|
326
|
+
var expObj = {
|
|
327
|
+
identify: function identify(value) {
|
|
328
|
+
return typeof value === 'number';
|
|
329
|
+
},
|
|
330
|
+
default: true,
|
|
331
|
+
tag: 'tag:yaml.org,2002:float',
|
|
332
|
+
format: 'EXP',
|
|
333
|
+
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
334
|
+
resolve: function resolve(str) {
|
|
335
|
+
return parseFloat(str);
|
|
336
|
+
},
|
|
337
|
+
stringify: function stringify(_ref3) {
|
|
338
|
+
var value = _ref3.value;
|
|
339
|
+
return Number(value).toExponential();
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
var floatObj = {
|
|
343
|
+
identify: function identify(value) {
|
|
344
|
+
return typeof value === 'number';
|
|
345
|
+
},
|
|
346
|
+
default: true,
|
|
347
|
+
tag: 'tag:yaml.org,2002:float',
|
|
348
|
+
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
349
|
+
resolve: function resolve(str) {
|
|
350
|
+
var node = new Scalar(parseFloat(str));
|
|
351
|
+
var dot = str.indexOf('.');
|
|
352
|
+
if (dot !== -1 && str[str.length - 1] === '0') node.minFractionDigits = str.length - dot - 1;
|
|
353
|
+
return node;
|
|
354
|
+
},
|
|
355
|
+
stringify: stringifyNumber
|
|
356
|
+
};
|
|
357
|
+
var core = failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);
|
|
358
|
+
|
|
359
|
+
/* global BigInt */
|
|
360
|
+
|
|
361
|
+
var intIdentify$1 = function intIdentify(value) {
|
|
362
|
+
return typeof value === 'bigint' || Number.isInteger(value);
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
var stringifyJSON = function stringifyJSON(_ref) {
|
|
366
|
+
var value = _ref.value;
|
|
367
|
+
return JSON.stringify(value);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
var json = [map, seq, {
|
|
371
|
+
identify: function identify(value) {
|
|
372
|
+
return typeof value === 'string';
|
|
373
|
+
},
|
|
374
|
+
default: true,
|
|
375
|
+
tag: 'tag:yaml.org,2002:str',
|
|
376
|
+
resolve: function resolve(str) {
|
|
377
|
+
return str;
|
|
378
|
+
},
|
|
379
|
+
stringify: stringifyJSON
|
|
380
|
+
}, {
|
|
381
|
+
identify: function identify(value) {
|
|
382
|
+
return value == null;
|
|
383
|
+
},
|
|
384
|
+
createNode: function createNode(schema, value, ctx) {
|
|
385
|
+
return ctx.wrapScalars ? new Scalar(null) : null;
|
|
386
|
+
},
|
|
387
|
+
default: true,
|
|
388
|
+
tag: 'tag:yaml.org,2002:null',
|
|
389
|
+
test: /^null$/,
|
|
390
|
+
resolve: function resolve() {
|
|
391
|
+
return null;
|
|
392
|
+
},
|
|
393
|
+
stringify: stringifyJSON
|
|
394
|
+
}, {
|
|
395
|
+
identify: function identify(value) {
|
|
396
|
+
return typeof value === 'boolean';
|
|
397
|
+
},
|
|
398
|
+
default: true,
|
|
399
|
+
tag: 'tag:yaml.org,2002:bool',
|
|
400
|
+
test: /^true|false$/,
|
|
401
|
+
resolve: function resolve(str) {
|
|
402
|
+
return str === 'true';
|
|
403
|
+
},
|
|
404
|
+
stringify: stringifyJSON
|
|
405
|
+
}, {
|
|
406
|
+
identify: intIdentify$1,
|
|
407
|
+
default: true,
|
|
408
|
+
tag: 'tag:yaml.org,2002:int',
|
|
409
|
+
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
410
|
+
resolve: function resolve(str) {
|
|
411
|
+
return intOptions.asBigInt ? BigInt(str) : parseInt(str, 10);
|
|
412
|
+
},
|
|
413
|
+
stringify: function stringify(_ref2) {
|
|
414
|
+
var value = _ref2.value;
|
|
415
|
+
return intIdentify$1(value) ? value.toString() : JSON.stringify(value);
|
|
416
|
+
}
|
|
417
|
+
}, {
|
|
418
|
+
identify: function identify(value) {
|
|
419
|
+
return typeof value === 'number';
|
|
420
|
+
},
|
|
421
|
+
default: true,
|
|
422
|
+
tag: 'tag:yaml.org,2002:float',
|
|
423
|
+
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
|
424
|
+
resolve: function resolve(str) {
|
|
425
|
+
return parseFloat(str);
|
|
426
|
+
},
|
|
427
|
+
stringify: stringifyJSON
|
|
428
|
+
}, {
|
|
429
|
+
default: true,
|
|
430
|
+
test: /^/,
|
|
431
|
+
resolve: function resolve(str, onError) {
|
|
432
|
+
onError("Unresolved plain scalar ".concat(JSON.stringify(str)));
|
|
433
|
+
return str;
|
|
434
|
+
}
|
|
435
|
+
}];
|
|
436
|
+
|
|
437
|
+
/* global atob, btoa, Buffer */
|
|
438
|
+
var binary = {
|
|
439
|
+
identify: function identify(value) {
|
|
440
|
+
return value instanceof Uint8Array;
|
|
441
|
+
},
|
|
442
|
+
// Buffer inherits from Uint8Array
|
|
443
|
+
default: false,
|
|
444
|
+
tag: 'tag:yaml.org,2002:binary',
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Returns a Buffer in node and an Uint8Array in browsers
|
|
448
|
+
*
|
|
449
|
+
* To use the resulting buffer as an image, you'll want to do something like:
|
|
450
|
+
*
|
|
451
|
+
* const blob = new Blob([buffer], { type: 'image/jpeg' })
|
|
452
|
+
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
453
|
+
*/
|
|
454
|
+
resolve: function resolve(src, onError) {
|
|
455
|
+
if (typeof Buffer === 'function') {
|
|
456
|
+
return Buffer.from(src, 'base64');
|
|
457
|
+
} else if (typeof atob === 'function') {
|
|
458
|
+
// On IE 11, atob() can't handle newlines
|
|
459
|
+
var str = atob(src.replace(/[\n\r]/g, ''));
|
|
460
|
+
var buffer = new Uint8Array(str.length);
|
|
461
|
+
|
|
462
|
+
for (var i = 0; i < str.length; ++i) {
|
|
463
|
+
buffer[i] = str.charCodeAt(i);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return buffer;
|
|
467
|
+
} else {
|
|
468
|
+
onError('This environment does not support reading binary tags; either Buffer or atob is required');
|
|
469
|
+
return src;
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
options: binaryOptions,
|
|
473
|
+
stringify: function stringify(_ref, ctx, onComment, onChompKeep) {
|
|
474
|
+
var comment = _ref.comment,
|
|
475
|
+
type = _ref.type,
|
|
476
|
+
value = _ref.value;
|
|
477
|
+
var src;
|
|
478
|
+
|
|
479
|
+
if (typeof Buffer === 'function') {
|
|
480
|
+
src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
|
|
481
|
+
} else if (typeof btoa === 'function') {
|
|
482
|
+
var s = '';
|
|
483
|
+
|
|
484
|
+
for (var i = 0; i < value.length; ++i) {
|
|
485
|
+
s += String.fromCharCode(value[i]);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
src = btoa(s);
|
|
489
|
+
} else {
|
|
490
|
+
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (!type) type = binaryOptions.defaultType;
|
|
494
|
+
|
|
495
|
+
if (type === Type.QUOTE_DOUBLE) {
|
|
496
|
+
value = src;
|
|
497
|
+
} else {
|
|
498
|
+
var lineWidth = binaryOptions.lineWidth;
|
|
499
|
+
var n = Math.ceil(src.length / lineWidth);
|
|
500
|
+
var lines = new Array(n);
|
|
501
|
+
|
|
502
|
+
for (var _i = 0, o = 0; _i < n; ++_i, o += lineWidth) {
|
|
503
|
+
lines[_i] = src.substr(o, lineWidth);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
value = lines.join(type === Type.BLOCK_LITERAL ? '\n' : ' ');
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return stringifyString({
|
|
510
|
+
comment: comment,
|
|
511
|
+
type: type,
|
|
512
|
+
value: value
|
|
513
|
+
}, ctx, onComment, onChompKeep);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
function parsePairs(seq, onError) {
|
|
518
|
+
if (seq instanceof YAMLSeq) {
|
|
519
|
+
for (var i = 0; i < seq.items.length; ++i) {
|
|
520
|
+
var item = seq.items[i];
|
|
521
|
+
if (item instanceof Pair) continue;else if (item instanceof YAMLMap) {
|
|
522
|
+
if (item.items.length > 1) onError('Each pair must have its own sequence indicator');
|
|
523
|
+
var pair = item.items[0] || new Pair();
|
|
524
|
+
if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore;
|
|
525
|
+
if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment;
|
|
526
|
+
item = pair;
|
|
527
|
+
}
|
|
528
|
+
seq.items[i] = item instanceof Pair ? item : new Pair(item);
|
|
529
|
+
}
|
|
530
|
+
} else onError('Expected a sequence for this tag');
|
|
531
|
+
|
|
532
|
+
return seq;
|
|
533
|
+
}
|
|
534
|
+
function createPairs(schema, iterable, ctx) {
|
|
535
|
+
var replacer = ctx.replacer;
|
|
536
|
+
var pairs = new YAMLSeq(schema);
|
|
537
|
+
pairs.tag = 'tag:yaml.org,2002:pairs';
|
|
538
|
+
var i = 0;
|
|
539
|
+
|
|
540
|
+
var _iterator = _createForOfIteratorHelper(iterable),
|
|
541
|
+
_step;
|
|
542
|
+
|
|
543
|
+
try {
|
|
544
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
545
|
+
var it = _step.value;
|
|
546
|
+
if (typeof replacer === 'function') it = replacer.call(iterable, String(i++), it);
|
|
547
|
+
var key = void 0,
|
|
548
|
+
value = void 0;
|
|
549
|
+
|
|
550
|
+
if (Array.isArray(it)) {
|
|
551
|
+
if (it.length === 2) {
|
|
552
|
+
key = it[0];
|
|
553
|
+
value = it[1];
|
|
554
|
+
} else throw new TypeError("Expected [key, value] tuple: ".concat(it));
|
|
555
|
+
} else if (it && it instanceof Object) {
|
|
556
|
+
var keys = Object.keys(it);
|
|
557
|
+
|
|
558
|
+
if (keys.length === 1) {
|
|
559
|
+
key = keys[0];
|
|
560
|
+
value = it[key];
|
|
561
|
+
} else throw new TypeError("Expected { key: value } tuple: ".concat(it));
|
|
562
|
+
} else {
|
|
563
|
+
key = it;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
pairs.items.push(createPair(key, value, ctx));
|
|
567
|
+
}
|
|
568
|
+
} catch (err) {
|
|
569
|
+
_iterator.e(err);
|
|
570
|
+
} finally {
|
|
571
|
+
_iterator.f();
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return pairs;
|
|
575
|
+
}
|
|
576
|
+
var pairs = {
|
|
577
|
+
default: false,
|
|
578
|
+
tag: 'tag:yaml.org,2002:pairs',
|
|
579
|
+
resolve: parsePairs,
|
|
580
|
+
createNode: createPairs
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
|
|
584
|
+
_inherits(YAMLOMap, _YAMLSeq);
|
|
585
|
+
|
|
586
|
+
var _super = _createSuper(YAMLOMap);
|
|
587
|
+
|
|
588
|
+
function YAMLOMap() {
|
|
589
|
+
var _this;
|
|
590
|
+
|
|
591
|
+
_classCallCheck(this, YAMLOMap);
|
|
592
|
+
|
|
593
|
+
_this = _super.call(this);
|
|
594
|
+
|
|
595
|
+
_defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this)));
|
|
596
|
+
|
|
597
|
+
_defineProperty(_assertThisInitialized(_this), "delete", YAMLMap.prototype.delete.bind(_assertThisInitialized(_this)));
|
|
598
|
+
|
|
599
|
+
_defineProperty(_assertThisInitialized(_this), "get", YAMLMap.prototype.get.bind(_assertThisInitialized(_this)));
|
|
600
|
+
|
|
601
|
+
_defineProperty(_assertThisInitialized(_this), "has", YAMLMap.prototype.has.bind(_assertThisInitialized(_this)));
|
|
602
|
+
|
|
603
|
+
_defineProperty(_assertThisInitialized(_this), "set", YAMLMap.prototype.set.bind(_assertThisInitialized(_this)));
|
|
604
|
+
|
|
605
|
+
_this.tag = YAMLOMap.tag;
|
|
606
|
+
return _this;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
_createClass(YAMLOMap, [{
|
|
610
|
+
key: "toJSON",
|
|
611
|
+
value: function toJSON(_, ctx) {
|
|
612
|
+
var map = new Map();
|
|
613
|
+
if (ctx && ctx.onCreate) ctx.onCreate(map);
|
|
614
|
+
|
|
615
|
+
var _iterator = _createForOfIteratorHelper(this.items),
|
|
616
|
+
_step;
|
|
617
|
+
|
|
618
|
+
try {
|
|
619
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
620
|
+
var pair = _step.value;
|
|
621
|
+
var key = void 0,
|
|
622
|
+
value = void 0;
|
|
623
|
+
|
|
624
|
+
if (pair instanceof Pair) {
|
|
625
|
+
key = toJS(pair.key, '', ctx);
|
|
626
|
+
value = toJS(pair.value, key, ctx);
|
|
627
|
+
} else {
|
|
628
|
+
key = toJS(pair, '', ctx);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
|
|
632
|
+
map.set(key, value);
|
|
633
|
+
}
|
|
634
|
+
} catch (err) {
|
|
635
|
+
_iterator.e(err);
|
|
636
|
+
} finally {
|
|
637
|
+
_iterator.f();
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
return map;
|
|
641
|
+
}
|
|
642
|
+
}]);
|
|
643
|
+
|
|
644
|
+
return YAMLOMap;
|
|
645
|
+
}(YAMLSeq);
|
|
646
|
+
|
|
647
|
+
_defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
|
|
648
|
+
|
|
649
|
+
function parseOMap(seq, onError) {
|
|
650
|
+
var pairs = parsePairs(seq, onError);
|
|
651
|
+
var seenKeys = [];
|
|
652
|
+
|
|
653
|
+
var _iterator2 = _createForOfIteratorHelper(pairs.items),
|
|
654
|
+
_step2;
|
|
655
|
+
|
|
656
|
+
try {
|
|
657
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
658
|
+
var key = _step2.value.key;
|
|
659
|
+
|
|
660
|
+
if (key instanceof Scalar) {
|
|
661
|
+
if (seenKeys.includes(key.value)) {
|
|
662
|
+
onError("Ordered maps must not include duplicate keys: ".concat(key.value));
|
|
663
|
+
} else {
|
|
664
|
+
seenKeys.push(key.value);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
} catch (err) {
|
|
669
|
+
_iterator2.e(err);
|
|
670
|
+
} finally {
|
|
671
|
+
_iterator2.f();
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
return Object.assign(new YAMLOMap(), pairs);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function createOMap(schema, iterable, ctx) {
|
|
678
|
+
var pairs = createPairs(schema, iterable, ctx);
|
|
679
|
+
var omap = new YAMLOMap();
|
|
680
|
+
omap.items = pairs.items;
|
|
681
|
+
return omap;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
var omap = {
|
|
685
|
+
identify: function identify(value) {
|
|
686
|
+
return value instanceof Map;
|
|
687
|
+
},
|
|
688
|
+
nodeClass: YAMLOMap,
|
|
689
|
+
default: false,
|
|
690
|
+
tag: 'tag:yaml.org,2002:omap',
|
|
691
|
+
resolve: parseOMap,
|
|
692
|
+
createNode: createOMap
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
var YAMLSet = /*#__PURE__*/function (_YAMLMap) {
|
|
696
|
+
_inherits(YAMLSet, _YAMLMap);
|
|
697
|
+
|
|
698
|
+
var _super = _createSuper(YAMLSet);
|
|
699
|
+
|
|
700
|
+
function YAMLSet(schema) {
|
|
701
|
+
var _this;
|
|
702
|
+
|
|
703
|
+
_classCallCheck(this, YAMLSet);
|
|
704
|
+
|
|
705
|
+
_this = _super.call(this, schema);
|
|
706
|
+
_this.tag = YAMLSet.tag;
|
|
707
|
+
return _this;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
_createClass(YAMLSet, [{
|
|
711
|
+
key: "add",
|
|
712
|
+
value: function add(key) {
|
|
713
|
+
var pair = key instanceof Pair ? key : new Pair(key);
|
|
714
|
+
var prev = findPair(this.items, pair.key);
|
|
715
|
+
if (!prev) this.items.push(pair);
|
|
716
|
+
}
|
|
717
|
+
}, {
|
|
718
|
+
key: "get",
|
|
719
|
+
value: function get(key, keepPair) {
|
|
720
|
+
var pair = findPair(this.items, key);
|
|
721
|
+
return !keepPair && pair instanceof Pair ? pair.key instanceof Scalar ? pair.key.value : pair.key : pair;
|
|
722
|
+
}
|
|
723
|
+
}, {
|
|
724
|
+
key: "set",
|
|
725
|
+
value: function set(key, value) {
|
|
726
|
+
if (typeof value !== 'boolean') throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat(_typeof(value)));
|
|
727
|
+
var prev = findPair(this.items, key);
|
|
728
|
+
|
|
729
|
+
if (prev && !value) {
|
|
730
|
+
this.items.splice(this.items.indexOf(prev), 1);
|
|
731
|
+
} else if (!prev && value) {
|
|
732
|
+
this.items.push(new Pair(key));
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}, {
|
|
736
|
+
key: "toJSON",
|
|
737
|
+
value: function toJSON(_, ctx) {
|
|
738
|
+
return _get(_getPrototypeOf(YAMLSet.prototype), "toJSON", this).call(this, _, ctx, Set);
|
|
739
|
+
}
|
|
740
|
+
}, {
|
|
741
|
+
key: "toString",
|
|
742
|
+
value: function toString(ctx, onComment, onChompKeep) {
|
|
743
|
+
if (!ctx) return JSON.stringify(this);
|
|
744
|
+
if (this.hasAllNullValues()) return _get(_getPrototypeOf(YAMLSet.prototype), "toString", this).call(this, ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
|
|
745
|
+
}
|
|
746
|
+
}]);
|
|
747
|
+
|
|
748
|
+
return YAMLSet;
|
|
749
|
+
}(YAMLMap);
|
|
750
|
+
|
|
751
|
+
_defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
|
|
752
|
+
|
|
753
|
+
function parseSet(map, onError) {
|
|
754
|
+
if (map instanceof YAMLMap) {
|
|
755
|
+
if (map.hasAllNullValues()) return Object.assign(new YAMLSet(), map);else onError('Set items must all have null values');
|
|
756
|
+
} else onError('Expected a mapping for this tag');
|
|
757
|
+
|
|
758
|
+
return map;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function createSet(schema, iterable, ctx) {
|
|
762
|
+
var replacer = ctx.replacer;
|
|
763
|
+
var set = new YAMLSet(schema);
|
|
764
|
+
|
|
765
|
+
var _iterator = _createForOfIteratorHelper(iterable),
|
|
766
|
+
_step;
|
|
767
|
+
|
|
768
|
+
try {
|
|
769
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
770
|
+
var value = _step.value;
|
|
771
|
+
if (typeof replacer === 'function') value = replacer.call(iterable, value, value);
|
|
772
|
+
set.items.push(createPair(value, null, ctx));
|
|
773
|
+
}
|
|
774
|
+
} catch (err) {
|
|
775
|
+
_iterator.e(err);
|
|
776
|
+
} finally {
|
|
777
|
+
_iterator.f();
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
return set;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
var set = {
|
|
784
|
+
identify: function identify(value) {
|
|
785
|
+
return value instanceof Set;
|
|
786
|
+
},
|
|
787
|
+
nodeClass: YAMLSet,
|
|
788
|
+
default: false,
|
|
789
|
+
tag: 'tag:yaml.org,2002:set',
|
|
790
|
+
resolve: parseSet,
|
|
791
|
+
createNode: createSet
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
var parseSexagesimal = function parseSexagesimal(str, isInt) {
|
|
795
|
+
var sign = str[0];
|
|
796
|
+
var parts = sign === '-' || sign === '+' ? str.substring(1) : str;
|
|
797
|
+
|
|
798
|
+
var num = function num(n) {
|
|
799
|
+
return isInt && intOptions.asBigInt ? BigInt(n) : Number(n);
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
var res = parts.replace(/_/g, '').split(':').reduce(function (res, p) {
|
|
803
|
+
return res * num(60) + num(p);
|
|
804
|
+
}, num(0));
|
|
805
|
+
return sign === '-' ? num(-1) * res : res;
|
|
806
|
+
}; // hhhh:mm:ss.sss
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
var stringifySexagesimal = function stringifySexagesimal(_ref) {
|
|
810
|
+
var value = _ref.value;
|
|
811
|
+
|
|
812
|
+
var num = function num(n) {
|
|
813
|
+
return n;
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
if (typeof value === 'bigint') num = function num(n) {
|
|
817
|
+
return BigInt(n);
|
|
818
|
+
};else if (isNaN(value) || !isFinite(value)) return stringifyNumber(value);
|
|
819
|
+
var sign = '';
|
|
820
|
+
|
|
821
|
+
if (value < 0) {
|
|
822
|
+
sign = '-';
|
|
823
|
+
value *= num(-1);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
var _60 = num(60);
|
|
827
|
+
|
|
828
|
+
var parts = [value % _60]; // seconds, including ms
|
|
829
|
+
|
|
830
|
+
if (value < 60) {
|
|
831
|
+
parts.unshift(0); // at least one : is required
|
|
832
|
+
} else {
|
|
833
|
+
value = (value - parts[0]) / _60;
|
|
834
|
+
parts.unshift(value % _60); // minutes
|
|
835
|
+
|
|
836
|
+
if (value >= 60) {
|
|
837
|
+
value = (value - parts[0]) / _60;
|
|
838
|
+
parts.unshift(value); // hours
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
return sign + parts.map(function (n) {
|
|
843
|
+
return n < 10 ? '0' + String(n) : String(n);
|
|
844
|
+
}).join(':').replace(/000000\d*$/, '') // % 60 may introduce error
|
|
845
|
+
;
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
var intTime = {
|
|
849
|
+
identify: function identify(value) {
|
|
850
|
+
return typeof value === 'bigint' || Number.isInteger(value);
|
|
851
|
+
},
|
|
852
|
+
default: true,
|
|
853
|
+
tag: 'tag:yaml.org,2002:int',
|
|
854
|
+
format: 'TIME',
|
|
855
|
+
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
856
|
+
resolve: function resolve(str) {
|
|
857
|
+
return parseSexagesimal(str, true);
|
|
858
|
+
},
|
|
859
|
+
stringify: stringifySexagesimal
|
|
860
|
+
};
|
|
861
|
+
var floatTime = {
|
|
862
|
+
identify: function identify(value) {
|
|
863
|
+
return typeof value === 'number';
|
|
864
|
+
},
|
|
865
|
+
default: true,
|
|
866
|
+
tag: 'tag:yaml.org,2002:float',
|
|
867
|
+
format: 'TIME',
|
|
868
|
+
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
869
|
+
resolve: function resolve(str) {
|
|
870
|
+
return parseSexagesimal(str, false);
|
|
871
|
+
},
|
|
872
|
+
stringify: stringifySexagesimal
|
|
873
|
+
};
|
|
874
|
+
var timestamp = {
|
|
875
|
+
identify: function identify(value) {
|
|
876
|
+
return value instanceof Date;
|
|
877
|
+
},
|
|
878
|
+
default: true,
|
|
879
|
+
tag: 'tag:yaml.org,2002:timestamp',
|
|
880
|
+
// If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
|
|
881
|
+
// may be omitted altogether, resulting in a date format. In such a case, the time part is
|
|
882
|
+
// assumed to be 00:00:00Z (start of day, UTC).
|
|
883
|
+
test: RegExp('^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd
|
|
884
|
+
'(?:' + // time is optional
|
|
885
|
+
'(?:t|T|[ \\t]+)' + // t | T | whitespace
|
|
886
|
+
'([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)?
|
|
887
|
+
'(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
|
|
888
|
+
')?$'),
|
|
889
|
+
resolve: function resolve(str) {
|
|
890
|
+
var _str$match = str.match(timestamp.test),
|
|
891
|
+
_str$match2 = _slicedToArray(_str$match, 9),
|
|
892
|
+
year = _str$match2[1],
|
|
893
|
+
month = _str$match2[2],
|
|
894
|
+
day = _str$match2[3],
|
|
895
|
+
hour = _str$match2[4],
|
|
896
|
+
minute = _str$match2[5],
|
|
897
|
+
second = _str$match2[6],
|
|
898
|
+
millisec = _str$match2[7],
|
|
899
|
+
tz = _str$match2[8];
|
|
900
|
+
|
|
901
|
+
if (millisec) millisec = (millisec + '00').substr(1, 3);
|
|
902
|
+
var date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0);
|
|
903
|
+
|
|
904
|
+
if (tz && tz !== 'Z') {
|
|
905
|
+
var d = parseSexagesimal(tz, false);
|
|
906
|
+
if (Math.abs(d) < 30) d *= 60;
|
|
907
|
+
date -= 60000 * d;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
return new Date(date);
|
|
911
|
+
},
|
|
912
|
+
stringify: function stringify(_ref2) {
|
|
913
|
+
var value = _ref2.value;
|
|
914
|
+
return value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '');
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
/* global BigInt */
|
|
919
|
+
|
|
920
|
+
var boolStringify = function boolStringify(_ref) {
|
|
921
|
+
var value = _ref.value;
|
|
922
|
+
return value ? boolOptions.trueStr : boolOptions.falseStr;
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
var intIdentify$2 = function intIdentify(value) {
|
|
926
|
+
return typeof value === 'bigint' || Number.isInteger(value);
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
function intResolve$1(str, offset, radix) {
|
|
930
|
+
var sign = str[0];
|
|
931
|
+
if (sign === '-' || sign === '+') offset += 1;
|
|
932
|
+
str = str.substring(offset).replace(/_/g, '');
|
|
933
|
+
|
|
934
|
+
if (intOptions.asBigInt) {
|
|
935
|
+
switch (radix) {
|
|
936
|
+
case 2:
|
|
937
|
+
str = "0b".concat(str);
|
|
938
|
+
break;
|
|
939
|
+
|
|
940
|
+
case 8:
|
|
941
|
+
str = "0o".concat(str);
|
|
942
|
+
break;
|
|
943
|
+
|
|
944
|
+
case 16:
|
|
945
|
+
str = "0x".concat(str);
|
|
946
|
+
break;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
var _n = BigInt(str);
|
|
950
|
+
|
|
951
|
+
return sign === '-' ? BigInt(-1) * _n : _n;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
var n = parseInt(str, radix);
|
|
955
|
+
return sign === '-' ? -1 * n : n;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function intStringify$1(node, radix, prefix) {
|
|
959
|
+
var value = node.value;
|
|
960
|
+
|
|
961
|
+
if (intIdentify$2(value)) {
|
|
962
|
+
var str = value.toString(radix);
|
|
963
|
+
return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
return stringifyNumber(node);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
var yaml11 = failsafe.concat([{
|
|
970
|
+
identify: function identify(value) {
|
|
971
|
+
return value == null;
|
|
972
|
+
},
|
|
973
|
+
createNode: function createNode(schema, value, ctx) {
|
|
974
|
+
return ctx.wrapScalars ? new Scalar(null) : null;
|
|
975
|
+
},
|
|
976
|
+
default: true,
|
|
977
|
+
tag: 'tag:yaml.org,2002:null',
|
|
978
|
+
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
979
|
+
resolve: function resolve(str) {
|
|
980
|
+
var node = new Scalar(null);
|
|
981
|
+
node.sourceStr = str;
|
|
982
|
+
return node;
|
|
983
|
+
},
|
|
984
|
+
options: nullOptions,
|
|
985
|
+
stringify: function stringify(_ref2) {
|
|
986
|
+
var sourceStr = _ref2.sourceStr;
|
|
987
|
+
return sourceStr !== null && sourceStr !== void 0 ? sourceStr : nullOptions.nullStr;
|
|
988
|
+
}
|
|
989
|
+
}, {
|
|
990
|
+
identify: function identify(value) {
|
|
991
|
+
return typeof value === 'boolean';
|
|
992
|
+
},
|
|
993
|
+
default: true,
|
|
994
|
+
tag: 'tag:yaml.org,2002:bool',
|
|
995
|
+
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
996
|
+
resolve: function resolve() {
|
|
997
|
+
return true;
|
|
998
|
+
},
|
|
999
|
+
options: boolOptions,
|
|
1000
|
+
stringify: boolStringify
|
|
1001
|
+
}, {
|
|
1002
|
+
identify: function identify(value) {
|
|
1003
|
+
return typeof value === 'boolean';
|
|
1004
|
+
},
|
|
1005
|
+
default: true,
|
|
1006
|
+
tag: 'tag:yaml.org,2002:bool',
|
|
1007
|
+
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
|
|
1008
|
+
resolve: function resolve() {
|
|
1009
|
+
return false;
|
|
1010
|
+
},
|
|
1011
|
+
options: boolOptions,
|
|
1012
|
+
stringify: boolStringify
|
|
1013
|
+
}, {
|
|
1014
|
+
identify: intIdentify$2,
|
|
1015
|
+
default: true,
|
|
1016
|
+
tag: 'tag:yaml.org,2002:int',
|
|
1017
|
+
format: 'BIN',
|
|
1018
|
+
test: /^[-+]?0b[0-1_]+$/,
|
|
1019
|
+
resolve: function resolve(str) {
|
|
1020
|
+
return intResolve$1(str, 2, 2);
|
|
1021
|
+
},
|
|
1022
|
+
stringify: function stringify(node) {
|
|
1023
|
+
return intStringify$1(node, 2, '0b');
|
|
1024
|
+
}
|
|
1025
|
+
}, {
|
|
1026
|
+
identify: intIdentify$2,
|
|
1027
|
+
default: true,
|
|
1028
|
+
tag: 'tag:yaml.org,2002:int',
|
|
1029
|
+
format: 'OCT',
|
|
1030
|
+
test: /^[-+]?0[0-7_]+$/,
|
|
1031
|
+
resolve: function resolve(str) {
|
|
1032
|
+
return intResolve$1(str, 1, 8);
|
|
1033
|
+
},
|
|
1034
|
+
stringify: function stringify(node) {
|
|
1035
|
+
return intStringify$1(node, 8, '0');
|
|
1036
|
+
}
|
|
1037
|
+
}, {
|
|
1038
|
+
identify: intIdentify$2,
|
|
1039
|
+
default: true,
|
|
1040
|
+
tag: 'tag:yaml.org,2002:int',
|
|
1041
|
+
test: /^[-+]?[0-9][0-9_]*$/,
|
|
1042
|
+
resolve: function resolve(str) {
|
|
1043
|
+
return intResolve$1(str, 0, 10);
|
|
1044
|
+
},
|
|
1045
|
+
stringify: stringifyNumber
|
|
1046
|
+
}, {
|
|
1047
|
+
identify: intIdentify$2,
|
|
1048
|
+
default: true,
|
|
1049
|
+
tag: 'tag:yaml.org,2002:int',
|
|
1050
|
+
format: 'HEX',
|
|
1051
|
+
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
1052
|
+
resolve: function resolve(str) {
|
|
1053
|
+
return intResolve$1(str, 2, 16);
|
|
1054
|
+
},
|
|
1055
|
+
stringify: function stringify(node) {
|
|
1056
|
+
return intStringify$1(node, 16, '0x');
|
|
1057
|
+
}
|
|
1058
|
+
}, {
|
|
1059
|
+
identify: function identify(value) {
|
|
1060
|
+
return typeof value === 'number';
|
|
1061
|
+
},
|
|
1062
|
+
default: true,
|
|
1063
|
+
tag: 'tag:yaml.org,2002:float',
|
|
1064
|
+
test: /^[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN)$/,
|
|
1065
|
+
resolve: function resolve(str) {
|
|
1066
|
+
return str.slice(-3).toLowerCase() === 'nan' ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
|
|
1067
|
+
},
|
|
1068
|
+
stringify: stringifyNumber
|
|
1069
|
+
}, {
|
|
1070
|
+
identify: function identify(value) {
|
|
1071
|
+
return typeof value === 'number';
|
|
1072
|
+
},
|
|
1073
|
+
default: true,
|
|
1074
|
+
tag: 'tag:yaml.org,2002:float',
|
|
1075
|
+
format: 'EXP',
|
|
1076
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
1077
|
+
resolve: function resolve(str) {
|
|
1078
|
+
return parseFloat(str.replace(/_/g, ''));
|
|
1079
|
+
},
|
|
1080
|
+
stringify: function stringify(_ref3) {
|
|
1081
|
+
var value = _ref3.value;
|
|
1082
|
+
return Number(value).toExponential();
|
|
1083
|
+
}
|
|
1084
|
+
}, {
|
|
1085
|
+
identify: function identify(value) {
|
|
1086
|
+
return typeof value === 'number';
|
|
1087
|
+
},
|
|
1088
|
+
default: true,
|
|
1089
|
+
tag: 'tag:yaml.org,2002:float',
|
|
1090
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
1091
|
+
resolve: function resolve(str) {
|
|
1092
|
+
var node = new Scalar(parseFloat(str.replace(/_/g, '')));
|
|
1093
|
+
var dot = str.indexOf('.');
|
|
1094
|
+
|
|
1095
|
+
if (dot !== -1) {
|
|
1096
|
+
var f = str.substring(dot + 1).replace(/_/g, '');
|
|
1097
|
+
if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
return node;
|
|
1101
|
+
},
|
|
1102
|
+
stringify: stringifyNumber
|
|
1103
|
+
}], binary, omap, pairs, set, intTime, floatTime, timestamp);
|
|
1104
|
+
|
|
1105
|
+
var schemas = {
|
|
1106
|
+
core: core,
|
|
1107
|
+
failsafe: failsafe,
|
|
1108
|
+
json: json,
|
|
1109
|
+
yaml11: yaml11
|
|
1110
|
+
};
|
|
1111
|
+
var tags = {
|
|
1112
|
+
binary: binary,
|
|
1113
|
+
bool: boolObj,
|
|
1114
|
+
float: floatObj,
|
|
1115
|
+
floatExp: expObj,
|
|
1116
|
+
floatNaN: nanObj,
|
|
1117
|
+
floatTime: floatTime,
|
|
1118
|
+
int: intObj,
|
|
1119
|
+
intHex: hexObj,
|
|
1120
|
+
intOct: octObj,
|
|
1121
|
+
intTime: intTime,
|
|
1122
|
+
map: map,
|
|
1123
|
+
null: nullObj,
|
|
1124
|
+
omap: omap,
|
|
1125
|
+
pairs: pairs,
|
|
1126
|
+
seq: seq,
|
|
1127
|
+
set: set,
|
|
1128
|
+
timestamp: timestamp
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
function getSchemaTags(schemas, knownTags, customTags, schemaId) {
|
|
1132
|
+
var tags = schemas[schemaId.replace(/\W/g, '')]; // 'yaml-1.1' -> 'yaml11'
|
|
1133
|
+
|
|
1134
|
+
if (!tags) {
|
|
1135
|
+
var keys = Object.keys(schemas).map(function (key) {
|
|
1136
|
+
return JSON.stringify(key);
|
|
1137
|
+
}).join(', ');
|
|
1138
|
+
throw new Error("Unknown schema \"".concat(schemaId, "\"; use one of ").concat(keys));
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
if (Array.isArray(customTags)) {
|
|
1142
|
+
var _iterator = _createForOfIteratorHelper(customTags),
|
|
1143
|
+
_step;
|
|
1144
|
+
|
|
1145
|
+
try {
|
|
1146
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1147
|
+
var tag = _step.value;
|
|
1148
|
+
tags = tags.concat(tag);
|
|
1149
|
+
}
|
|
1150
|
+
} catch (err) {
|
|
1151
|
+
_iterator.e(err);
|
|
1152
|
+
} finally {
|
|
1153
|
+
_iterator.f();
|
|
1154
|
+
}
|
|
1155
|
+
} else if (typeof customTags === 'function') {
|
|
1156
|
+
tags = customTags(tags.slice());
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
for (var i = 0; i < tags.length; ++i) {
|
|
1160
|
+
var _tag = tags[i];
|
|
1161
|
+
|
|
1162
|
+
if (typeof _tag === 'string') {
|
|
1163
|
+
var tagObj = knownTags[_tag];
|
|
1164
|
+
|
|
1165
|
+
if (!tagObj) {
|
|
1166
|
+
var _keys = Object.keys(knownTags).map(function (key) {
|
|
1167
|
+
return JSON.stringify(key);
|
|
1168
|
+
}).join(', ');
|
|
1169
|
+
|
|
1170
|
+
throw new Error("Unknown custom tag \"".concat(_tag, "\"; use one of ").concat(_keys));
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
tags[i] = tagObj;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
return tags;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
var sortMapEntriesByKey = function sortMapEntriesByKey(a, b) {
|
|
1181
|
+
return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
var coreKnownTags = {
|
|
1185
|
+
'tag:yaml.org,2002:binary': tags.binary,
|
|
1186
|
+
'tag:yaml.org,2002:omap': tags.omap,
|
|
1187
|
+
'tag:yaml.org,2002:pairs': tags.pairs,
|
|
1188
|
+
'tag:yaml.org,2002:set': tags.set,
|
|
1189
|
+
'tag:yaml.org,2002:timestamp': tags.timestamp
|
|
1190
|
+
};
|
|
1191
|
+
var Schema = function Schema(_ref) {
|
|
1192
|
+
var customTags = _ref.customTags,
|
|
1193
|
+
merge = _ref.merge,
|
|
1194
|
+
resolveKnownTags = _ref.resolveKnownTags,
|
|
1195
|
+
schema = _ref.schema,
|
|
1196
|
+
sortMapEntries = _ref.sortMapEntries;
|
|
1197
|
+
|
|
1198
|
+
_classCallCheck(this, Schema);
|
|
1199
|
+
|
|
1200
|
+
this.merge = !!merge;
|
|
1201
|
+
this.name = schema;
|
|
1202
|
+
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
1203
|
+
this.tags = getSchemaTags(schemas, tags, customTags, schema); // Used by createNode(), to avoid circular dependencies
|
|
1204
|
+
|
|
1205
|
+
this.map = tags.map;
|
|
1206
|
+
this.seq = tags.seq; // Used by createMap()
|
|
1207
|
+
|
|
1208
|
+
this.sortMapEntries = sortMapEntries === true ? sortMapEntriesByKey : sortMapEntries || null;
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
export { Merge as M, Schema as S, MERGE_KEY as a };
|