yaml 2.0.0-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.
@@ -1,9 +1,118 @@
1
- import { e as _createForOfIteratorHelper, h as _slicedToArray, _ as _typeof, p as YAMLReferenceError, T as Type, g as YAMLSemanticError, c as _defineProperty, j as _inherits, k as _createSuper, b as _classCallCheck, n as _assertThisInitialized, a as _createClass, l as _get, m as _getPrototypeOf } from './PlainValue-6b68dc0e.js';
2
- import { d as YAMLMap, j as resolveMap, k as createPair, Y as YAMLSeq, l as resolveSeq, e as createNode, m as resolveString, c as stringifyString, s as strOptions, S as Scalar, n as nullOptions, a as boolOptions, i as intOptions, o as stringifyNumber, b as binaryOptions, P as Pair, t as toJSON, p as findPair } from './resolveSeq-3477c430.js';
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);
3
105
 
4
106
  function createMap(schema, obj, ctx) {
107
+ var keepUndefined = ctx.keepUndefined,
108
+ replacer = ctx.replacer;
5
109
  var map = new YAMLMap(schema);
6
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
+
7
116
  if (obj instanceof Map) {
8
117
  var _iterator = _createForOfIteratorHelper(obj),
9
118
  _step;
@@ -14,7 +123,7 @@ function createMap(schema, obj, ctx) {
14
123
  key = _step$value[0],
15
124
  value = _step$value[1];
16
125
 
17
- map.items.push(createPair(key, value, ctx));
126
+ add(key, value);
18
127
  }
19
128
  } catch (err) {
20
129
  _iterator.e(err);
@@ -24,8 +133,7 @@ function createMap(schema, obj, ctx) {
24
133
  } else if (obj && _typeof(obj) === 'object') {
25
134
  for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
26
135
  var _key = _Object$keys[_i];
27
- var _value = obj[_key];
28
- if (_value !== undefined) map.items.push(createPair(_key, _value, ctx));
136
+ add(_key, obj[_key]);
29
137
  }
30
138
  }
31
139
 
@@ -41,19 +149,30 @@ var map = {
41
149
  default: true,
42
150
  nodeClass: YAMLMap,
43
151
  tag: 'tag:yaml.org,2002:map',
44
- resolve: resolveMap
152
+ resolve: function resolve(map) {
153
+ return map;
154
+ }
45
155
  };
46
156
 
47
157
  function createSeq(schema, obj, ctx) {
158
+ var replacer = ctx.replacer;
48
159
  var seq = new YAMLSeq(schema);
49
160
 
50
161
  if (obj && obj[Symbol.iterator]) {
162
+ var i = 0;
163
+
51
164
  var _iterator = _createForOfIteratorHelper(obj),
52
165
  _step;
53
166
 
54
167
  try {
55
168
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
56
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
+
57
176
  seq.items.push(createNode(it, null, ctx));
58
177
  }
59
178
  } catch (err) {
@@ -71,7 +190,9 @@ var seq = {
71
190
  default: true,
72
191
  nodeClass: YAMLSeq,
73
192
  tag: 'tag:yaml.org,2002:seq',
74
- resolve: resolveSeq
193
+ resolve: function resolve(seq) {
194
+ return seq;
195
+ }
75
196
  };
76
197
 
77
198
  var string = {
@@ -80,7 +201,9 @@ var string = {
80
201
  },
81
202
  default: true,
82
203
  tag: 'tag:yaml.org,2002:str',
83
- resolve: resolveString,
204
+ resolve: function resolve(str) {
205
+ return str;
206
+ },
84
207
  stringify: function stringify(item, ctx, onComment, onChompKeep) {
85
208
  ctx = Object.assign({
86
209
  actualString: true
@@ -98,8 +221,8 @@ var intIdentify = function intIdentify(value) {
98
221
  return typeof value === 'bigint' || Number.isInteger(value);
99
222
  };
100
223
 
101
- var intResolve = function intResolve(src, part, radix) {
102
- return intOptions.asBigInt ? BigInt(src) : parseInt(part, radix);
224
+ var intResolve = function intResolve(src, offset, radix) {
225
+ return intOptions.asBigInt ? BigInt(src) : parseInt(src.substring(offset), radix);
103
226
  };
104
227
 
105
228
  function intStringify(node, radix, prefix) {
@@ -118,12 +241,15 @@ var nullObj = {
118
241
  default: true,
119
242
  tag: 'tag:yaml.org,2002:null',
120
243
  test: /^(?:~|[Nn]ull|NULL)?$/,
121
- resolve: function resolve() {
122
- return null;
244
+ resolve: function resolve(str) {
245
+ var node = new Scalar(null);
246
+ node.sourceStr = str;
247
+ return node;
123
248
  },
124
249
  options: nullOptions,
125
- stringify: function stringify() {
126
- return nullOptions.nullStr;
250
+ stringify: function stringify(_ref) {
251
+ var sourceStr = _ref.sourceStr;
252
+ return sourceStr !== null && sourceStr !== void 0 ? sourceStr : nullOptions.nullStr;
127
253
  }
128
254
  };
129
255
  var boolObj = {
@@ -137,8 +263,8 @@ var boolObj = {
137
263
  return str[0] === 't' || str[0] === 'T';
138
264
  },
139
265
  options: boolOptions,
140
- stringify: function stringify(_ref) {
141
- var value = _ref.value;
266
+ stringify: function stringify(_ref2) {
267
+ var value = _ref2.value;
142
268
  return value ? boolOptions.trueStr : boolOptions.falseStr;
143
269
  }
144
270
  };
@@ -149,9 +275,9 @@ var octObj = {
149
275
  default: true,
150
276
  tag: 'tag:yaml.org,2002:int',
151
277
  format: 'OCT',
152
- test: /^0o([0-7]+)$/,
153
- resolve: function resolve(str, oct) {
154
- return intResolve(str, oct, 8);
278
+ test: /^0o[0-7]+$/,
279
+ resolve: function resolve(str) {
280
+ return intResolve(str, 2, 8);
155
281
  },
156
282
  options: intOptions,
157
283
  stringify: function stringify(node) {
@@ -164,7 +290,7 @@ var intObj = {
164
290
  tag: 'tag:yaml.org,2002:int',
165
291
  test: /^[-+]?[0-9]+$/,
166
292
  resolve: function resolve(str) {
167
- return intResolve(str, str, 10);
293
+ return intResolve(str, 0, 10);
168
294
  },
169
295
  options: intOptions,
170
296
  stringify: stringifyNumber
@@ -176,9 +302,9 @@ var hexObj = {
176
302
  default: true,
177
303
  tag: 'tag:yaml.org,2002:int',
178
304
  format: 'HEX',
179
- test: /^0x([0-9a-fA-F]+)$/,
180
- resolve: function resolve(str, hex) {
181
- return intResolve(str, hex, 16);
305
+ test: /^0x[0-9a-fA-F]+$/,
306
+ resolve: function resolve(str) {
307
+ return intResolve(str, 2, 16);
182
308
  },
183
309
  options: intOptions,
184
310
  stringify: function stringify(node) {
@@ -191,9 +317,9 @@ var nanObj = {
191
317
  },
192
318
  default: true,
193
319
  tag: 'tag:yaml.org,2002:float',
194
- test: /^(?:[-+]?\.inf|(\.nan))$/i,
195
- resolve: function resolve(str, nan) {
196
- return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
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;
197
323
  },
198
324
  stringify: stringifyNumber
199
325
  };
@@ -208,8 +334,8 @@ var expObj = {
208
334
  resolve: function resolve(str) {
209
335
  return parseFloat(str);
210
336
  },
211
- stringify: function stringify(_ref2) {
212
- var value = _ref2.value;
337
+ stringify: function stringify(_ref3) {
338
+ var value = _ref3.value;
213
339
  return Number(value).toExponential();
214
340
  }
215
341
  };
@@ -219,11 +345,11 @@ var floatObj = {
219
345
  },
220
346
  default: true,
221
347
  tag: 'tag:yaml.org,2002:float',
222
- test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
223
- resolve: function resolve(str, frac1, frac2) {
224
- var frac = frac1 || frac2;
348
+ test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
349
+ resolve: function resolve(str) {
225
350
  var node = new Scalar(parseFloat(str));
226
- if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
351
+ var dot = str.indexOf('.');
352
+ if (dot !== -1 && str[str.length - 1] === '0') node.minFractionDigits = str.length - dot - 1;
227
353
  return node;
228
354
  },
229
355
  stringify: stringifyNumber
@@ -247,7 +373,9 @@ var json = [map, seq, {
247
373
  },
248
374
  default: true,
249
375
  tag: 'tag:yaml.org,2002:str',
250
- resolve: resolveString,
376
+ resolve: function resolve(str) {
377
+ return str;
378
+ },
251
379
  stringify: stringifyJSON
252
380
  }, {
253
381
  identify: function identify(value) {
@@ -297,12 +425,15 @@ var json = [map, seq, {
297
425
  return parseFloat(str);
298
426
  },
299
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
+ }
300
435
  }];
301
436
 
302
- json.scalarFallback = function (str) {
303
- throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(str)));
304
- };
305
-
306
437
  /* global atob, btoa, Buffer */
307
438
  var binary = {
308
439
  identify: function identify(value) {
@@ -320,9 +451,7 @@ var binary = {
320
451
  * const blob = new Blob([buffer], { type: 'image/jpeg' })
321
452
  * document.querySelector('#photo').src = URL.createObjectURL(blob)
322
453
  */
323
- resolve: function resolve(doc, node) {
324
- var src = resolveString(doc, node);
325
-
454
+ resolve: function resolve(src, onError) {
326
455
  if (typeof Buffer === 'function') {
327
456
  return Buffer.from(src, 'base64');
328
457
  } else if (typeof atob === 'function') {
@@ -336,9 +465,8 @@ var binary = {
336
465
 
337
466
  return buffer;
338
467
  } else {
339
- var msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
340
- doc.errors.push(new YAMLReferenceError(node, msg));
341
- return null;
468
+ onError('This environment does not support reading binary tags; either Buffer or atob is required');
469
+ return src;
342
470
  }
343
471
  },
344
472
  options: binaryOptions,
@@ -386,30 +514,28 @@ var binary = {
386
514
  }
387
515
  };
388
516
 
389
- function parsePairs(doc, cst) {
390
- var seq = resolveSeq(doc, cst);
391
-
392
- for (var i = 0; i < seq.items.length; ++i) {
393
- var item = seq.items[i];
394
- if (item instanceof Pair) continue;else if (item instanceof YAMLMap) {
395
- if (item.items.length > 1) {
396
- var msg = 'Each pair must have its own sequence indicator';
397
- throw new YAMLSemanticError(cst, msg);
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;
398
527
  }
399
-
400
- var pair = item.items[0] || new Pair();
401
- if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore;
402
- if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment;
403
- item = pair;
528
+ seq.items[i] = item instanceof Pair ? item : new Pair(item);
404
529
  }
405
- seq.items[i] = item instanceof Pair ? item : new Pair(item);
406
- }
530
+ } else onError('Expected a sequence for this tag');
407
531
 
408
532
  return seq;
409
533
  }
410
534
  function createPairs(schema, iterable, ctx) {
535
+ var replacer = ctx.replacer;
411
536
  var pairs = new YAMLSeq(schema);
412
537
  pairs.tag = 'tag:yaml.org,2002:pairs';
538
+ var i = 0;
413
539
 
414
540
  var _iterator = _createForOfIteratorHelper(iterable),
415
541
  _step;
@@ -417,6 +543,7 @@ function createPairs(schema, iterable, ctx) {
417
543
  try {
418
544
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
419
545
  var it = _step.value;
546
+ if (typeof replacer === 'function') it = replacer.call(iterable, String(i++), it);
420
547
  var key = void 0,
421
548
  value = void 0;
422
549
 
@@ -481,7 +608,7 @@ var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
481
608
 
482
609
  _createClass(YAMLOMap, [{
483
610
  key: "toJSON",
484
- value: function toJSON$1(_, ctx) {
611
+ value: function toJSON(_, ctx) {
485
612
  var map = new Map();
486
613
  if (ctx && ctx.onCreate) ctx.onCreate(map);
487
614
 
@@ -495,10 +622,10 @@ var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
495
622
  value = void 0;
496
623
 
497
624
  if (pair instanceof Pair) {
498
- key = toJSON(pair.key, '', ctx);
499
- value = toJSON(pair.value, key, ctx);
625
+ key = toJS(pair.key, '', ctx);
626
+ value = toJS(pair.value, key, ctx);
500
627
  } else {
501
- key = toJSON(pair, '', ctx);
628
+ key = toJS(pair, '', ctx);
502
629
  }
503
630
 
504
631
  if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
@@ -519,8 +646,8 @@ var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
519
646
 
520
647
  _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
521
648
 
522
- function parseOMap(doc, cst) {
523
- var pairs = parsePairs(doc, cst);
649
+ function parseOMap(seq, onError) {
650
+ var pairs = parsePairs(seq, onError);
524
651
  var seenKeys = [];
525
652
 
526
653
  var _iterator2 = _createForOfIteratorHelper(pairs.items),
@@ -532,8 +659,7 @@ function parseOMap(doc, cst) {
532
659
 
533
660
  if (key instanceof Scalar) {
534
661
  if (seenKeys.includes(key.value)) {
535
- var msg = 'Ordered maps must not include duplicate keys';
536
- throw new YAMLSemanticError(cst, msg);
662
+ onError("Ordered maps must not include duplicate keys: ".concat(key.value));
537
663
  } else {
538
664
  seenKeys.push(key.value);
539
665
  }
@@ -571,12 +697,12 @@ var YAMLSet = /*#__PURE__*/function (_YAMLMap) {
571
697
 
572
698
  var _super = _createSuper(YAMLSet);
573
699
 
574
- function YAMLSet() {
700
+ function YAMLSet(schema) {
575
701
  var _this;
576
702
 
577
703
  _classCallCheck(this, YAMLSet);
578
704
 
579
- _this = _super.call(this);
705
+ _this = _super.call(this, schema);
580
706
  _this.tag = YAMLSet.tag;
581
707
  return _this;
582
708
  }
@@ -624,14 +750,17 @@ var YAMLSet = /*#__PURE__*/function (_YAMLMap) {
624
750
 
625
751
  _defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
626
752
 
627
- function parseSet(doc, cst) {
628
- var map = resolveMap(doc, cst);
629
- if (!map.hasAllNullValues()) throw new YAMLSemanticError(cst, 'Set items must all have null values');
630
- return Object.assign(new YAMLSet(), map);
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;
631
759
  }
632
760
 
633
761
  function createSet(schema, iterable, ctx) {
634
- var set = new YAMLSet();
762
+ var replacer = ctx.replacer;
763
+ var set = new YAMLSet(schema);
635
764
 
636
765
  var _iterator = _createForOfIteratorHelper(iterable),
637
766
  _step;
@@ -639,6 +768,7 @@ function createSet(schema, iterable, ctx) {
639
768
  try {
640
769
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
641
770
  var value = _step.value;
771
+ if (typeof replacer === 'function') value = replacer.call(iterable, value, value);
642
772
  set.items.push(createPair(value, null, ctx));
643
773
  }
644
774
  } catch (err) {
@@ -661,34 +791,50 @@ var set = {
661
791
  createNode: createSet
662
792
  };
663
793
 
664
- var parseSexagesimal = function parseSexagesimal(sign, parts) {
665
- var n = parts.split(':').reduce(function (n, p) {
666
- return n * 60 + Number(p);
667
- }, 0);
668
- return sign === '-' ? -n : n;
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;
669
806
  }; // hhhh:mm:ss.sss
670
807
 
671
808
 
672
809
  var stringifySexagesimal = function stringifySexagesimal(_ref) {
673
810
  var value = _ref.value;
674
- if (isNaN(value) || !isFinite(value)) return stringifyNumber(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);
675
819
  var sign = '';
676
820
 
677
821
  if (value < 0) {
678
822
  sign = '-';
679
- value = Math.abs(value);
823
+ value *= num(-1);
680
824
  }
681
825
 
682
- var parts = [value % 60]; // seconds, including ms
826
+ var _60 = num(60);
827
+
828
+ var parts = [value % _60]; // seconds, including ms
683
829
 
684
830
  if (value < 60) {
685
831
  parts.unshift(0); // at least one : is required
686
832
  } else {
687
- value = Math.round((value - parts[0]) / 60);
688
- parts.unshift(value % 60); // minutes
833
+ value = (value - parts[0]) / _60;
834
+ parts.unshift(value % _60); // minutes
689
835
 
690
836
  if (value >= 60) {
691
- value = Math.round((value - parts[0]) / 60);
837
+ value = (value - parts[0]) / _60;
692
838
  parts.unshift(value); // hours
693
839
  }
694
840
  }
@@ -701,14 +847,14 @@ var stringifySexagesimal = function stringifySexagesimal(_ref) {
701
847
 
702
848
  var intTime = {
703
849
  identify: function identify(value) {
704
- return typeof value === 'number';
850
+ return typeof value === 'bigint' || Number.isInteger(value);
705
851
  },
706
852
  default: true,
707
853
  tag: 'tag:yaml.org,2002:int',
708
854
  format: 'TIME',
709
- test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,
710
- resolve: function resolve(str, sign, parts) {
711
- return parseSexagesimal(sign, parts.replace(/_/g, ''));
855
+ test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
856
+ resolve: function resolve(str) {
857
+ return parseSexagesimal(str, true);
712
858
  },
713
859
  stringify: stringifySexagesimal
714
860
  };
@@ -719,9 +865,9 @@ var floatTime = {
719
865
  default: true,
720
866
  tag: 'tag:yaml.org,2002:float',
721
867
  format: 'TIME',
722
- test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,
723
- resolve: function resolve(str, sign, parts) {
724
- return parseSexagesimal(sign, parts.replace(/_/g, ''));
868
+ test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
869
+ resolve: function resolve(str) {
870
+ return parseSexagesimal(str, false);
725
871
  },
726
872
  stringify: stringifySexagesimal
727
873
  };
@@ -734,17 +880,29 @@ var timestamp = {
734
880
  // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
735
881
  // may be omitted altogether, resulting in a date format. In such a case, the time part is
736
882
  // assumed to be 00:00:00Z (start of day, UTC).
737
- test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd
738
- '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace
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
739
886
  '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)?
740
887
  '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
741
- ')?' + ')$'),
742
- resolve: function resolve(str, year, month, day, hour, minute, second, millisec, tz) {
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
+
743
901
  if (millisec) millisec = (millisec + '00').substr(1, 3);
744
902
  var date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0);
745
903
 
746
904
  if (tz && tz !== 'Z') {
747
- var d = parseSexagesimal(tz[0], tz.slice(1));
905
+ var d = parseSexagesimal(tz, false);
748
906
  if (Math.abs(d) < 30) d *= 60;
749
907
  date -= 60000 * d;
750
908
  }
@@ -768,8 +926,10 @@ var intIdentify$2 = function intIdentify(value) {
768
926
  return typeof value === 'bigint' || Number.isInteger(value);
769
927
  };
770
928
 
771
- function intResolve$1(sign, src, radix) {
772
- var str = src.replace(/_/g, '');
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, '');
773
933
 
774
934
  if (intOptions.asBigInt) {
775
935
  switch (radix) {
@@ -816,12 +976,15 @@ var yaml11 = failsafe.concat([{
816
976
  default: true,
817
977
  tag: 'tag:yaml.org,2002:null',
818
978
  test: /^(?:~|[Nn]ull|NULL)?$/,
819
- resolve: function resolve() {
820
- return null;
979
+ resolve: function resolve(str) {
980
+ var node = new Scalar(null);
981
+ node.sourceStr = str;
982
+ return node;
821
983
  },
822
984
  options: nullOptions,
823
- stringify: function stringify() {
824
- return nullOptions.nullStr;
985
+ stringify: function stringify(_ref2) {
986
+ var sourceStr = _ref2.sourceStr;
987
+ return sourceStr !== null && sourceStr !== void 0 ? sourceStr : nullOptions.nullStr;
825
988
  }
826
989
  }, {
827
990
  identify: function identify(value) {
@@ -841,7 +1004,7 @@ var yaml11 = failsafe.concat([{
841
1004
  },
842
1005
  default: true,
843
1006
  tag: 'tag:yaml.org,2002:bool',
844
- test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
1007
+ test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
845
1008
  resolve: function resolve() {
846
1009
  return false;
847
1010
  },
@@ -852,9 +1015,9 @@ var yaml11 = failsafe.concat([{
852
1015
  default: true,
853
1016
  tag: 'tag:yaml.org,2002:int',
854
1017
  format: 'BIN',
855
- test: /^([-+]?)0b([0-1_]+)$/,
856
- resolve: function resolve(str, sign, bin) {
857
- return intResolve$1(sign, bin, 2);
1018
+ test: /^[-+]?0b[0-1_]+$/,
1019
+ resolve: function resolve(str) {
1020
+ return intResolve$1(str, 2, 2);
858
1021
  },
859
1022
  stringify: function stringify(node) {
860
1023
  return intStringify$1(node, 2, '0b');
@@ -864,9 +1027,9 @@ var yaml11 = failsafe.concat([{
864
1027
  default: true,
865
1028
  tag: 'tag:yaml.org,2002:int',
866
1029
  format: 'OCT',
867
- test: /^([-+]?)0([0-7_]+)$/,
868
- resolve: function resolve(str, sign, oct) {
869
- return intResolve$1(sign, oct, 8);
1030
+ test: /^[-+]?0[0-7_]+$/,
1031
+ resolve: function resolve(str) {
1032
+ return intResolve$1(str, 1, 8);
870
1033
  },
871
1034
  stringify: function stringify(node) {
872
1035
  return intStringify$1(node, 8, '0');
@@ -875,9 +1038,9 @@ var yaml11 = failsafe.concat([{
875
1038
  identify: intIdentify$2,
876
1039
  default: true,
877
1040
  tag: 'tag:yaml.org,2002:int',
878
- test: /^([-+]?)([0-9][0-9_]*)$/,
879
- resolve: function resolve(str, sign, abs) {
880
- return intResolve$1(sign, abs, 10);
1041
+ test: /^[-+]?[0-9][0-9_]*$/,
1042
+ resolve: function resolve(str) {
1043
+ return intResolve$1(str, 0, 10);
881
1044
  },
882
1045
  stringify: stringifyNumber
883
1046
  }, {
@@ -885,9 +1048,9 @@ var yaml11 = failsafe.concat([{
885
1048
  default: true,
886
1049
  tag: 'tag:yaml.org,2002:int',
887
1050
  format: 'HEX',
888
- test: /^([-+]?)0x([0-9a-fA-F_]+)$/,
889
- resolve: function resolve(str, sign, hex) {
890
- return intResolve$1(sign, hex, 16);
1051
+ test: /^[-+]?0x[0-9a-fA-F_]+$/,
1052
+ resolve: function resolve(str) {
1053
+ return intResolve$1(str, 2, 16);
891
1054
  },
892
1055
  stringify: function stringify(node) {
893
1056
  return intStringify$1(node, 16, '0x');
@@ -898,9 +1061,9 @@ var yaml11 = failsafe.concat([{
898
1061
  },
899
1062
  default: true,
900
1063
  tag: 'tag:yaml.org,2002:float',
901
- test: /^(?:[-+]?\.inf|(\.nan))$/i,
902
- resolve: function resolve(str, nan) {
903
- return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
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;
904
1067
  },
905
1068
  stringify: stringifyNumber
906
1069
  }, {
@@ -910,12 +1073,12 @@ var yaml11 = failsafe.concat([{
910
1073
  default: true,
911
1074
  tag: 'tag:yaml.org,2002:float',
912
1075
  format: 'EXP',
913
- test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
1076
+ test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
914
1077
  resolve: function resolve(str) {
915
1078
  return parseFloat(str.replace(/_/g, ''));
916
1079
  },
917
- stringify: function stringify(_ref2) {
918
- var value = _ref2.value;
1080
+ stringify: function stringify(_ref3) {
1081
+ var value = _ref3.value;
919
1082
  return Number(value).toExponential();
920
1083
  }
921
1084
  }, {
@@ -924,12 +1087,13 @@ var yaml11 = failsafe.concat([{
924
1087
  },
925
1088
  default: true,
926
1089
  tag: 'tag:yaml.org,2002:float',
927
- test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
928
- resolve: function resolve(str, frac) {
1090
+ test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
1091
+ resolve: function resolve(str) {
929
1092
  var node = new Scalar(parseFloat(str.replace(/_/g, '')));
1093
+ var dot = str.indexOf('.');
930
1094
 
931
- if (frac) {
932
- var f = frac.replace(/_/g, '');
1095
+ if (dot !== -1) {
1096
+ var f = str.substring(dot + 1).replace(/_/g, '');
933
1097
  if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
934
1098
  }
935
1099
 
@@ -1044,4 +1208,4 @@ var Schema = function Schema(_ref) {
1044
1208
  this.sortMapEntries = sortMapEntries === true ? sortMapEntriesByKey : sortMapEntries || null;
1045
1209
  };
1046
1210
 
1047
- export { Schema as S };
1211
+ export { Merge as M, Schema as S, MERGE_KEY as a };