yaml 1.9.2 → 1.10.0

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.
Files changed (160) hide show
  1. package/README.md +4 -4
  2. package/browser/dist/PlainValue-ff5147c6.js +1277 -0
  3. package/browser/dist/Schema-2bf2c74e.js +679 -0
  4. package/browser/dist/index.js +869 -34
  5. package/browser/dist/legacy-exports.js +3 -0
  6. package/browser/dist/parse-cst.js +1904 -0
  7. package/browser/dist/resolveSeq-04825f30.js +2373 -0
  8. package/browser/dist/types.js +4 -0
  9. package/browser/dist/util.js +2 -0
  10. package/browser/dist/warnings-0e4b70d3.js +499 -0
  11. package/browser/index.js +1 -1
  12. package/browser/map.js +2 -4
  13. package/browser/pair.js +2 -4
  14. package/browser/parse-cst.js +1 -1
  15. package/browser/scalar.js +2 -4
  16. package/browser/schema.js +7 -10
  17. package/browser/seq.js +2 -4
  18. package/browser/types/binary.js +7 -5
  19. package/browser/types/omap.js +3 -4
  20. package/browser/types/pairs.js +3 -4
  21. package/browser/types/set.js +3 -4
  22. package/browser/types/timestamp.js +9 -5
  23. package/browser/types.js +1 -13
  24. package/browser/util.js +1 -18
  25. package/dist/Document-2cf6b08c.js +757 -0
  26. package/dist/PlainValue-ec8e588e.js +876 -0
  27. package/dist/Schema-42e9705c.js +522 -0
  28. package/dist/index.js +20 -84
  29. package/dist/legacy-exports.js +16 -0
  30. package/dist/parse-cst.js +1747 -0
  31. package/dist/resolveSeq-4a68b39b.js +2115 -0
  32. package/dist/test-events.js +11 -9
  33. package/dist/types.js +23 -0
  34. package/dist/util.js +19 -0
  35. package/dist/warnings-39684f17.js +416 -0
  36. package/index.d.ts +22 -8
  37. package/map.js +2 -2
  38. package/package.json +22 -39
  39. package/pair.js +2 -2
  40. package/parse-cst.js +1 -1
  41. package/scalar.js +2 -2
  42. package/schema.js +8 -6
  43. package/seq.js +2 -2
  44. package/types/binary.js +3 -2
  45. package/types/omap.js +3 -2
  46. package/types/pairs.js +3 -2
  47. package/types/set.js +3 -2
  48. package/types/timestamp.js +6 -6
  49. package/types.d.ts +113 -99
  50. package/types.js +16 -11
  51. package/types.mjs +15 -19
  52. package/util.js +14 -14
  53. package/util.mjs +13 -20
  54. package/browser/dist/Anchors.js +0 -130
  55. package/browser/dist/Document.js +0 -824
  56. package/browser/dist/addComment.js +0 -8
  57. package/browser/dist/constants.js +0 -26
  58. package/browser/dist/cst/Alias.js +0 -46
  59. package/browser/dist/cst/BlankLine.js +0 -52
  60. package/browser/dist/cst/BlockValue.js +0 -251
  61. package/browser/dist/cst/Collection.js +0 -278
  62. package/browser/dist/cst/CollectionItem.js +0 -140
  63. package/browser/dist/cst/Comment.js +0 -44
  64. package/browser/dist/cst/Directive.js +0 -76
  65. package/browser/dist/cst/Document.js +0 -286
  66. package/browser/dist/cst/FlowCollection.js +0 -220
  67. package/browser/dist/cst/Node.js +0 -386
  68. package/browser/dist/cst/ParseContext.js +0 -246
  69. package/browser/dist/cst/PlainValue.js +0 -170
  70. package/browser/dist/cst/QuoteDouble.js +0 -245
  71. package/browser/dist/cst/QuoteSingle.js +0 -120
  72. package/browser/dist/cst/Range.js +0 -64
  73. package/browser/dist/cst/parse.js +0 -48
  74. package/browser/dist/cst/source-utils.js +0 -168
  75. package/browser/dist/errors.js +0 -127
  76. package/browser/dist/foldFlowLines.js +0 -138
  77. package/browser/dist/listTagNames.js +0 -28
  78. package/browser/dist/schema/Alias.js +0 -135
  79. package/browser/dist/schema/Collection.js +0 -260
  80. package/browser/dist/schema/Map.js +0 -161
  81. package/browser/dist/schema/Merge.js +0 -118
  82. package/browser/dist/schema/Node.js +0 -4
  83. package/browser/dist/schema/Pair.js +0 -194
  84. package/browser/dist/schema/Scalar.js +0 -42
  85. package/browser/dist/schema/Seq.js +0 -116
  86. package/browser/dist/schema/index.js +0 -368
  87. package/browser/dist/schema/parseMap.js +0 -312
  88. package/browser/dist/schema/parseSeq.js +0 -168
  89. package/browser/dist/schema/parseUtils.js +0 -106
  90. package/browser/dist/stringify.js +0 -332
  91. package/browser/dist/tags/core.js +0 -141
  92. package/browser/dist/tags/failsafe/index.js +0 -4
  93. package/browser/dist/tags/failsafe/map.js +0 -53
  94. package/browser/dist/tags/failsafe/seq.js +0 -39
  95. package/browser/dist/tags/failsafe/string.js +0 -28
  96. package/browser/dist/tags/index.js +0 -36
  97. package/browser/dist/tags/json.js +0 -77
  98. package/browser/dist/tags/options.js +0 -26
  99. package/browser/dist/tags/yaml-1.1/binary.js +0 -87
  100. package/browser/dist/tags/yaml-1.1/index.js +0 -189
  101. package/browser/dist/tags/yaml-1.1/omap.js +0 -137
  102. package/browser/dist/tags/yaml-1.1/pairs.js +0 -78
  103. package/browser/dist/tags/yaml-1.1/set.js +0 -118
  104. package/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
  105. package/browser/dist/test-events.js +0 -163
  106. package/browser/dist/toJSON.js +0 -19
  107. package/browser/dist/warnings.js +0 -39
  108. package/dist/Anchors.js +0 -120
  109. package/dist/Document.js +0 -714
  110. package/dist/addComment.js +0 -14
  111. package/dist/constants.js +0 -31
  112. package/dist/cst/Alias.js +0 -33
  113. package/dist/cst/BlankLine.js +0 -40
  114. package/dist/cst/BlockValue.js +0 -243
  115. package/dist/cst/Collection.js +0 -266
  116. package/dist/cst/CollectionItem.js +0 -135
  117. package/dist/cst/Comment.js +0 -33
  118. package/dist/cst/Directive.js +0 -59
  119. package/dist/cst/Document.js +0 -276
  120. package/dist/cst/FlowCollection.js +0 -213
  121. package/dist/cst/Node.js +0 -360
  122. package/dist/cst/ParseContext.js +0 -253
  123. package/dist/cst/PlainValue.js +0 -156
  124. package/dist/cst/QuoteDouble.js +0 -232
  125. package/dist/cst/QuoteSingle.js +0 -108
  126. package/dist/cst/Range.js +0 -60
  127. package/dist/cst/parse.js +0 -50
  128. package/dist/cst/source-utils.js +0 -175
  129. package/dist/errors.js +0 -97
  130. package/dist/foldFlowLines.js +0 -143
  131. package/dist/listTagNames.js +0 -33
  132. package/dist/schema/Alias.js +0 -105
  133. package/dist/schema/Collection.js +0 -184
  134. package/dist/schema/Map.js +0 -98
  135. package/dist/schema/Merge.js +0 -75
  136. package/dist/schema/Node.js +0 -7
  137. package/dist/schema/Pair.js +0 -174
  138. package/dist/schema/Scalar.js +0 -26
  139. package/dist/schema/Seq.js +0 -73
  140. package/dist/schema/index.js +0 -310
  141. package/dist/schema/parseMap.js +0 -334
  142. package/dist/schema/parseSeq.js +0 -175
  143. package/dist/schema/parseUtils.js +0 -101
  144. package/dist/stringify.js +0 -352
  145. package/dist/tags/core.js +0 -121
  146. package/dist/tags/failsafe/index.js +0 -12
  147. package/dist/tags/failsafe/map.js +0 -32
  148. package/dist/tags/failsafe/seq.js +0 -29
  149. package/dist/tags/failsafe/string.js +0 -37
  150. package/dist/tags/index.js +0 -53
  151. package/dist/tags/json.js +0 -64
  152. package/dist/tags/options.js +0 -36
  153. package/dist/tags/yaml-1.1/binary.js +0 -94
  154. package/dist/tags/yaml-1.1/index.js +0 -162
  155. package/dist/tags/yaml-1.1/omap.js +0 -100
  156. package/dist/tags/yaml-1.1/pairs.js +0 -75
  157. package/dist/tags/yaml-1.1/set.js +0 -82
  158. package/dist/tags/yaml-1.1/timestamp.js +0 -90
  159. package/dist/toJSON.js +0 -21
  160. package/dist/warnings.js +0 -48
@@ -0,0 +1,679 @@
1
+ import { _ as _createForOfIteratorHelper, h as _slicedToArray, a as _typeof, b as _createClass, e as _defineProperty, c as _classCallCheck, d as defaultTagPrefix, n as defaultTags } from './PlainValue-ff5147c6.js';
2
+ import { d as YAMLMap, g as resolveMap, Y as YAMLSeq, h as resolveSeq, j as resolveString, c as stringifyString, s as strOptions, S as Scalar, n as nullOptions, a as boolOptions, i as intOptions, k as stringifyNumber, N as Node, A as Alias, P as Pair } from './resolveSeq-04825f30.js';
3
+ import { b as binary, o as omap, p as pairs, s as set, i as intTime, f as floatTime, t as timestamp, a as warnOptionDeprecation } from './warnings-0e4b70d3.js';
4
+
5
+ function createMap(schema, obj, ctx) {
6
+ var map = new YAMLMap(schema);
7
+
8
+ if (obj instanceof Map) {
9
+ var _iterator = _createForOfIteratorHelper(obj),
10
+ _step;
11
+
12
+ try {
13
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
14
+ var _step$value = _slicedToArray(_step.value, 2),
15
+ key = _step$value[0],
16
+ value = _step$value[1];
17
+
18
+ map.items.push(schema.createPair(key, value, ctx));
19
+ }
20
+ } catch (err) {
21
+ _iterator.e(err);
22
+ } finally {
23
+ _iterator.f();
24
+ }
25
+ } else if (obj && _typeof(obj) === 'object') {
26
+ for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
27
+ var _key = _Object$keys[_i];
28
+ map.items.push(schema.createPair(_key, obj[_key], ctx));
29
+ }
30
+ }
31
+
32
+ if (typeof schema.sortMapEntries === 'function') {
33
+ map.items.sort(schema.sortMapEntries);
34
+ }
35
+
36
+ return map;
37
+ }
38
+
39
+ var map = {
40
+ createNode: createMap,
41
+ default: true,
42
+ nodeClass: YAMLMap,
43
+ tag: 'tag:yaml.org,2002:map',
44
+ resolve: resolveMap
45
+ };
46
+
47
+ function createSeq(schema, obj, ctx) {
48
+ var seq = new YAMLSeq(schema);
49
+
50
+ if (obj && obj[Symbol.iterator]) {
51
+ var _iterator = _createForOfIteratorHelper(obj),
52
+ _step;
53
+
54
+ try {
55
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
56
+ var it = _step.value;
57
+ var v = schema.createNode(it, ctx.wrapScalars, null, ctx);
58
+ seq.items.push(v);
59
+ }
60
+ } catch (err) {
61
+ _iterator.e(err);
62
+ } finally {
63
+ _iterator.f();
64
+ }
65
+ }
66
+
67
+ return seq;
68
+ }
69
+
70
+ var seq = {
71
+ createNode: createSeq,
72
+ default: true,
73
+ nodeClass: YAMLSeq,
74
+ tag: 'tag:yaml.org,2002:seq',
75
+ resolve: resolveSeq
76
+ };
77
+
78
+ var string = {
79
+ identify: function identify(value) {
80
+ return typeof value === 'string';
81
+ },
82
+ default: true,
83
+ tag: 'tag:yaml.org,2002:str',
84
+ resolve: resolveString,
85
+ stringify: function stringify(item, ctx, onComment, onChompKeep) {
86
+ ctx = Object.assign({
87
+ actualString: true
88
+ }, ctx);
89
+ return stringifyString(item, ctx, onComment, onChompKeep);
90
+ },
91
+ options: strOptions
92
+ };
93
+
94
+ var failsafe = [map, seq, string];
95
+
96
+ /* global BigInt */
97
+
98
+ var intIdentify = function intIdentify(value) {
99
+ return typeof value === 'bigint' || Number.isInteger(value);
100
+ };
101
+
102
+ var intResolve = function intResolve(src, part, radix) {
103
+ return intOptions.asBigInt ? BigInt(src) : parseInt(part, radix);
104
+ };
105
+
106
+ function intStringify(node, radix, prefix) {
107
+ var value = node.value;
108
+ if (intIdentify(value) && value >= 0) return prefix + value.toString(radix);
109
+ return stringifyNumber(node);
110
+ }
111
+
112
+ var nullObj = {
113
+ identify: function identify(value) {
114
+ return value == null;
115
+ },
116
+ createNode: function createNode(schema, value, ctx) {
117
+ return ctx.wrapScalars ? new Scalar(null) : null;
118
+ },
119
+ default: true,
120
+ tag: 'tag:yaml.org,2002:null',
121
+ test: /^(?:~|[Nn]ull|NULL)?$/,
122
+ resolve: function resolve() {
123
+ return null;
124
+ },
125
+ options: nullOptions,
126
+ stringify: function stringify() {
127
+ return nullOptions.nullStr;
128
+ }
129
+ };
130
+ var boolObj = {
131
+ identify: function identify(value) {
132
+ return typeof value === 'boolean';
133
+ },
134
+ default: true,
135
+ tag: 'tag:yaml.org,2002:bool',
136
+ test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
137
+ resolve: function resolve(str) {
138
+ return str[0] === 't' || str[0] === 'T';
139
+ },
140
+ options: boolOptions,
141
+ stringify: function stringify(_ref) {
142
+ var value = _ref.value;
143
+ return value ? boolOptions.trueStr : boolOptions.falseStr;
144
+ }
145
+ };
146
+ var octObj = {
147
+ identify: function identify(value) {
148
+ return intIdentify(value) && value >= 0;
149
+ },
150
+ default: true,
151
+ tag: 'tag:yaml.org,2002:int',
152
+ format: 'OCT',
153
+ test: /^0o([0-7]+)$/,
154
+ resolve: function resolve(str, oct) {
155
+ return intResolve(str, oct, 8);
156
+ },
157
+ options: intOptions,
158
+ stringify: function stringify(node) {
159
+ return intStringify(node, 8, '0o');
160
+ }
161
+ };
162
+ var intObj = {
163
+ identify: intIdentify,
164
+ default: true,
165
+ tag: 'tag:yaml.org,2002:int',
166
+ test: /^[-+]?[0-9]+$/,
167
+ resolve: function resolve(str) {
168
+ return intResolve(str, str, 10);
169
+ },
170
+ options: intOptions,
171
+ stringify: stringifyNumber
172
+ };
173
+ var hexObj = {
174
+ identify: function identify(value) {
175
+ return intIdentify(value) && value >= 0;
176
+ },
177
+ default: true,
178
+ tag: 'tag:yaml.org,2002:int',
179
+ format: 'HEX',
180
+ test: /^0x([0-9a-fA-F]+)$/,
181
+ resolve: function resolve(str, hex) {
182
+ return intResolve(str, hex, 16);
183
+ },
184
+ options: intOptions,
185
+ stringify: function stringify(node) {
186
+ return intStringify(node, 16, '0x');
187
+ }
188
+ };
189
+ var nanObj = {
190
+ identify: function identify(value) {
191
+ return typeof value === 'number';
192
+ },
193
+ default: true,
194
+ tag: 'tag:yaml.org,2002:float',
195
+ test: /^(?:[-+]?\.inf|(\.nan))$/i,
196
+ resolve: function resolve(str, nan) {
197
+ return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
198
+ },
199
+ stringify: stringifyNumber
200
+ };
201
+ var expObj = {
202
+ identify: function identify(value) {
203
+ return typeof value === 'number';
204
+ },
205
+ default: true,
206
+ tag: 'tag:yaml.org,2002:float',
207
+ format: 'EXP',
208
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
209
+ resolve: function resolve(str) {
210
+ return parseFloat(str);
211
+ },
212
+ stringify: function stringify(_ref2) {
213
+ var value = _ref2.value;
214
+ return Number(value).toExponential();
215
+ }
216
+ };
217
+ var floatObj = {
218
+ identify: function identify(value) {
219
+ return typeof value === 'number';
220
+ },
221
+ default: true,
222
+ tag: 'tag:yaml.org,2002:float',
223
+ test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
224
+ resolve: function resolve(str, frac1, frac2) {
225
+ var frac = frac1 || frac2;
226
+ var node = new Scalar(parseFloat(str));
227
+ if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
228
+ return node;
229
+ },
230
+ stringify: stringifyNumber
231
+ };
232
+ var core = failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);
233
+
234
+ /* global BigInt */
235
+
236
+ var intIdentify$1 = function intIdentify(value) {
237
+ return typeof value === 'bigint' || Number.isInteger(value);
238
+ };
239
+
240
+ var stringifyJSON = function stringifyJSON(_ref) {
241
+ var value = _ref.value;
242
+ return JSON.stringify(value);
243
+ };
244
+
245
+ var json = [map, seq, {
246
+ identify: function identify(value) {
247
+ return typeof value === 'string';
248
+ },
249
+ default: true,
250
+ tag: 'tag:yaml.org,2002:str',
251
+ resolve: resolveString,
252
+ stringify: stringifyJSON
253
+ }, {
254
+ identify: function identify(value) {
255
+ return value == null;
256
+ },
257
+ createNode: function createNode(schema, value, ctx) {
258
+ return ctx.wrapScalars ? new Scalar(null) : null;
259
+ },
260
+ default: true,
261
+ tag: 'tag:yaml.org,2002:null',
262
+ test: /^null$/,
263
+ resolve: function resolve() {
264
+ return null;
265
+ },
266
+ stringify: stringifyJSON
267
+ }, {
268
+ identify: function identify(value) {
269
+ return typeof value === 'boolean';
270
+ },
271
+ default: true,
272
+ tag: 'tag:yaml.org,2002:bool',
273
+ test: /^true|false$/,
274
+ resolve: function resolve(str) {
275
+ return str === 'true';
276
+ },
277
+ stringify: stringifyJSON
278
+ }, {
279
+ identify: intIdentify$1,
280
+ default: true,
281
+ tag: 'tag:yaml.org,2002:int',
282
+ test: /^-?(?:0|[1-9][0-9]*)$/,
283
+ resolve: function resolve(str) {
284
+ return intOptions.asBigInt ? BigInt(str) : parseInt(str, 10);
285
+ },
286
+ stringify: function stringify(_ref2) {
287
+ var value = _ref2.value;
288
+ return intIdentify$1(value) ? value.toString() : JSON.stringify(value);
289
+ }
290
+ }, {
291
+ identify: function identify(value) {
292
+ return typeof value === 'number';
293
+ },
294
+ default: true,
295
+ tag: 'tag:yaml.org,2002:float',
296
+ test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
297
+ resolve: function resolve(str) {
298
+ return parseFloat(str);
299
+ },
300
+ stringify: stringifyJSON
301
+ }];
302
+
303
+ json.scalarFallback = function (str) {
304
+ throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(str)));
305
+ };
306
+
307
+ /* global BigInt */
308
+
309
+ var boolStringify = function boolStringify(_ref) {
310
+ var value = _ref.value;
311
+ return value ? boolOptions.trueStr : boolOptions.falseStr;
312
+ };
313
+
314
+ var intIdentify$2 = function intIdentify(value) {
315
+ return typeof value === 'bigint' || Number.isInteger(value);
316
+ };
317
+
318
+ function intResolve$1(sign, src, radix) {
319
+ var str = src.replace(/_/g, '');
320
+
321
+ if (intOptions.asBigInt) {
322
+ switch (radix) {
323
+ case 2:
324
+ str = "0b".concat(str);
325
+ break;
326
+
327
+ case 8:
328
+ str = "0o".concat(str);
329
+ break;
330
+
331
+ case 16:
332
+ str = "0x".concat(str);
333
+ break;
334
+ }
335
+
336
+ var _n = BigInt(str);
337
+
338
+ return sign === '-' ? BigInt(-1) * _n : _n;
339
+ }
340
+
341
+ var n = parseInt(str, radix);
342
+ return sign === '-' ? -1 * n : n;
343
+ }
344
+
345
+ function intStringify$1(node, radix, prefix) {
346
+ var value = node.value;
347
+
348
+ if (intIdentify$2(value)) {
349
+ var str = value.toString(radix);
350
+ return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
351
+ }
352
+
353
+ return stringifyNumber(node);
354
+ }
355
+
356
+ var yaml11 = failsafe.concat([{
357
+ identify: function identify(value) {
358
+ return value == null;
359
+ },
360
+ createNode: function createNode(schema, value, ctx) {
361
+ return ctx.wrapScalars ? new Scalar(null) : null;
362
+ },
363
+ default: true,
364
+ tag: 'tag:yaml.org,2002:null',
365
+ test: /^(?:~|[Nn]ull|NULL)?$/,
366
+ resolve: function resolve() {
367
+ return null;
368
+ },
369
+ options: nullOptions,
370
+ stringify: function stringify() {
371
+ return nullOptions.nullStr;
372
+ }
373
+ }, {
374
+ identify: function identify(value) {
375
+ return typeof value === 'boolean';
376
+ },
377
+ default: true,
378
+ tag: 'tag:yaml.org,2002:bool',
379
+ test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
380
+ resolve: function resolve() {
381
+ return true;
382
+ },
383
+ options: boolOptions,
384
+ stringify: boolStringify
385
+ }, {
386
+ identify: function identify(value) {
387
+ return typeof value === 'boolean';
388
+ },
389
+ default: true,
390
+ tag: 'tag:yaml.org,2002:bool',
391
+ test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
392
+ resolve: function resolve() {
393
+ return false;
394
+ },
395
+ options: boolOptions,
396
+ stringify: boolStringify
397
+ }, {
398
+ identify: intIdentify$2,
399
+ default: true,
400
+ tag: 'tag:yaml.org,2002:int',
401
+ format: 'BIN',
402
+ test: /^([-+]?)0b([0-1_]+)$/,
403
+ resolve: function resolve(str, sign, bin) {
404
+ return intResolve$1(sign, bin, 2);
405
+ },
406
+ stringify: function stringify(node) {
407
+ return intStringify$1(node, 2, '0b');
408
+ }
409
+ }, {
410
+ identify: intIdentify$2,
411
+ default: true,
412
+ tag: 'tag:yaml.org,2002:int',
413
+ format: 'OCT',
414
+ test: /^([-+]?)0([0-7_]+)$/,
415
+ resolve: function resolve(str, sign, oct) {
416
+ return intResolve$1(sign, oct, 8);
417
+ },
418
+ stringify: function stringify(node) {
419
+ return intStringify$1(node, 8, '0');
420
+ }
421
+ }, {
422
+ identify: intIdentify$2,
423
+ default: true,
424
+ tag: 'tag:yaml.org,2002:int',
425
+ test: /^([-+]?)([0-9][0-9_]*)$/,
426
+ resolve: function resolve(str, sign, abs) {
427
+ return intResolve$1(sign, abs, 10);
428
+ },
429
+ stringify: stringifyNumber
430
+ }, {
431
+ identify: intIdentify$2,
432
+ default: true,
433
+ tag: 'tag:yaml.org,2002:int',
434
+ format: 'HEX',
435
+ test: /^([-+]?)0x([0-9a-fA-F_]+)$/,
436
+ resolve: function resolve(str, sign, hex) {
437
+ return intResolve$1(sign, hex, 16);
438
+ },
439
+ stringify: function stringify(node) {
440
+ return intStringify$1(node, 16, '0x');
441
+ }
442
+ }, {
443
+ identify: function identify(value) {
444
+ return typeof value === 'number';
445
+ },
446
+ default: true,
447
+ tag: 'tag:yaml.org,2002:float',
448
+ test: /^(?:[-+]?\.inf|(\.nan))$/i,
449
+ resolve: function resolve(str, nan) {
450
+ return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
451
+ },
452
+ stringify: stringifyNumber
453
+ }, {
454
+ identify: function identify(value) {
455
+ return typeof value === 'number';
456
+ },
457
+ default: true,
458
+ tag: 'tag:yaml.org,2002:float',
459
+ format: 'EXP',
460
+ test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
461
+ resolve: function resolve(str) {
462
+ return parseFloat(str.replace(/_/g, ''));
463
+ },
464
+ stringify: function stringify(_ref2) {
465
+ var value = _ref2.value;
466
+ return Number(value).toExponential();
467
+ }
468
+ }, {
469
+ identify: function identify(value) {
470
+ return typeof value === 'number';
471
+ },
472
+ default: true,
473
+ tag: 'tag:yaml.org,2002:float',
474
+ test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
475
+ resolve: function resolve(str, frac) {
476
+ var node = new Scalar(parseFloat(str.replace(/_/g, '')));
477
+
478
+ if (frac) {
479
+ var f = frac.replace(/_/g, '');
480
+ if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
481
+ }
482
+
483
+ return node;
484
+ },
485
+ stringify: stringifyNumber
486
+ }], binary, omap, pairs, set, intTime, floatTime, timestamp);
487
+
488
+ var schemas = {
489
+ core: core,
490
+ failsafe: failsafe,
491
+ json: json,
492
+ yaml11: yaml11
493
+ };
494
+ var tags = {
495
+ binary: binary,
496
+ bool: boolObj,
497
+ float: floatObj,
498
+ floatExp: expObj,
499
+ floatNaN: nanObj,
500
+ floatTime: floatTime,
501
+ int: intObj,
502
+ intHex: hexObj,
503
+ intOct: octObj,
504
+ intTime: intTime,
505
+ map: map,
506
+ null: nullObj,
507
+ omap: omap,
508
+ pairs: pairs,
509
+ seq: seq,
510
+ set: set,
511
+ timestamp: timestamp
512
+ };
513
+
514
+ function findTagObject(value, tagName, tags) {
515
+ if (tagName) {
516
+ var match = tags.filter(function (t) {
517
+ return t.tag === tagName;
518
+ });
519
+ var tagObj = match.find(function (t) {
520
+ return !t.format;
521
+ }) || match[0];
522
+ if (!tagObj) throw new Error("Tag ".concat(tagName, " not found"));
523
+ return tagObj;
524
+ } // TODO: deprecate/remove class check
525
+
526
+
527
+ return tags.find(function (t) {
528
+ return (t.identify && t.identify(value) || t.class && value instanceof t.class) && !t.format;
529
+ });
530
+ }
531
+
532
+ function createNode(value, tagName, ctx) {
533
+ if (value instanceof Node) return value;
534
+ var defaultPrefix = ctx.defaultPrefix,
535
+ onTagObj = ctx.onTagObj,
536
+ prevObjects = ctx.prevObjects,
537
+ schema = ctx.schema,
538
+ wrapScalars = ctx.wrapScalars;
539
+ if (tagName && tagName.startsWith('!!')) tagName = defaultPrefix + tagName.slice(2);
540
+ var tagObj = findTagObject(value, tagName, schema.tags);
541
+
542
+ if (!tagObj) {
543
+ if (typeof value.toJSON === 'function') value = value.toJSON();
544
+ if (_typeof(value) !== 'object') return wrapScalars ? new Scalar(value) : value;
545
+ tagObj = value instanceof Map ? map : value[Symbol.iterator] ? seq : map;
546
+ }
547
+
548
+ if (onTagObj) {
549
+ onTagObj(tagObj);
550
+ delete ctx.onTagObj;
551
+ } // Detect duplicate references to the same object & use Alias nodes for all
552
+ // after first. The `obj` wrapper allows for circular references to resolve.
553
+
554
+
555
+ var obj = {};
556
+
557
+ if (value && _typeof(value) === 'object' && prevObjects) {
558
+ var prev = prevObjects.get(value);
559
+
560
+ if (prev) {
561
+ var alias = new Alias(prev); // leaves source dirty; must be cleaned by caller
562
+
563
+ ctx.aliasNodes.push(alias); // defined along with prevObjects
564
+
565
+ return alias;
566
+ }
567
+
568
+ obj.value = value;
569
+ prevObjects.set(value, obj);
570
+ }
571
+
572
+ obj.node = tagObj.createNode ? tagObj.createNode(ctx.schema, value, ctx) : wrapScalars ? new Scalar(value) : value;
573
+ if (tagName && obj.node instanceof Node) obj.node.tag = tagName;
574
+ return obj.node;
575
+ }
576
+
577
+ function getSchemaTags(schemas, knownTags, customTags, schemaId) {
578
+ var tags = schemas[schemaId.replace(/\W/g, '')]; // 'yaml-1.1' -> 'yaml11'
579
+
580
+ if (!tags) {
581
+ var keys = Object.keys(schemas).map(function (key) {
582
+ return JSON.stringify(key);
583
+ }).join(', ');
584
+ throw new Error("Unknown schema \"".concat(schemaId, "\"; use one of ").concat(keys));
585
+ }
586
+
587
+ if (Array.isArray(customTags)) {
588
+ var _iterator = _createForOfIteratorHelper(customTags),
589
+ _step;
590
+
591
+ try {
592
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
593
+ var tag = _step.value;
594
+ tags = tags.concat(tag);
595
+ }
596
+ } catch (err) {
597
+ _iterator.e(err);
598
+ } finally {
599
+ _iterator.f();
600
+ }
601
+ } else if (typeof customTags === 'function') {
602
+ tags = customTags(tags.slice());
603
+ }
604
+
605
+ for (var i = 0; i < tags.length; ++i) {
606
+ var _tag = tags[i];
607
+
608
+ if (typeof _tag === 'string') {
609
+ var tagObj = knownTags[_tag];
610
+
611
+ if (!tagObj) {
612
+ var _keys = Object.keys(knownTags).map(function (key) {
613
+ return JSON.stringify(key);
614
+ }).join(', ');
615
+
616
+ throw new Error("Unknown custom tag \"".concat(_tag, "\"; use one of ").concat(_keys));
617
+ }
618
+
619
+ tags[i] = tagObj;
620
+ }
621
+ }
622
+
623
+ return tags;
624
+ }
625
+
626
+ var sortMapEntriesByKey = function sortMapEntriesByKey(a, b) {
627
+ return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
628
+ };
629
+
630
+ var Schema = /*#__PURE__*/function () {
631
+ // TODO: remove in v2
632
+ // TODO: remove in v2
633
+ function Schema(_ref) {
634
+ var customTags = _ref.customTags,
635
+ merge = _ref.merge,
636
+ schema = _ref.schema,
637
+ sortMapEntries = _ref.sortMapEntries,
638
+ deprecatedCustomTags = _ref.tags;
639
+
640
+ _classCallCheck(this, Schema);
641
+
642
+ this.merge = !!merge;
643
+ this.name = schema;
644
+ this.sortMapEntries = sortMapEntries === true ? sortMapEntriesByKey : sortMapEntries || null;
645
+ if (!customTags && deprecatedCustomTags) warnOptionDeprecation('tags', 'customTags');
646
+ this.tags = getSchemaTags(schemas, tags, customTags || deprecatedCustomTags, schema);
647
+ }
648
+
649
+ _createClass(Schema, [{
650
+ key: "createNode",
651
+ value: function createNode$1(value, wrapScalars, tagName, ctx) {
652
+ var baseCtx = {
653
+ defaultPrefix: Schema.defaultPrefix,
654
+ schema: this,
655
+ wrapScalars: wrapScalars
656
+ };
657
+ var createCtx = ctx ? Object.assign(ctx, baseCtx) : baseCtx;
658
+ return createNode(value, tagName, createCtx);
659
+ }
660
+ }, {
661
+ key: "createPair",
662
+ value: function createPair(key, value, ctx) {
663
+ if (!ctx) ctx = {
664
+ wrapScalars: true
665
+ };
666
+ var k = this.createNode(key, ctx.wrapScalars, null, ctx);
667
+ var v = this.createNode(value, ctx.wrapScalars, null, ctx);
668
+ return new Pair(k, v);
669
+ }
670
+ }]);
671
+
672
+ return Schema;
673
+ }();
674
+
675
+ _defineProperty(Schema, "defaultPrefix", defaultTagPrefix);
676
+
677
+ _defineProperty(Schema, "defaultTags", defaultTags);
678
+
679
+ export { Schema as S };