yaml 1.8.2 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/browser/dist/Anchors.js +10 -13
  2. package/browser/dist/Document.js +72 -67
  3. package/browser/dist/addComment.js +1 -1
  4. package/browser/dist/cst/Alias.js +12 -8
  5. package/browser/dist/cst/BlankLine.js +16 -20
  6. package/browser/dist/cst/BlockValue.js +14 -10
  7. package/browser/dist/cst/Collection.js +17 -13
  8. package/browser/dist/cst/CollectionItem.js +15 -11
  9. package/browser/dist/cst/Comment.js +13 -9
  10. package/browser/dist/cst/Directive.js +13 -9
  11. package/browser/dist/cst/Document.js +17 -13
  12. package/browser/dist/cst/FlowCollection.js +17 -13
  13. package/browser/dist/cst/Node.js +3 -5
  14. package/browser/dist/cst/ParseContext.js +12 -14
  15. package/browser/dist/cst/PlainValue.js +12 -8
  16. package/browser/dist/cst/QuoteDouble.js +13 -9
  17. package/browser/dist/cst/QuoteSingle.js +13 -9
  18. package/browser/dist/cst/Range.js +2 -5
  19. package/browser/dist/cst/parse.js +3 -3
  20. package/browser/dist/errors.js +23 -8
  21. package/browser/dist/foldFlowLines.js +1 -1
  22. package/browser/dist/index.js +71 -21
  23. package/browser/dist/listTagNames.js +5 -5
  24. package/browser/dist/schema/Alias.js +30 -34
  25. package/browser/dist/schema/Collection.js +40 -47
  26. package/browser/dist/schema/Map.js +39 -56
  27. package/browser/dist/schema/Merge.js +37 -46
  28. package/browser/dist/schema/Node.js +2 -5
  29. package/browser/dist/schema/Pair.js +36 -13
  30. package/browser/dist/schema/Scalar.js +13 -9
  31. package/browser/dist/schema/Seq.js +27 -25
  32. package/browser/dist/schema/index.js +25 -39
  33. package/browser/dist/schema/parseMap.js +8 -8
  34. package/browser/dist/schema/parseSeq.js +5 -5
  35. package/browser/dist/schema/parseUtils.js +11 -15
  36. package/browser/dist/stringify.js +2 -1
  37. package/browser/dist/tags/core.js +39 -23
  38. package/browser/dist/tags/failsafe/index.js +4 -4
  39. package/browser/dist/tags/failsafe/map.js +15 -18
  40. package/browser/dist/tags/failsafe/seq.js +14 -18
  41. package/browser/dist/tags/failsafe/string.js +1 -1
  42. package/browser/dist/tags/index.js +10 -10
  43. package/browser/dist/tags/json.js +27 -26
  44. package/browser/dist/tags/options.js +3 -0
  45. package/browser/dist/tags/yaml-1.1/binary.js +10 -8
  46. package/browser/dist/tags/yaml-1.1/index.js +75 -43
  47. package/browser/dist/tags/yaml-1.1/omap.js +34 -39
  48. package/browser/dist/tags/yaml-1.1/pairs.js +17 -20
  49. package/browser/dist/tags/yaml-1.1/set.js +27 -23
  50. package/browser/dist/test-events.js +4 -4
  51. package/browser/dist/toJSON.js +3 -4
  52. package/browser/dist/warnings.js +29 -18
  53. package/browser/index.js +1 -1
  54. package/browser/map.js +4 -2
  55. package/browser/pair.js +4 -2
  56. package/browser/parse-cst.js +1 -1
  57. package/browser/scalar.js +4 -2
  58. package/browser/schema.js +11 -6
  59. package/browser/seq.js +4 -2
  60. package/browser/types/binary.js +5 -6
  61. package/browser/types/omap.js +4 -2
  62. package/browser/types/pairs.js +4 -2
  63. package/browser/types/set.js +4 -2
  64. package/browser/types/timestamp.js +5 -9
  65. package/browser/types.js +12 -10
  66. package/browser/util.js +16 -13
  67. package/dist/Anchors.js +13 -18
  68. package/dist/Document.js +52 -48
  69. package/dist/addComment.js +1 -4
  70. package/dist/constants.js +0 -3
  71. package/dist/cst/Alias.js +8 -13
  72. package/dist/cst/BlankLine.js +8 -24
  73. package/dist/cst/BlockValue.js +12 -17
  74. package/dist/cst/Collection.js +22 -27
  75. package/dist/cst/CollectionItem.js +16 -21
  76. package/dist/cst/Comment.js +6 -11
  77. package/dist/cst/Directive.js +7 -12
  78. package/dist/cst/Document.js +23 -28
  79. package/dist/cst/FlowCollection.js +21 -26
  80. package/dist/cst/Node.js +4 -9
  81. package/dist/cst/ParseContext.js +38 -43
  82. package/dist/cst/PlainValue.js +10 -15
  83. package/dist/cst/QuoteDouble.js +9 -14
  84. package/dist/cst/QuoteSingle.js +9 -14
  85. package/dist/cst/Range.js +2 -5
  86. package/dist/cst/parse.js +5 -10
  87. package/dist/cst/source-utils.js +0 -3
  88. package/dist/errors.js +4 -9
  89. package/dist/foldFlowLines.js +1 -4
  90. package/dist/index.js +59 -17
  91. package/dist/listTagNames.js +9 -14
  92. package/dist/schema/Alias.js +12 -17
  93. package/dist/schema/Collection.js +16 -20
  94. package/dist/schema/Map.js +12 -17
  95. package/dist/schema/Merge.js +13 -18
  96. package/dist/schema/Node.js +2 -5
  97. package/dist/schema/Pair.js +44 -31
  98. package/dist/schema/Scalar.js +6 -11
  99. package/dist/schema/Seq.js +9 -14
  100. package/dist/schema/index.js +22 -27
  101. package/dist/schema/parseMap.js +19 -28
  102. package/dist/schema/parseSeq.js +10 -15
  103. package/dist/schema/parseUtils.js +0 -3
  104. package/dist/stringify.js +6 -12
  105. package/dist/tags/core.js +34 -26
  106. package/dist/tags/failsafe/index.js +6 -11
  107. package/dist/tags/failsafe/map.js +8 -13
  108. package/dist/tags/failsafe/seq.js +8 -13
  109. package/dist/tags/failsafe/string.js +3 -6
  110. package/dist/tags/index.js +20 -29
  111. package/dist/tags/json.js +26 -22
  112. package/dist/tags/options.js +5 -4
  113. package/dist/tags/yaml-1.1/binary.js +11 -11
  114. package/dist/tags/yaml-1.1/index.js +69 -38
  115. package/dist/tags/yaml-1.1/omap.js +19 -24
  116. package/dist/tags/yaml-1.1/pairs.js +12 -17
  117. package/dist/tags/yaml-1.1/set.js +12 -21
  118. package/dist/tags/yaml-1.1/timestamp.js +0 -3
  119. package/dist/test-events.js +4 -9
  120. package/dist/toJSON.js +3 -5
  121. package/dist/warnings.js +31 -22
  122. package/index.d.ts +358 -0
  123. package/index.js +1 -1
  124. package/map.js +1 -1
  125. package/package.json +29 -23
  126. package/pair.js +1 -1
  127. package/parse-cst.d.ts +187 -0
  128. package/parse-cst.js +1 -1
  129. package/scalar.js +1 -1
  130. package/schema.js +2 -2
  131. package/seq.js +1 -1
  132. package/types/binary.js +1 -1
  133. package/types/omap.js +1 -1
  134. package/types/pairs.js +1 -1
  135. package/types/set.js +1 -1
  136. package/types/timestamp.js +1 -1
  137. package/types.d.ts +393 -0
  138. package/types.js +7 -6
  139. package/types.mjs +6 -5
  140. package/util.d.ts +86 -0
  141. package/util.js +6 -5
  142. package/util.mjs +4 -3
@@ -1,18 +1,24 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import YAMLMap from '../../schema/Map';
4
- import parseMap from '../../schema/parseMap';
3
+
4
+ function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
+
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
9
+
10
+ import { YAMLMap } from '../../schema/Map';
11
+ import { parseMap } from '../../schema/parseMap';
5
12
 
6
13
  function createMap(schema, obj, ctx) {
7
14
  var map = new YAMLMap(schema);
8
15
 
9
16
  if (obj instanceof Map) {
10
- var _iteratorNormalCompletion = true;
11
- var _didIteratorError = false;
12
- var _iteratorError = undefined;
17
+ var _iterator = _createForOfIteratorHelper(obj),
18
+ _step;
13
19
 
14
20
  try {
15
- for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
21
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
16
22
  var _step$value = _slicedToArray(_step.value, 2),
17
23
  key = _step$value[0],
18
24
  value = _step$value[1];
@@ -20,18 +26,9 @@ function createMap(schema, obj, ctx) {
20
26
  map.items.push(schema.createPair(key, value, ctx));
21
27
  }
22
28
  } catch (err) {
23
- _didIteratorError = true;
24
- _iteratorError = err;
29
+ _iterator.e(err);
25
30
  } finally {
26
- try {
27
- if (!_iteratorNormalCompletion && _iterator.return != null) {
28
- _iterator.return();
29
- }
30
- } finally {
31
- if (_didIteratorError) {
32
- throw _iteratorError;
33
- }
34
- }
31
+ _iterator.f();
35
32
  }
36
33
  } else if (obj && _typeof(obj) === 'object') {
37
34
  for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
@@ -47,7 +44,7 @@ function createMap(schema, obj, ctx) {
47
44
  return map;
48
45
  }
49
46
 
50
- export default {
47
+ export var map = {
51
48
  createNode: createMap,
52
49
  default: true,
53
50
  nodeClass: YAMLMap,
@@ -1,40 +1,36 @@
1
- import parseSeq from '../../schema/parseSeq';
2
- import YAMLSeq from '../../schema/Seq';
1
+ function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6
+
7
+ import { parseSeq } from '../../schema/parseSeq';
8
+ import { YAMLSeq } from '../../schema/Seq';
3
9
 
4
10
  function createSeq(schema, obj, ctx) {
5
11
  var seq = new YAMLSeq(schema);
6
12
 
7
13
  if (obj && obj[Symbol.iterator]) {
8
- var _iteratorNormalCompletion = true;
9
- var _didIteratorError = false;
10
- var _iteratorError = undefined;
14
+ var _iterator = _createForOfIteratorHelper(obj),
15
+ _step;
11
16
 
12
17
  try {
13
- for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
18
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
14
19
  var it = _step.value;
15
20
  var v = schema.createNode(it, ctx.wrapScalars, null, ctx);
16
21
  seq.items.push(v);
17
22
  }
18
23
  } catch (err) {
19
- _didIteratorError = true;
20
- _iteratorError = err;
24
+ _iterator.e(err);
21
25
  } finally {
22
- try {
23
- if (!_iteratorNormalCompletion && _iterator.return != null) {
24
- _iterator.return();
25
- }
26
- } finally {
27
- if (_didIteratorError) {
28
- throw _iteratorError;
29
- }
30
- }
26
+ _iterator.f();
31
27
  }
32
28
  }
33
29
 
34
30
  return seq;
35
31
  }
36
32
 
37
- export default {
33
+ export var seq = {
38
34
  createNode: createSeq,
39
35
  default: true,
40
36
  nodeClass: YAMLSeq,
@@ -11,7 +11,7 @@ export var resolveString = function resolveString(doc, node) {
11
11
  });
12
12
  return res.str;
13
13
  };
14
- export default {
14
+ export var string = {
15
15
  identify: function identify(value) {
16
16
  return typeof value === 'string';
17
17
  },
@@ -1,13 +1,13 @@
1
- import core, { nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj } from './core';
2
- import failsafe from './failsafe';
3
- import json from './json';
4
- import yaml11 from './yaml-1.1';
5
- import map from './failsafe/map';
6
- import seq from './failsafe/seq';
7
- import binary from './yaml-1.1/binary';
8
- import omap from './yaml-1.1/omap';
9
- import pairs from './yaml-1.1/pairs';
10
- import set from './yaml-1.1/set';
1
+ import { core, nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj } from './core';
2
+ import { failsafe } from './failsafe';
3
+ import { json } from './json';
4
+ import { yaml11 } from './yaml-1.1';
5
+ import { map } from './failsafe/map';
6
+ import { seq } from './failsafe/seq';
7
+ import { binary } from './yaml-1.1/binary';
8
+ import { omap } from './yaml-1.1/omap';
9
+ import { pairs } from './yaml-1.1/pairs';
10
+ import { set } from './yaml-1.1/set';
11
11
  import { floatTime, intTime, timestamp } from './yaml-1.1/timestamp';
12
12
  export var schemas = {
13
13
  core: core,
@@ -1,17 +1,27 @@
1
- import map from './failsafe/map';
2
- import seq from './failsafe/seq';
3
- import Scalar from '../schema/Scalar';
1
+ /* global BigInt */
2
+ import { map } from './failsafe/map';
3
+ import { seq } from './failsafe/seq';
4
+ import { Scalar } from '../schema/Scalar';
4
5
  import { resolveString } from './failsafe/string';
5
- var schema = [map, seq, {
6
+ import { intOptions } from './options';
7
+
8
+ var intIdentify = function intIdentify(value) {
9
+ return typeof value === 'bigint' || Number.isInteger(value);
10
+ };
11
+
12
+ var stringifyJSON = function stringifyJSON(_ref) {
13
+ var value = _ref.value;
14
+ return JSON.stringify(value);
15
+ };
16
+
17
+ export var json = [map, seq, {
6
18
  identify: function identify(value) {
7
19
  return typeof value === 'string';
8
20
  },
9
21
  default: true,
10
22
  tag: 'tag:yaml.org,2002:str',
11
23
  resolve: resolveString,
12
- stringify: function stringify(value) {
13
- return JSON.stringify(value);
14
- }
24
+ stringify: stringifyJSON
15
25
  }, {
16
26
  identify: function identify(value) {
17
27
  return value == null;
@@ -25,9 +35,7 @@ var schema = [map, seq, {
25
35
  resolve: function resolve() {
26
36
  return null;
27
37
  },
28
- stringify: function stringify(value) {
29
- return JSON.stringify(value);
30
- }
38
+ stringify: stringifyJSON
31
39
  }, {
32
40
  identify: function identify(value) {
33
41
  return typeof value === 'boolean';
@@ -38,21 +46,18 @@ var schema = [map, seq, {
38
46
  resolve: function resolve(str) {
39
47
  return str === 'true';
40
48
  },
41
- stringify: function stringify(value) {
42
- return JSON.stringify(value);
43
- }
49
+ stringify: stringifyJSON
44
50
  }, {
45
- identify: function identify(value) {
46
- return typeof value === 'number';
47
- },
51
+ identify: intIdentify,
48
52
  default: true,
49
53
  tag: 'tag:yaml.org,2002:int',
50
54
  test: /^-?(?:0|[1-9][0-9]*)$/,
51
55
  resolve: function resolve(str) {
52
- return parseInt(str, 10);
56
+ return intOptions.asBigInt ? BigInt(str) : parseInt(str, 10);
53
57
  },
54
- stringify: function stringify(value) {
55
- return JSON.stringify(value);
58
+ stringify: function stringify(_ref2) {
59
+ var value = _ref2.value;
60
+ return intIdentify(value) ? value.toString() : JSON.stringify(value);
56
61
  }
57
62
  }, {
58
63
  identify: function identify(value) {
@@ -64,13 +69,9 @@ var schema = [map, seq, {
64
69
  resolve: function resolve(str) {
65
70
  return parseFloat(str);
66
71
  },
67
- stringify: function stringify(value) {
68
- return JSON.stringify(value);
69
- }
72
+ stringify: stringifyJSON
70
73
  }];
71
74
 
72
- schema.scalarFallback = function (str) {
75
+ json.scalarFallback = function (str) {
73
76
  throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(str)));
74
- };
75
-
76
- export default schema;
77
+ };
@@ -7,6 +7,9 @@ export var boolOptions = {
7
7
  trueStr: 'true',
8
8
  falseStr: 'false'
9
9
  };
10
+ export var intOptions = {
11
+ asBigInt: false
12
+ };
10
13
  export var nullOptions = {
11
14
  nullStr: 'null'
12
15
  };
@@ -4,7 +4,7 @@ import { YAMLReferenceError } from '../../errors';
4
4
  import { stringifyString } from '../../stringify';
5
5
  import { resolveString } from '../failsafe/string';
6
6
  import { binaryOptions as options } from '../options';
7
- export default {
7
+ export var binary = {
8
8
  identify: function identify(value) {
9
9
  return value instanceof Uint8Array;
10
10
  },
@@ -21,21 +21,23 @@ export default {
21
21
  * document.querySelector('#photo').src = URL.createObjectURL(blob)
22
22
  */
23
23
  resolve: function resolve(doc, node) {
24
+ var src = resolveString(doc, node);
25
+
24
26
  if (typeof Buffer === 'function') {
25
- var src = resolveString(doc, node);
26
27
  return Buffer.from(src, 'base64');
27
28
  } else if (typeof atob === 'function') {
28
- var _src = atob(resolveString(doc, node));
29
-
30
- var buffer = new Uint8Array(_src.length);
29
+ // On IE 11, atob() can't handle newlines
30
+ var str = atob(src.replace(/[\n\r]/g, ''));
31
+ var buffer = new Uint8Array(str.length);
31
32
 
32
- for (var i = 0; i < _src.length; ++i) {
33
- buffer[i] = _src.charCodeAt(i);
33
+ for (var i = 0; i < str.length; ++i) {
34
+ buffer[i] = str.charCodeAt(i);
34
35
  }
35
36
 
36
37
  return buffer;
37
38
  } else {
38
- doc.errors.push(new YAMLReferenceError(node, 'This environment does not support reading binary tags; either Buffer or atob is required'));
39
+ var msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
40
+ doc.errors.push(new YAMLReferenceError(node, msg));
39
41
  return null;
40
42
  }
41
43
  },
@@ -1,11 +1,12 @@
1
- import Scalar from '../../schema/Scalar';
1
+ /* global BigInt */
2
+ import { Scalar } from '../../schema/Scalar';
2
3
  import { stringifyNumber } from '../../stringify';
3
- import failsafe from '../failsafe';
4
- import { boolOptions, nullOptions } from '../options';
5
- import binary from './binary';
6
- import omap from './omap';
7
- import pairs from './pairs';
8
- import set from './set';
4
+ import { failsafe } from '../failsafe';
5
+ import { boolOptions, intOptions, nullOptions } from '../options';
6
+ import { binary } from './binary';
7
+ import { omap } from './omap';
8
+ import { pairs } from './pairs';
9
+ import { set } from './set';
9
10
  import { intTime, floatTime, timestamp } from './timestamp';
10
11
 
11
12
  var boolStringify = function boolStringify(_ref) {
@@ -13,7 +14,49 @@ var boolStringify = function boolStringify(_ref) {
13
14
  return value ? boolOptions.trueStr : boolOptions.falseStr;
14
15
  };
15
16
 
16
- export default failsafe.concat([{
17
+ var intIdentify = function intIdentify(value) {
18
+ return typeof value === 'bigint' || Number.isInteger(value);
19
+ };
20
+
21
+ function intResolve(sign, src, radix) {
22
+ var str = src.replace(/_/g, '');
23
+
24
+ if (intOptions.asBigInt) {
25
+ switch (radix) {
26
+ case 2:
27
+ str = "0b".concat(str);
28
+ break;
29
+
30
+ case 8:
31
+ str = "0o".concat(str);
32
+ break;
33
+
34
+ case 16:
35
+ str = "0x".concat(str);
36
+ break;
37
+ }
38
+
39
+ var _n = BigInt(str);
40
+
41
+ return sign === '-' ? BigInt(-1) * _n : _n;
42
+ }
43
+
44
+ var n = parseInt(str, radix);
45
+ return sign === '-' ? -1 * n : n;
46
+ }
47
+
48
+ function intStringify(node, radix, prefix) {
49
+ var value = node.value;
50
+
51
+ if (intIdentify(value)) {
52
+ var str = value.toString(radix);
53
+ return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
54
+ }
55
+
56
+ return stringifyNumber(node);
57
+ }
58
+
59
+ export var yaml11 = failsafe.concat([{
17
60
  identify: function identify(value) {
18
61
  return value == null;
19
62
  },
@@ -55,60 +98,49 @@ export default failsafe.concat([{
55
98
  options: boolOptions,
56
99
  stringify: boolStringify
57
100
  }, {
58
- identify: function identify(value) {
59
- return typeof value === 'number';
60
- },
101
+ identify: intIdentify,
61
102
  default: true,
62
103
  tag: 'tag:yaml.org,2002:int',
63
104
  format: 'BIN',
64
- test: /^0b([0-1_]+)$/,
65
- resolve: function resolve(str, bin) {
66
- return parseInt(bin.replace(/_/g, ''), 2);
105
+ test: /^([-+]?)0b([0-1_]+)$/,
106
+ resolve: function resolve(str, sign, bin) {
107
+ return intResolve(sign, bin, 2);
67
108
  },
68
- stringify: function stringify(_ref2) {
69
- var value = _ref2.value;
70
- return '0b' + value.toString(2);
109
+ stringify: function stringify(node) {
110
+ return intStringify(node, 2, '0b');
71
111
  }
72
112
  }, {
73
- identify: function identify(value) {
74
- return typeof value === 'number';
75
- },
113
+ identify: intIdentify,
76
114
  default: true,
77
115
  tag: 'tag:yaml.org,2002:int',
78
116
  format: 'OCT',
79
- test: /^[-+]?0([0-7_]+)$/,
80
- resolve: function resolve(str, oct) {
81
- return parseInt(oct.replace(/_/g, ''), 8);
117
+ test: /^([-+]?)0([0-7_]+)$/,
118
+ resolve: function resolve(str, sign, oct) {
119
+ return intResolve(sign, oct, 8);
82
120
  },
83
- stringify: function stringify(_ref3) {
84
- var value = _ref3.value;
85
- return (value < 0 ? '-0' : '0') + value.toString(8);
121
+ stringify: function stringify(node) {
122
+ return intStringify(node, 8, '0');
86
123
  }
87
124
  }, {
88
- identify: function identify(value) {
89
- return typeof value === 'number';
90
- },
125
+ identify: intIdentify,
91
126
  default: true,
92
127
  tag: 'tag:yaml.org,2002:int',
93
- test: /^[-+]?[0-9][0-9_]*$/,
94
- resolve: function resolve(str) {
95
- return parseInt(str.replace(/_/g, ''), 10);
128
+ test: /^([-+]?)([0-9][0-9_]*)$/,
129
+ resolve: function resolve(str, sign, abs) {
130
+ return intResolve(sign, abs, 10);
96
131
  },
97
132
  stringify: stringifyNumber
98
133
  }, {
99
- identify: function identify(value) {
100
- return typeof value === 'number';
101
- },
134
+ identify: intIdentify,
102
135
  default: true,
103
136
  tag: 'tag:yaml.org,2002:int',
104
137
  format: 'HEX',
105
- test: /^0x([0-9a-fA-F_]+)$/,
106
- resolve: function resolve(str, hex) {
107
- return parseInt(hex.replace(/_/g, ''), 16);
138
+ test: /^([-+]?)0x([0-9a-fA-F_]+)$/,
139
+ resolve: function resolve(str, sign, hex) {
140
+ return intResolve(sign, hex, 16);
108
141
  },
109
- stringify: function stringify(_ref4) {
110
- var value = _ref4.value;
111
- return (value < 0 ? '-0x' : '0x') + value.toString(16);
142
+ stringify: function stringify(node) {
143
+ return intStringify(node, 16, '0x');
112
144
  }
113
145
  }, {
114
146
  identify: function identify(value) {
@@ -132,8 +164,8 @@ export default failsafe.concat([{
132
164
  resolve: function resolve(str) {
133
165
  return parseFloat(str.replace(/_/g, ''));
134
166
  },
135
- stringify: function stringify(_ref5) {
136
- var value = _ref5.value;
167
+ stringify: function stringify(_ref2) {
168
+ var value = _ref2.value;
137
169
  return Number(value).toExponential();
138
170
  }
139
171
  }, {
@@ -1,26 +1,39 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
3
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
6
4
  import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+
9
+ function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
10
+
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14
+
15
+ function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
+
17
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
18
+
8
19
  import { YAMLSemanticError } from '../../errors';
9
- import _toJSON from '../../toJSON';
10
- import YAMLMap from '../../schema/Map';
11
- import Pair from '../../schema/Pair';
12
- import Scalar from '../../schema/Scalar';
13
- import YAMLSeq from '../../schema/Seq';
20
+ import { toJSON as _toJSON } from '../../toJSON';
21
+ import { YAMLMap } from '../../schema/Map';
22
+ import { Pair } from '../../schema/Pair';
23
+ import { Scalar } from '../../schema/Scalar';
24
+ import { YAMLSeq } from '../../schema/Seq';
14
25
  import { createPairs, parsePairs } from './pairs';
15
26
  export var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
16
27
  _inherits(YAMLOMap, _YAMLSeq);
17
28
 
29
+ var _super = _createSuper(YAMLOMap);
30
+
18
31
  function YAMLOMap() {
19
32
  var _this;
20
33
 
21
34
  _classCallCheck(this, YAMLOMap);
22
35
 
23
- _this = _possibleConstructorReturn(this, _getPrototypeOf(YAMLOMap).call(this));
36
+ _this = _super.call(this);
24
37
 
25
38
  _defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this)));
26
39
 
@@ -41,12 +54,12 @@ export var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
41
54
  value: function toJSON(_, ctx) {
42
55
  var map = new Map();
43
56
  if (ctx && ctx.onCreate) ctx.onCreate(map);
44
- var _iteratorNormalCompletion = true;
45
- var _didIteratorError = false;
46
- var _iteratorError = undefined;
57
+
58
+ var _iterator = _createForOfIteratorHelper(this.items),
59
+ _step;
47
60
 
48
61
  try {
49
- for (var _iterator = this.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
62
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
50
63
  var pair = _step.value;
51
64
  var key = void 0,
52
65
  value = void 0;
@@ -62,18 +75,9 @@ export var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
62
75
  map.set(key, value);
63
76
  }
64
77
  } catch (err) {
65
- _didIteratorError = true;
66
- _iteratorError = err;
78
+ _iterator.e(err);
67
79
  } finally {
68
- try {
69
- if (!_iteratorNormalCompletion && _iterator.return != null) {
70
- _iterator.return();
71
- }
72
- } finally {
73
- if (_didIteratorError) {
74
- throw _iteratorError;
75
- }
76
- }
80
+ _iterator.f();
77
81
  }
78
82
 
79
83
  return map;
@@ -88,12 +92,12 @@ _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
88
92
  function parseOMap(doc, cst) {
89
93
  var pairs = parsePairs(doc, cst);
90
94
  var seenKeys = [];
91
- var _iteratorNormalCompletion2 = true;
92
- var _didIteratorError2 = false;
93
- var _iteratorError2 = undefined;
95
+
96
+ var _iterator2 = _createForOfIteratorHelper(pairs.items),
97
+ _step2;
94
98
 
95
99
  try {
96
- for (var _iterator2 = pairs.items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
100
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
97
101
  var key = _step2.value.key;
98
102
 
99
103
  if (key instanceof Scalar) {
@@ -106,18 +110,9 @@ function parseOMap(doc, cst) {
106
110
  }
107
111
  }
108
112
  } catch (err) {
109
- _didIteratorError2 = true;
110
- _iteratorError2 = err;
113
+ _iterator2.e(err);
111
114
  } finally {
112
- try {
113
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
114
- _iterator2.return();
115
- }
116
- } finally {
117
- if (_didIteratorError2) {
118
- throw _iteratorError2;
119
- }
120
- }
115
+ _iterator2.f();
121
116
  }
122
117
 
123
118
  return Object.assign(new YAMLOMap(), pairs);
@@ -130,7 +125,7 @@ function createOMap(schema, iterable, ctx) {
130
125
  return omap;
131
126
  }
132
127
 
133
- export default {
128
+ export var omap = {
134
129
  identify: function identify(value) {
135
130
  return value instanceof Map;
136
131
  },
@@ -1,8 +1,14 @@
1
+ function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6
+
1
7
  import { YAMLSemanticError } from '../../errors';
2
- import YAMLMap from '../../schema/Map';
3
- import Pair from '../../schema/Pair';
4
- import parseSeq from '../../schema/parseSeq';
5
- import YAMLSeq from '../../schema/Seq';
8
+ import { YAMLMap } from '../../schema/Map';
9
+ import { Pair } from '../../schema/Pair';
10
+ import { parseSeq } from '../../schema/parseSeq';
11
+ import { YAMLSeq } from '../../schema/Seq';
6
12
  export function parsePairs(doc, cst) {
7
13
  var seq = parseSeq(doc, cst);
8
14
 
@@ -27,12 +33,12 @@ export function parsePairs(doc, cst) {
27
33
  export function createPairs(schema, iterable, ctx) {
28
34
  var pairs = new YAMLSeq(schema);
29
35
  pairs.tag = 'tag:yaml.org,2002:pairs';
30
- var _iteratorNormalCompletion = true;
31
- var _didIteratorError = false;
32
- var _iteratorError = undefined;
36
+
37
+ var _iterator = _createForOfIteratorHelper(iterable),
38
+ _step;
33
39
 
34
40
  try {
35
- for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
41
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
42
  var it = _step.value;
37
43
  var key = void 0,
38
44
  value = void 0;
@@ -57,23 +63,14 @@ export function createPairs(schema, iterable, ctx) {
57
63
  pairs.items.push(pair);
58
64
  }
59
65
  } catch (err) {
60
- _didIteratorError = true;
61
- _iteratorError = err;
66
+ _iterator.e(err);
62
67
  } finally {
63
- try {
64
- if (!_iteratorNormalCompletion && _iterator.return != null) {
65
- _iterator.return();
66
- }
67
- } finally {
68
- if (_didIteratorError) {
69
- throw _iteratorError;
70
- }
71
- }
68
+ _iterator.f();
72
69
  }
73
70
 
74
71
  return pairs;
75
72
  }
76
- export default {
73
+ export var pairs = {
77
74
  default: false,
78
75
  tag: 'tag:yaml.org,2002:pairs',
79
76
  resolve: parsePairs,