yaml 1.8.1 → 1.9.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.
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 +42 -31
  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 +392 -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,21 +1,27 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
3
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
4
2
  import _get from "@babel/runtime/helpers/get";
5
3
  import _createClass from "@babel/runtime/helpers/createClass";
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
+
8
+ 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); }; }
9
+
10
+ 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; } }
11
+
7
12
  import { Char, Type } from '../constants';
8
13
  import { YAMLSemanticError, YAMLSyntaxError } from '../errors';
9
- import BlankLine from './BlankLine';
14
+ import { BlankLine } from './BlankLine';
10
15
  import { grabCollectionEndComments } from './Collection';
11
- import Comment from './Comment';
12
- import Directive from './Directive';
13
- import Node from './Node';
14
- import Range from './Range';
15
-
16
- var Document = /*#__PURE__*/function (_Node) {
16
+ import { Comment } from './Comment';
17
+ import { Directive } from './Directive';
18
+ import { Node } from './Node';
19
+ import { Range } from './Range';
20
+ export var Document = /*#__PURE__*/function (_Node) {
17
21
  _inherits(Document, _Node);
18
22
 
23
+ var _super = _createSuper(Document);
24
+
19
25
  _createClass(Document, null, [{
20
26
  key: "startCommentOrEndBlankLine",
21
27
  value: function startCommentOrEndBlankLine(src, start) {
@@ -30,7 +36,7 @@ var Document = /*#__PURE__*/function (_Node) {
30
36
 
31
37
  _classCallCheck(this, Document);
32
38
 
33
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Document).call(this, Type.DOCUMENT));
39
+ _this = _super.call(this, Type.DOCUMENT);
34
40
  _this.directives = null;
35
41
  _this.contents = null;
36
42
  _this.directivesEndMarker = null;
@@ -277,6 +283,4 @@ var Document = /*#__PURE__*/function (_Node) {
277
283
  }]);
278
284
 
279
285
  return Document;
280
- }(Node);
281
-
282
- export { Document as default };
286
+ }(Node);
@@ -1,25 +1,31 @@
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 _get from "@babel/runtime/helpers/get";
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
+
8
+ 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); }; }
9
+
10
+ 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; } }
11
+
7
12
  import { Type } from '../constants';
8
13
  import { YAMLSemanticError } from '../errors';
9
- import BlankLine from './BlankLine';
10
- import Comment from './Comment';
11
- import Node from './Node';
12
- import Range from './Range';
13
-
14
- var FlowCollection = /*#__PURE__*/function (_Node) {
14
+ import { BlankLine } from './BlankLine';
15
+ import { Comment } from './Comment';
16
+ import { Node } from './Node';
17
+ import { Range } from './Range';
18
+ export var FlowCollection = /*#__PURE__*/function (_Node) {
15
19
  _inherits(FlowCollection, _Node);
16
20
 
21
+ var _super = _createSuper(FlowCollection);
22
+
17
23
  function FlowCollection(type, props) {
18
24
  var _this;
19
25
 
20
26
  _classCallCheck(this, FlowCollection);
21
27
 
22
- _this = _possibleConstructorReturn(this, _getPrototypeOf(FlowCollection).call(this, type, props));
28
+ _this = _super.call(this, type, props);
23
29
  _this.items = null;
24
30
  return _this;
25
31
  }
@@ -29,7 +35,7 @@ var FlowCollection = /*#__PURE__*/function (_Node) {
29
35
  value: function prevNodeIsJsonLike() {
30
36
  var idx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items.length;
31
37
  var node = this.items[idx - 1];
32
- return !!node && (node.jsonLike || node.type === Type.COMMENT && this.nodeIsJsonLike(idx - 1));
38
+ return !!node && (node.jsonLike || node.type === Type.COMMENT && this.prevNodeIsJsonLike(idx - 1));
33
39
  }
34
40
  /**
35
41
  * @param {ParseContext} context
@@ -211,6 +217,4 @@ var FlowCollection = /*#__PURE__*/function (_Node) {
211
217
  }]);
212
218
 
213
219
  return FlowCollection;
214
- }(Node);
215
-
216
- export { FlowCollection as default };
220
+ }(Node);
@@ -3,10 +3,10 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import { Char, Type } from '../constants';
5
5
  import { getLinePos } from './source-utils';
6
- import Range from './Range';
6
+ import { Range } from './Range';
7
7
  /** Root class of all nodes */
8
8
 
9
- var Node = /*#__PURE__*/function () {
9
+ export var Node = /*#__PURE__*/function () {
10
10
  _createClass(Node, null, [{
11
11
  key: "addStringTerminator",
12
12
  value: function addStringTerminator(src, offset, str) {
@@ -383,6 +383,4 @@ var Node = /*#__PURE__*/function () {
383
383
  }]);
384
384
 
385
385
  return Node;
386
- }();
387
-
388
- export { Node as default };
386
+ }();
@@ -3,16 +3,16 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import { Char, Type } from '../constants';
5
5
  import { YAMLSyntaxError } from '../errors';
6
- import Alias from './Alias';
7
- import BlockValue from './BlockValue';
8
- import Collection from './Collection';
9
- import CollectionItem from './CollectionItem';
10
- import FlowCollection from './FlowCollection';
11
- import Node from './Node';
12
- import PlainValue from './PlainValue';
13
- import QuoteDouble from './QuoteDouble';
14
- import QuoteSingle from './QuoteSingle';
15
- import Range from './Range';
6
+ import { Alias } from './Alias';
7
+ import { BlockValue } from './BlockValue';
8
+ import { Collection } from './Collection';
9
+ import { CollectionItem } from './CollectionItem';
10
+ import { FlowCollection } from './FlowCollection';
11
+ import { Node } from './Node';
12
+ import { PlainValue } from './PlainValue';
13
+ import { QuoteDouble } from './QuoteDouble';
14
+ import { QuoteSingle } from './QuoteSingle';
15
+ import { Range } from './Range';
16
16
 
17
17
  function createNewNode(type, props) {
18
18
  switch (type) {
@@ -60,7 +60,7 @@ function createNewNode(type, props) {
60
60
  */
61
61
 
62
62
 
63
- var ParseContext = /*#__PURE__*/function () {
63
+ export var ParseContext = /*#__PURE__*/function () {
64
64
  _createClass(ParseContext, null, [{
65
65
  key: "parseType",
66
66
  value: function parseType(src, offset, inFlow) {
@@ -243,6 +243,4 @@ var ParseContext = /*#__PURE__*/function () {
243
243
  }]);
244
244
 
245
245
  return ParseContext;
246
- }();
247
-
248
- export { ParseContext as default };
246
+ }();
@@ -1,18 +1,24 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
3
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import Node from './Node';
7
- import Range from './Range';
8
6
 
9
- var PlainValue = /*#__PURE__*/function (_Node) {
7
+ 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); }; }
8
+
9
+ 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; } }
10
+
11
+ import { Node } from './Node';
12
+ import { Range } from './Range';
13
+ export var PlainValue = /*#__PURE__*/function (_Node) {
10
14
  _inherits(PlainValue, _Node);
11
15
 
16
+ var _super = _createSuper(PlainValue);
17
+
12
18
  function PlainValue() {
13
19
  _classCallCheck(this, PlainValue);
14
20
 
15
- return _possibleConstructorReturn(this, _getPrototypeOf(PlainValue).apply(this, arguments));
21
+ return _super.apply(this, arguments);
16
22
  }
17
23
 
18
24
  _createClass(PlainValue, [{
@@ -161,6 +167,4 @@ var PlainValue = /*#__PURE__*/function (_Node) {
161
167
  }]);
162
168
 
163
169
  return PlainValue;
164
- }(Node);
165
-
166
- export { PlainValue as default };
170
+ }(Node);
@@ -1,19 +1,25 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
3
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import { YAMLSemanticError, YAMLSyntaxError } from '../errors';
7
- import Node from './Node';
8
- import Range from './Range';
9
6
 
10
- var QuoteDouble = /*#__PURE__*/function (_Node) {
7
+ 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); }; }
8
+
9
+ 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; } }
10
+
11
+ import { YAMLSemanticError, YAMLSyntaxError } from '../errors';
12
+ import { Node } from './Node';
13
+ import { Range } from './Range';
14
+ export var QuoteDouble = /*#__PURE__*/function (_Node) {
11
15
  _inherits(QuoteDouble, _Node);
12
16
 
17
+ var _super = _createSuper(QuoteDouble);
18
+
13
19
  function QuoteDouble() {
14
20
  _classCallCheck(this, QuoteDouble);
15
21
 
16
- return _possibleConstructorReturn(this, _getPrototypeOf(QuoteDouble).apply(this, arguments));
22
+ return _super.apply(this, arguments);
17
23
  }
18
24
 
19
25
  _createClass(QuoteDouble, [{
@@ -236,6 +242,4 @@ var QuoteDouble = /*#__PURE__*/function (_Node) {
236
242
  }]);
237
243
 
238
244
  return QuoteDouble;
239
- }(Node);
240
-
241
- export { QuoteDouble as default };
245
+ }(Node);
@@ -1,19 +1,25 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
3
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import { YAMLSemanticError, YAMLSyntaxError } from '../errors';
7
- import Node from './Node';
8
- import Range from './Range';
9
6
 
10
- var QuoteSingle = /*#__PURE__*/function (_Node) {
7
+ 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); }; }
8
+
9
+ 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; } }
10
+
11
+ import { YAMLSemanticError, YAMLSyntaxError } from '../errors';
12
+ import { Node } from './Node';
13
+ import { Range } from './Range';
14
+ export var QuoteSingle = /*#__PURE__*/function (_Node) {
11
15
  _inherits(QuoteSingle, _Node);
12
16
 
17
+ var _super = _createSuper(QuoteSingle);
18
+
13
19
  function QuoteSingle() {
14
20
  _classCallCheck(this, QuoteSingle);
15
21
 
16
- return _possibleConstructorReturn(this, _getPrototypeOf(QuoteSingle).apply(this, arguments));
22
+ return _super.apply(this, arguments);
17
23
  }
18
24
 
19
25
  _createClass(QuoteSingle, [{
@@ -111,6 +117,4 @@ var QuoteSingle = /*#__PURE__*/function (_Node) {
111
117
  }]);
112
118
 
113
119
  return QuoteSingle;
114
- }(Node);
115
-
116
- export { QuoteSingle as default };
120
+ }(Node);
@@ -1,7 +1,6 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
-
4
- var Range = /*#__PURE__*/function () {
3
+ export var Range = /*#__PURE__*/function () {
5
4
  _createClass(Range, null, [{
6
5
  key: "copy",
7
6
  value: function copy(orig) {
@@ -62,6 +61,4 @@ var Range = /*#__PURE__*/function () {
62
61
  }]);
63
62
 
64
63
  return Range;
65
- }();
66
-
67
- export { Range as default };
64
+ }();
@@ -1,7 +1,7 @@
1
1
  // Published as 'yaml/parse-cst'
2
- import Document from './Document';
3
- import ParseContext from './ParseContext';
4
- export default function parse(src) {
2
+ import { Document } from './Document';
3
+ import { ParseContext } from './ParseContext';
4
+ export function parse(src) {
5
5
  var cr = [];
6
6
 
7
7
  if (src.indexOf('\r') !== -1) {
@@ -1,22 +1,29 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
3
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
7
- import Node from './cst/Node';
7
+
8
+ 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); }; }
9
+
10
+ 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; } }
11
+
12
+ import { Node } from './cst/Node';
8
13
  import { getLinePos, getPrettyContext } from './cst/source-utils';
9
- import Range from './cst/Range';
14
+ import { Range } from './cst/Range';
10
15
  export var YAMLError = /*#__PURE__*/function (_Error) {
11
16
  _inherits(YAMLError, _Error);
12
17
 
18
+ var _super = _createSuper(YAMLError);
19
+
13
20
  function YAMLError(name, source, message) {
14
21
  var _this;
15
22
 
16
23
  _classCallCheck(this, YAMLError);
17
24
 
18
25
  if (!message || !(source instanceof Node)) throw new Error("Invalid arguments for new ".concat(name));
19
- _this = _possibleConstructorReturn(this, _getPrototypeOf(YAMLError).call(this));
26
+ _this = _super.call(this);
20
27
  _this.name = name;
21
28
  _this.message = message;
22
29
  _this.source = source;
@@ -69,10 +76,12 @@ export var YAMLError = /*#__PURE__*/function (_Error) {
69
76
  export var YAMLReferenceError = /*#__PURE__*/function (_YAMLError) {
70
77
  _inherits(YAMLReferenceError, _YAMLError);
71
78
 
79
+ var _super2 = _createSuper(YAMLReferenceError);
80
+
72
81
  function YAMLReferenceError(source, message) {
73
82
  _classCallCheck(this, YAMLReferenceError);
74
83
 
75
- return _possibleConstructorReturn(this, _getPrototypeOf(YAMLReferenceError).call(this, 'YAMLReferenceError', source, message));
84
+ return _super2.call(this, 'YAMLReferenceError', source, message);
76
85
  }
77
86
 
78
87
  return YAMLReferenceError;
@@ -80,10 +89,12 @@ export var YAMLReferenceError = /*#__PURE__*/function (_YAMLError) {
80
89
  export var YAMLSemanticError = /*#__PURE__*/function (_YAMLError2) {
81
90
  _inherits(YAMLSemanticError, _YAMLError2);
82
91
 
92
+ var _super3 = _createSuper(YAMLSemanticError);
93
+
83
94
  function YAMLSemanticError(source, message) {
84
95
  _classCallCheck(this, YAMLSemanticError);
85
96
 
86
- return _possibleConstructorReturn(this, _getPrototypeOf(YAMLSemanticError).call(this, 'YAMLSemanticError', source, message));
97
+ return _super3.call(this, 'YAMLSemanticError', source, message);
87
98
  }
88
99
 
89
100
  return YAMLSemanticError;
@@ -91,10 +102,12 @@ export var YAMLSemanticError = /*#__PURE__*/function (_YAMLError2) {
91
102
  export var YAMLSyntaxError = /*#__PURE__*/function (_YAMLError3) {
92
103
  _inherits(YAMLSyntaxError, _YAMLError3);
93
104
 
105
+ var _super4 = _createSuper(YAMLSyntaxError);
106
+
94
107
  function YAMLSyntaxError(source, message) {
95
108
  _classCallCheck(this, YAMLSyntaxError);
96
109
 
97
- return _possibleConstructorReturn(this, _getPrototypeOf(YAMLSyntaxError).call(this, 'YAMLSyntaxError', source, message));
110
+ return _super4.call(this, 'YAMLSyntaxError', source, message);
98
111
  }
99
112
 
100
113
  return YAMLSyntaxError;
@@ -102,10 +115,12 @@ export var YAMLSyntaxError = /*#__PURE__*/function (_YAMLError3) {
102
115
  export var YAMLWarning = /*#__PURE__*/function (_YAMLError4) {
103
116
  _inherits(YAMLWarning, _YAMLError4);
104
117
 
118
+ var _super5 = _createSuper(YAMLWarning);
119
+
105
120
  function YAMLWarning(source, message) {
106
121
  _classCallCheck(this, YAMLWarning);
107
122
 
108
- return _possibleConstructorReturn(this, _getPrototypeOf(YAMLWarning).call(this, 'YAMLWarning', source, message));
123
+ return _super5.call(this, 'YAMLWarning', source, message);
109
124
  }
110
125
 
111
126
  return YAMLWarning;
@@ -38,7 +38,7 @@ var consumeMoreIndentedLines = function consumeMoreIndentedLines(text, i) {
38
38
  */
39
39
 
40
40
 
41
- export default function foldFlowLines(text, indent, mode, _ref) {
41
+ export function foldFlowLines(text, indent, mode, _ref) {
42
42
  var indentAtStart = _ref.indentAtStart,
43
43
  _ref$lineWidth = _ref.lineWidth,
44
44
  lineWidth = _ref$lineWidth === void 0 ? 80 : _ref$lineWidth,
@@ -1,15 +1,29 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/inherits";
2
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
3
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import parseCST from './cst/parse';
6
- import YAMLDocument from './Document';
5
+
6
+ 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; } } }; }
7
+
8
+ 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); }
9
+
10
+ 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; }
11
+
12
+ 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); }; }
13
+
14
+ 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; } }
15
+
16
+ import { parse as parseCST } from './cst/parse';
17
+ import { Document as YAMLDocument } from './Document';
7
18
  import { YAMLSemanticError } from './errors';
8
- import Schema from './schema';
19
+ import { Schema } from './schema';
20
+ import { binaryOptions, boolOptions, intOptions, nullOptions, strOptions } from './tags/options';
9
21
  import { warn } from './warnings';
10
22
  var defaultOptions = {
11
23
  anchorPrefix: 'a',
12
24
  customTags: null,
25
+ indent: 2,
26
+ indentSeq: true,
13
27
  keepCstNodes: false,
14
28
  keepNodeTypes: true,
15
29
  keepBlobsInJSON: true,
@@ -20,6 +34,48 @@ var defaultOptions = {
20
34
  simpleKeys: false,
21
35
  version: '1.2'
22
36
  };
37
+ var scalarOptions = {
38
+ get binary() {
39
+ return binaryOptions;
40
+ },
41
+
42
+ set binary(opt) {
43
+ Object.assign(binaryOptions, opt);
44
+ },
45
+
46
+ get bool() {
47
+ return boolOptions;
48
+ },
49
+
50
+ set bool(opt) {
51
+ Object.assign(boolOptions, opt);
52
+ },
53
+
54
+ get int() {
55
+ return intOptions;
56
+ },
57
+
58
+ set int(opt) {
59
+ Object.assign(intOptions, opt);
60
+ },
61
+
62
+ get null() {
63
+ return nullOptions;
64
+ },
65
+
66
+ set null(opt) {
67
+ Object.assign(nullOptions, opt);
68
+ },
69
+
70
+ get str() {
71
+ return strOptions;
72
+ },
73
+
74
+ set str(opt) {
75
+ Object.assign(strOptions, opt);
76
+ }
77
+
78
+ };
23
79
 
24
80
  function createNode(value) {
25
81
  var wrapScalars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -38,10 +94,12 @@ function createNode(value) {
38
94
  var Document = /*#__PURE__*/function (_YAMLDocument) {
39
95
  _inherits(Document, _YAMLDocument);
40
96
 
97
+ var _super = _createSuper(Document);
98
+
41
99
  function Document(options) {
42
100
  _classCallCheck(this, Document);
43
101
 
44
- return _possibleConstructorReturn(this, _getPrototypeOf(Document).call(this, Object.assign({}, defaultOptions, options)));
102
+ return _super.call(this, Object.assign({}, defaultOptions, options));
45
103
  }
46
104
 
47
105
  return Document;
@@ -50,12 +108,12 @@ var Document = /*#__PURE__*/function (_YAMLDocument) {
50
108
  function parseAllDocuments(src, options) {
51
109
  var stream = [];
52
110
  var prev;
53
- var _iteratorNormalCompletion = true;
54
- var _didIteratorError = false;
55
- var _iteratorError = undefined;
111
+
112
+ var _iterator = _createForOfIteratorHelper(parseCST(src)),
113
+ _step;
56
114
 
57
115
  try {
58
- for (var _iterator = parseCST(src)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
116
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
59
117
  var cstDoc = _step.value;
60
118
  var doc = new Document(options);
61
119
  doc.parse(cstDoc, prev);
@@ -63,18 +121,9 @@ function parseAllDocuments(src, options) {
63
121
  prev = doc;
64
122
  }
65
123
  } catch (err) {
66
- _didIteratorError = true;
67
- _iteratorError = err;
124
+ _iterator.e(err);
68
125
  } finally {
69
- try {
70
- if (!_iteratorNormalCompletion && _iterator.return != null) {
71
- _iterator.return();
72
- }
73
- } finally {
74
- if (_didIteratorError) {
75
- throw _iteratorError;
76
- }
77
- }
126
+ _iterator.f();
78
127
  }
79
128
 
80
129
  return stream;
@@ -107,7 +156,7 @@ function stringify(value, options) {
107
156
  return String(doc);
108
157
  }
109
158
 
110
- export default {
159
+ export var YAML = {
111
160
  createNode: createNode,
112
161
  defaultOptions: defaultOptions,
113
162
  Document: Document,
@@ -115,5 +164,6 @@ export default {
115
164
  parseAllDocuments: parseAllDocuments,
116
165
  parseCST: parseCST,
117
166
  parseDocument: parseDocument,
167
+ scalarOptions: scalarOptions,
118
168
  stringify: stringify
119
169
  };
@@ -1,7 +1,7 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
- import Collection from './schema/Collection';
3
- import Pair from './schema/Pair';
4
- import Scalar from './schema/Scalar';
2
+ import { Collection } from './schema/Collection';
3
+ import { Pair } from './schema/Pair';
4
+ import { Scalar } from './schema/Scalar';
5
5
 
6
6
  var visit = function visit(node, tags) {
7
7
  if (node && _typeof(node) === 'object') {
@@ -23,6 +23,6 @@ var visit = function visit(node, tags) {
23
23
  return tags;
24
24
  };
25
25
 
26
- export default (function (node) {
26
+ export var listTagNames = function listTagNames(node) {
27
27
  return Object.keys(visit(node, {}));
28
- });
28
+ };