yaml 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/README.md +29 -23
  2. package/browser/dist/Anchors.js +12 -10
  3. package/browser/dist/Document.js +122 -60
  4. package/browser/dist/constants.js +34 -0
  5. package/browser/dist/cst/Alias.js +1 -3
  6. package/browser/dist/cst/BlankLine.js +5 -7
  7. package/browser/dist/cst/BlockValue.js +4 -4
  8. package/browser/dist/cst/Collection.js +8 -8
  9. package/browser/dist/cst/CollectionItem.js +6 -8
  10. package/browser/dist/cst/Comment.js +5 -7
  11. package/browser/dist/cst/Directive.js +5 -7
  12. package/browser/dist/cst/Document.js +8 -10
  13. package/browser/dist/cst/FlowCollection.js +5 -7
  14. package/browser/dist/cst/Node.js +12 -40
  15. package/browser/dist/cst/ParseContext.js +32 -34
  16. package/browser/dist/cst/PlainValue.js +1 -3
  17. package/browser/dist/cst/QuoteDouble.js +1 -3
  18. package/browser/dist/cst/QuoteSingle.js +1 -3
  19. package/browser/dist/cst/Range.js +1 -3
  20. package/browser/dist/cst/getLinePos.js +8 -13
  21. package/browser/dist/cst/parse.js +1 -4
  22. package/browser/dist/deprecation.js +34 -0
  23. package/browser/dist/errors.js +50 -59
  24. package/browser/dist/index.js +7 -4
  25. package/browser/dist/listTagNames.js +1 -3
  26. package/browser/dist/schema/Alias.js +90 -10
  27. package/browser/dist/schema/Collection.js +3 -3
  28. package/browser/dist/schema/Map.js +22 -105
  29. package/browser/dist/schema/Merge.js +74 -1
  30. package/browser/dist/schema/Node.js +1 -3
  31. package/browser/dist/schema/Pair.js +52 -26
  32. package/browser/dist/schema/Scalar.js +3 -5
  33. package/browser/dist/schema/Seq.js +30 -7
  34. package/browser/dist/schema/index.js +158 -82
  35. package/browser/dist/schema/parseMap.js +18 -21
  36. package/browser/dist/schema/parseSeq.js +9 -12
  37. package/browser/dist/{schema/_string.js → stringify.js} +65 -73
  38. package/browser/dist/tags/core.js +132 -0
  39. package/browser/dist/tags/failsafe/index.js +17 -0
  40. package/browser/dist/tags/failsafe/map.js +65 -0
  41. package/browser/dist/tags/failsafe/seq.js +54 -0
  42. package/browser/dist/tags/failsafe/string.js +40 -0
  43. package/browser/dist/tags/index.js +50 -0
  44. package/browser/dist/tags/json.js +103 -0
  45. package/browser/dist/tags/options.js +35 -0
  46. package/browser/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +20 -20
  47. package/browser/dist/tags/yaml-1.1/index.js +177 -0
  48. package/browser/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +25 -25
  49. package/browser/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +9 -13
  50. package/browser/dist/tags/yaml-1.1/set.js +140 -0
  51. package/browser/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +13 -10
  52. package/browser/dist/test-events.js +1 -4
  53. package/browser/dist/toJSON.js +20 -8
  54. package/browser/index.js +1 -0
  55. package/browser/map.js +2 -1
  56. package/browser/pair.js +2 -1
  57. package/browser/parse-cst.js +1 -1
  58. package/browser/scalar.js +2 -1
  59. package/browser/schema.js +7 -3
  60. package/browser/seq.js +2 -1
  61. package/browser/types/binary.js +7 -1
  62. package/browser/types/omap.js +2 -1
  63. package/browser/types/pairs.js +2 -1
  64. package/browser/types/set.js +2 -1
  65. package/browser/types/timestamp.js +10 -1
  66. package/browser/types.js +11 -0
  67. package/browser/util.js +15 -0
  68. package/dist/Anchors.js +9 -8
  69. package/dist/Document.js +55 -39
  70. package/dist/constants.js +34 -0
  71. package/dist/cst/Alias.js +1 -3
  72. package/dist/cst/BlankLine.js +5 -7
  73. package/dist/cst/BlockValue.js +4 -4
  74. package/dist/cst/Collection.js +8 -8
  75. package/dist/cst/CollectionItem.js +6 -8
  76. package/dist/cst/Comment.js +5 -7
  77. package/dist/cst/Directive.js +5 -7
  78. package/dist/cst/Document.js +8 -10
  79. package/dist/cst/FlowCollection.js +5 -7
  80. package/dist/cst/Node.js +12 -40
  81. package/dist/cst/ParseContext.js +32 -34
  82. package/dist/cst/PlainValue.js +1 -3
  83. package/dist/cst/QuoteDouble.js +1 -3
  84. package/dist/cst/QuoteSingle.js +1 -3
  85. package/dist/cst/Range.js +1 -3
  86. package/dist/cst/getLinePos.js +8 -12
  87. package/dist/cst/parse.js +1 -4
  88. package/dist/deprecation.js +34 -0
  89. package/dist/errors.js +29 -35
  90. package/dist/index.js +7 -4
  91. package/dist/listTagNames.js +1 -3
  92. package/dist/schema/Alias.js +67 -12
  93. package/dist/schema/Map.js +10 -74
  94. package/dist/schema/Merge.js +31 -0
  95. package/dist/schema/Node.js +1 -3
  96. package/dist/schema/Pair.js +46 -20
  97. package/dist/schema/Scalar.js +3 -5
  98. package/dist/schema/Seq.js +9 -5
  99. package/dist/schema/index.js +109 -74
  100. package/dist/schema/parseMap.js +18 -21
  101. package/dist/schema/parseSeq.js +9 -12
  102. package/dist/{schema/_string.js → stringify.js} +56 -65
  103. package/dist/tags/core.js +96 -0
  104. package/dist/tags/failsafe/index.js +17 -0
  105. package/dist/tags/failsafe/map.js +33 -0
  106. package/dist/tags/failsafe/seq.js +34 -0
  107. package/dist/tags/failsafe/string.js +40 -0
  108. package/dist/tags/index.js +50 -0
  109. package/dist/tags/json.js +67 -0
  110. package/dist/tags/options.js +35 -0
  111. package/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +18 -20
  112. package/dist/tags/yaml-1.1/index.js +131 -0
  113. package/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +16 -16
  114. package/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +9 -11
  115. package/dist/{schema/_set.js → tags/yaml-1.1/set.js} +12 -44
  116. package/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +7 -10
  117. package/dist/test-events.js +1 -4
  118. package/dist/toJSON.js +15 -5
  119. package/index.js +1 -0
  120. package/map.js +2 -1
  121. package/package.json +22 -17
  122. package/pair.js +2 -1
  123. package/parse-cst.js +1 -1
  124. package/scalar.js +2 -1
  125. package/schema.js +7 -3
  126. package/seq.js +2 -1
  127. package/types/binary.js +7 -1
  128. package/types/omap.js +2 -1
  129. package/types/pairs.js +2 -1
  130. package/types/set.js +2 -1
  131. package/types/timestamp.js +10 -1
  132. package/types.js +11 -0
  133. package/util.js +15 -0
  134. package/browser/dist/polyfill.js +0 -251
  135. package/browser/dist/schema/_set.js +0 -212
  136. package/browser/dist/schema/core.js +0 -98
  137. package/browser/dist/schema/failsafe.js +0 -125
  138. package/browser/dist/schema/json.js +0 -66
  139. package/browser/dist/schema/yaml-1.1.js +0 -140
  140. package/dist/linePos.js +0 -58
  141. package/dist/polyfill.js +0 -27
  142. package/dist/schema/core.js +0 -79
  143. package/dist/schema/failsafe.js +0 -74
  144. package/dist/schema/json.js +0 -56
  145. package/dist/schema/yaml-1.1.js +0 -115
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
@@ -21,11 +19,13 @@ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
21
19
 
22
20
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
21
 
22
+ var _constants = require("../constants");
23
+
24
24
  var _errors = require("../errors");
25
25
 
26
26
  var _BlankLine = _interopRequireDefault(require("./BlankLine"));
27
27
 
28
- var _Node2 = _interopRequireWildcard(require("./Node"));
28
+ var _Node2 = _interopRequireDefault(require("./Node"));
29
29
 
30
30
  var _Range = _interopRequireDefault(require("./Range"));
31
31
 
@@ -57,7 +57,7 @@ function (_Node) {
57
57
  src = context.src;
58
58
  var atLineStart = context.atLineStart,
59
59
  lineStart = context.lineStart;
60
- if (!atLineStart && this.type === _Node2.Type.SEQ_ITEM) this.error = new _errors.YAMLSemanticError(this, 'Sequence items must not have preceding content on the same line');
60
+ if (!atLineStart && this.type === _constants.Type.SEQ_ITEM) this.error = new _errors.YAMLSemanticError(this, 'Sequence items must not have preceding content on the same line');
61
61
  var indent = atLineStart ? start - lineStart : context.indent;
62
62
 
63
63
  var offset = _Node2.default.endOfWhiteSpace(src, start + 1);
@@ -91,7 +91,7 @@ function (_Node) {
91
91
  ch = src[offset];
92
92
  }
93
93
 
94
- if (_Node2.default.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== _Node2.Type.SEQ_ITEM)) {
94
+ if (_Node2.default.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== _constants.Type.SEQ_ITEM)) {
95
95
  this.node = parseNode({
96
96
  atLineStart: atLineStart,
97
97
  inCollection: false,
@@ -134,6 +134,4 @@ function (_Node) {
134
134
  return CollectionItem;
135
135
  }(_Node2.default);
136
136
 
137
- exports.default = CollectionItem;
138
- module.exports = exports.default;
139
- module.exports.default = exports.default;
137
+ exports.default = CollectionItem;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
@@ -19,7 +17,9 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
19
17
 
20
18
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
19
 
22
- var _Node2 = _interopRequireWildcard(require("./Node"));
20
+ var _constants = require("../constants");
21
+
22
+ var _Node2 = _interopRequireDefault(require("./Node"));
23
23
 
24
24
  var _Range = _interopRequireDefault(require("./Range"));
25
25
 
@@ -30,7 +30,7 @@ function (_Node) {
30
30
 
31
31
  function Comment() {
32
32
  (0, _classCallCheck2.default)(this, Comment);
33
- return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Comment).call(this, _Node2.Type.COMMENT));
33
+ return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Comment).call(this, _constants.Type.COMMENT));
34
34
  }
35
35
  /**
36
36
  * Parses a comment line from the source
@@ -53,6 +53,4 @@ function (_Node) {
53
53
  return Comment;
54
54
  }(_Node2.default);
55
55
 
56
- exports.default = Comment;
57
- module.exports = exports.default;
58
- module.exports.default = exports.default;
56
+ exports.default = Comment;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
@@ -19,7 +17,9 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
19
17
 
20
18
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
19
 
22
- var _Node2 = _interopRequireWildcard(require("./Node"));
20
+ var _constants = require("../constants");
21
+
22
+ var _Node2 = _interopRequireDefault(require("./Node"));
23
23
 
24
24
  var _Range = _interopRequireDefault(require("./Range"));
25
25
 
@@ -52,7 +52,7 @@ function (_Node) {
52
52
  var _this;
53
53
 
54
54
  (0, _classCallCheck2.default)(this, Directive);
55
- _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Directive).call(this, _Node2.Type.DIRECTIVE));
55
+ _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Directive).call(this, _constants.Type.DIRECTIVE));
56
56
  _this.name = null;
57
57
  return _this;
58
58
  }
@@ -105,6 +105,4 @@ function (_Node) {
105
105
  return Directive;
106
106
  }(_Node2.default);
107
107
 
108
- exports.default = Directive;
109
- module.exports = exports.default;
110
- module.exports.default = exports.default;
108
+ exports.default = Directive;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
@@ -21,6 +19,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
21
19
 
22
20
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
21
 
22
+ var _constants = require("../constants");
23
+
24
24
  var _errors = require("../errors");
25
25
 
26
26
  var _BlankLine = _interopRequireDefault(require("./BlankLine"));
@@ -31,7 +31,7 @@ var _Comment = _interopRequireDefault(require("./Comment"));
31
31
 
32
32
  var _Directive = _interopRequireDefault(require("./Directive"));
33
33
 
34
- var _Node2 = _interopRequireWildcard(require("./Node"));
34
+ var _Node2 = _interopRequireDefault(require("./Node"));
35
35
 
36
36
  var _Range = _interopRequireDefault(require("./Range"));
37
37
 
@@ -53,7 +53,7 @@ function (_Node) {
53
53
  var _this;
54
54
 
55
55
  (0, _classCallCheck2.default)(this, Document);
56
- _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Document).call(this, _Node2.Type.DOCUMENT));
56
+ _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Document).call(this, _constants.Type.DOCUMENT));
57
57
  _this.directives = null;
58
58
  _this.contents = null;
59
59
  return _this;
@@ -68,7 +68,7 @@ function (_Node) {
68
68
  var hasDirectives = false;
69
69
  var offset = start;
70
70
 
71
- while (!_Node2.default.atDocumentBoundary(src, offset, _Node2.Char.DIRECTIVES_END)) {
71
+ while (!_Node2.default.atDocumentBoundary(src, offset, _constants.Char.DIRECTIVES_END)) {
72
72
  offset = Document.startCommentOrEndBlankLine(src, offset);
73
73
 
74
74
  switch (src[offset]) {
@@ -154,7 +154,7 @@ function (_Node) {
154
154
  var atLineStart = lineStart === start;
155
155
  this.valueRange = new _Range.default(offset);
156
156
 
157
- while (!_Node2.default.atDocumentBoundary(src, offset, _Node2.Char.DOCUMENT_END)) {
157
+ while (!_Node2.default.atDocumentBoundary(src, offset, _constants.Char.DOCUMENT_END)) {
158
158
  switch (src[offset]) {
159
159
  case '\n':
160
160
  if (atLineStart) {
@@ -284,7 +284,7 @@ function (_Node) {
284
284
  var str = directives.join('');
285
285
 
286
286
  if (contents.length > 0) {
287
- if (directives.length > 0 || contents[0].type === _Node2.Type.COMMENT) str += '---\n';
287
+ if (directives.length > 0 || contents[0].type === _constants.Type.COMMENT) str += '---\n';
288
288
  str += contents.join('');
289
289
  }
290
290
 
@@ -295,6 +295,4 @@ function (_Node) {
295
295
  return Document;
296
296
  }(_Node2.default);
297
297
 
298
- exports.default = Document;
299
- module.exports = exports.default;
300
- module.exports.default = exports.default;
298
+ exports.default = Document;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
@@ -21,13 +19,15 @@ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
21
19
 
22
20
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
21
 
22
+ var _constants = require("../constants");
23
+
24
24
  var _errors = require("../errors");
25
25
 
26
26
  var _BlankLine = _interopRequireDefault(require("./BlankLine"));
27
27
 
28
28
  var _Comment = _interopRequireDefault(require("./Comment"));
29
29
 
30
- var _Node2 = _interopRequireWildcard(require("./Node"));
30
+ var _Node2 = _interopRequireDefault(require("./Node"));
31
31
 
32
32
  var _Range = _interopRequireDefault(require("./Range"));
33
33
 
@@ -50,7 +50,7 @@ function (_Node) {
50
50
  value: function prevNodeIsJsonLike() {
51
51
  var idx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items.length;
52
52
  var node = this.items[idx - 1];
53
- return !!node && (node.jsonLike || node.type === _Node2.Type.COMMENT && this.nodeIsJsonLike(idx - 1));
53
+ return !!node && (node.jsonLike || node.type === _constants.Type.COMMENT && this.nodeIsJsonLike(idx - 1));
54
54
  }
55
55
  /**
56
56
  * @param {ParseContext} context
@@ -228,6 +228,4 @@ function (_Node) {
228
228
  return FlowCollection;
229
229
  }(_Node2.default);
230
230
 
231
- exports.default = FlowCollection;
232
- module.exports = exports.default;
233
- module.exports.default = exports.default;
231
+ exports.default = FlowCollection;
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = exports.Char = exports.Type = void 0;
8
+ exports.default = void 0;
9
9
 
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
 
@@ -13,41 +13,13 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
13
13
 
14
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
15
 
16
+ var _constants = require("../constants");
17
+
16
18
  var _getLinePos = _interopRequireDefault(require("./getLinePos"));
17
19
 
18
20
  var _Range = _interopRequireDefault(require("./Range"));
19
21
 
20
- var Type = {
21
- ALIAS: 'ALIAS',
22
- BLANK_LINE: 'BLANK_LINE',
23
- BLOCK_FOLDED: 'BLOCK_FOLDED',
24
- BLOCK_LITERAL: 'BLOCK_LITERAL',
25
- COMMENT: 'COMMENT',
26
- DIRECTIVE: 'DIRECTIVE',
27
- DOCUMENT: 'DOCUMENT',
28
- FLOW_MAP: 'FLOW_MAP',
29
- FLOW_SEQ: 'FLOW_SEQ',
30
- MAP: 'MAP',
31
- MAP_KEY: 'MAP_KEY',
32
- MAP_VALUE: 'MAP_VALUE',
33
- PLAIN: 'PLAIN',
34
- QUOTE_DOUBLE: 'QUOTE_DOUBLE',
35
- QUOTE_SINGLE: 'QUOTE_SINGLE',
36
- SEQ: 'SEQ',
37
- SEQ_ITEM: 'SEQ_ITEM'
38
- };
39
- exports.Type = Type;
40
- var Char = {
41
- ANCHOR: '&',
42
- COMMENT: '#',
43
- TAG: '!',
44
- DIRECTIVES_END: '-',
45
- DOCUMENT_END: '.'
46
- /** Root class of all nodes */
47
-
48
- };
49
- exports.Char = Char;
50
-
22
+ /** Root class of all nodes */
51
23
  var Node =
52
24
  /*#__PURE__*/
53
25
  function () {
@@ -70,7 +42,7 @@ function () {
70
42
  if (sep) {
71
43
  if (ch0 !== sep) return false;
72
44
  } else {
73
- if (ch0 !== Char.DIRECTIVES_END && ch0 !== Char.DOCUMENT_END) return false;
45
+ if (ch0 !== _constants.Char.DIRECTIVES_END && ch0 !== _constants.Char.DOCUMENT_END) return false;
74
46
  }
75
47
 
76
48
  var ch1 = src[offset + 1];
@@ -264,7 +236,7 @@ function () {
264
236
  value: function parseComment(start) {
265
237
  var src = this.context.src;
266
238
 
267
- if (src[start] === Char.COMMENT) {
239
+ if (src[start] === _constants.Char.COMMENT) {
268
240
  var end = Node.endOfLine(src, start + 1);
269
241
  var commentRange = new _Range.default(start, end);
270
242
  this.props.push(commentRange);
@@ -306,7 +278,7 @@ function () {
306
278
  key: "anchor",
307
279
  get: function get() {
308
280
  for (var i = 0; i < this.props.length; ++i) {
309
- var anchor = this.getPropValue(i, Char.ANCHOR, true);
281
+ var anchor = this.getPropValue(i, _constants.Char.ANCHOR, true);
310
282
  if (anchor != null) return anchor;
311
283
  }
312
284
 
@@ -318,7 +290,7 @@ function () {
318
290
  var comments = [];
319
291
 
320
292
  for (var i = 0; i < this.props.length; ++i) {
321
- var comment = this.getPropValue(i, Char.COMMENT, true);
293
+ var comment = this.getPropValue(i, _constants.Char.COMMENT, true);
322
294
  if (comment != null) comments.push(comment);
323
295
  }
324
296
 
@@ -331,7 +303,7 @@ function () {
331
303
  var src = this.context.src;
332
304
 
333
305
  for (var i = 0; i < this.props.length; ++i) {
334
- if (src[this.props[i].start] === Char.COMMENT) return true;
306
+ if (src[this.props[i].start] === _constants.Char.COMMENT) return true;
335
307
  }
336
308
  }
337
309
 
@@ -344,7 +316,7 @@ function () {
344
316
  var src = this.context.src;
345
317
 
346
318
  for (var i = 0; i < this.props.length; ++i) {
347
- if (src[this.props[i].start] !== Char.COMMENT) return true;
319
+ if (src[this.props[i].start] !== _constants.Char.COMMENT) return true;
348
320
  }
349
321
  }
350
322
 
@@ -358,7 +330,7 @@ function () {
358
330
  }, {
359
331
  key: "jsonLike",
360
332
  get: function get() {
361
- var jsonLikeTypes = [Type.FLOW_MAP, Type.FLOW_SEQ, Type.QUOTE_DOUBLE, Type.QUOTE_SINGLE];
333
+ var jsonLikeTypes = [_constants.Type.FLOW_MAP, _constants.Type.FLOW_SEQ, _constants.Type.QUOTE_DOUBLE, _constants.Type.QUOTE_SINGLE];
362
334
  return jsonLikeTypes.indexOf(this.type) !== -1;
363
335
  }
364
336
  }, {
@@ -386,7 +358,7 @@ function () {
386
358
  key: "tag",
387
359
  get: function get() {
388
360
  for (var i = 0; i < this.props.length; ++i) {
389
- var tag = this.getPropValue(i, Char.TAG, false);
361
+ var tag = this.getPropValue(i, _constants.Char.TAG, false);
390
362
 
391
363
  if (tag != null) {
392
364
  if (tag[1] === '<') {
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
@@ -15,6 +13,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
15
13
 
16
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
15
 
16
+ var _constants = require("../constants");
17
+
18
18
  var _errors = require("../errors");
19
19
 
20
20
  var _Alias = _interopRequireDefault(require("./Alias"));
@@ -27,7 +27,7 @@ var _CollectionItem = _interopRequireDefault(require("./CollectionItem"));
27
27
 
28
28
  var _FlowCollection = _interopRequireDefault(require("./FlowCollection"));
29
29
 
30
- var _Node = _interopRequireWildcard(require("./Node"));
30
+ var _Node = _interopRequireDefault(require("./Node"));
31
31
 
32
32
  var _PlainValue = _interopRequireDefault(require("./PlainValue"));
33
33
 
@@ -54,37 +54,37 @@ function () {
54
54
  value: function parseType(src, offset, inFlow) {
55
55
  switch (src[offset]) {
56
56
  case '*':
57
- return _Node.Type.ALIAS;
57
+ return _constants.Type.ALIAS;
58
58
 
59
59
  case '>':
60
- return _Node.Type.BLOCK_FOLDED;
60
+ return _constants.Type.BLOCK_FOLDED;
61
61
 
62
62
  case '|':
63
- return _Node.Type.BLOCK_LITERAL;
63
+ return _constants.Type.BLOCK_LITERAL;
64
64
 
65
65
  case '{':
66
- return _Node.Type.FLOW_MAP;
66
+ return _constants.Type.FLOW_MAP;
67
67
 
68
68
  case '[':
69
- return _Node.Type.FLOW_SEQ;
69
+ return _constants.Type.FLOW_SEQ;
70
70
 
71
71
  case '?':
72
- return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _Node.Type.MAP_KEY : _Node.Type.PLAIN;
72
+ return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _constants.Type.MAP_KEY : _constants.Type.PLAIN;
73
73
 
74
74
  case ':':
75
- return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _Node.Type.MAP_VALUE : _Node.Type.PLAIN;
75
+ return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _constants.Type.MAP_VALUE : _constants.Type.PLAIN;
76
76
 
77
77
  case '-':
78
- return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _Node.Type.SEQ_ITEM : _Node.Type.PLAIN;
78
+ return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? _constants.Type.SEQ_ITEM : _constants.Type.PLAIN;
79
79
 
80
80
  case '"':
81
- return _Node.Type.QUOTE_DOUBLE;
81
+ return _constants.Type.QUOTE_DOUBLE;
82
82
 
83
83
  case "'":
84
- return _Node.Type.QUOTE_SINGLE;
84
+ return _constants.Type.QUOTE_SINGLE;
85
85
 
86
86
  default:
87
- return _Node.Type.PLAIN;
87
+ return _constants.Type.PLAIN;
88
88
  }
89
89
  }
90
90
  }]);
@@ -115,36 +115,36 @@ function () {
115
115
  var node;
116
116
 
117
117
  switch (type) {
118
- case _Node.Type.ALIAS:
118
+ case _constants.Type.ALIAS:
119
119
  node = new _Alias.default(type, props);
120
120
  break;
121
121
 
122
- case _Node.Type.BLOCK_FOLDED:
123
- case _Node.Type.BLOCK_LITERAL:
122
+ case _constants.Type.BLOCK_FOLDED:
123
+ case _constants.Type.BLOCK_LITERAL:
124
124
  node = new _BlockValue.default(type, props);
125
125
  break;
126
126
 
127
- case _Node.Type.FLOW_MAP:
128
- case _Node.Type.FLOW_SEQ:
127
+ case _constants.Type.FLOW_MAP:
128
+ case _constants.Type.FLOW_SEQ:
129
129
  node = new _FlowCollection.default(type, props);
130
130
  break;
131
131
 
132
- case _Node.Type.MAP_KEY:
133
- case _Node.Type.MAP_VALUE:
134
- case _Node.Type.SEQ_ITEM:
132
+ case _constants.Type.MAP_KEY:
133
+ case _constants.Type.MAP_VALUE:
134
+ case _constants.Type.SEQ_ITEM:
135
135
  node = new _CollectionItem.default(type, props);
136
136
  break;
137
137
 
138
- case _Node.Type.COMMENT:
139
- case _Node.Type.PLAIN:
138
+ case _constants.Type.COMMENT:
139
+ case _constants.Type.PLAIN:
140
140
  node = new _PlainValue.default(type, props);
141
141
  break;
142
142
 
143
- case _Node.Type.QUOTE_DOUBLE:
143
+ case _constants.Type.QUOTE_DOUBLE:
144
144
  node = new _QuoteDouble.default(type, props);
145
145
  break;
146
146
 
147
- case _Node.Type.QUOTE_SINGLE:
147
+ case _constants.Type.QUOTE_SINGLE:
148
148
  node = new _QuoteSingle.default(type, props);
149
149
  break;
150
150
 
@@ -165,7 +165,7 @@ function () {
165
165
  }
166
166
 
167
167
  if (context.nodeStartsCollection(node)) {
168
- if (!node.error && !context.atLineStart && context.parent.type === _Node.Type.DOCUMENT) {
168
+ if (!node.error && !context.atLineStart && context.parent.type === _constants.Type.DOCUMENT) {
169
169
  node.error = new _errors.YAMLSyntaxError(node, 'Block collection must not have preceding content here (e.g. directives-end indicator)');
170
170
  }
171
171
 
@@ -215,20 +215,20 @@ function () {
215
215
  offset = _Node.default.endOfWhiteSpace(src, offset);
216
216
  var ch = src[offset];
217
217
 
218
- while (ch === _Node.Char.ANCHOR || ch === _Node.Char.COMMENT || ch === _Node.Char.TAG || ch === '\n') {
218
+ while (ch === _constants.Char.ANCHOR || ch === _constants.Char.COMMENT || ch === _constants.Char.TAG || ch === '\n') {
219
219
  if (ch === '\n') {
220
220
  var lineStart = offset + 1;
221
221
 
222
222
  var inEnd = _Node.default.endOfIndent(src, lineStart);
223
223
 
224
224
  var indentDiff = inEnd - (lineStart + this.indent);
225
- var noIndicatorAsIndent = parent.type === _Node.Type.SEQ_ITEM && parent.context.atLineStart;
225
+ var noIndicatorAsIndent = parent.type === _constants.Type.SEQ_ITEM && parent.context.atLineStart;
226
226
  if (!_Node.default.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break;
227
227
  this.atLineStart = true;
228
228
  this.lineStart = lineStart;
229
229
  lineHasProps = false;
230
230
  offset = inEnd;
231
- } else if (ch === _Node.Char.COMMENT) {
231
+ } else if (ch === _constants.Char.COMMENT) {
232
232
  var end = _Node.default.endOfLine(src, offset + 1);
233
233
 
234
234
  props.push(new _Range.default(offset, end));
@@ -236,7 +236,7 @@ function () {
236
236
  } else {
237
237
  var _end = _Node.default.endOfIdentifier(src, offset + 1);
238
238
 
239
- if (ch === _Node.Char.TAG && src[_end] === ',' && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(src.slice(offset + 1, _end + 13))) {
239
+ if (ch === _constants.Char.TAG && src[_end] === ',' && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(src.slice(offset + 1, _end + 13))) {
240
240
  // Let's presume we're dealing with a YAML 1.0 domain tag here, rather
241
241
  // than an empty but 'foo.bar' private-tagged node in a flow collection
242
242
  // followed without whitespace by a plain string starting with a year
@@ -285,6 +285,4 @@ function () {
285
285
  return ParseContext;
286
286
  }();
287
287
 
288
- exports.default = ParseContext;
289
- module.exports = exports.default;
290
- module.exports.default = exports.default;
288
+ exports.default = ParseContext;
@@ -180,6 +180,4 @@ function (_Node) {
180
180
  return PlainValue;
181
181
  }(_Node2.default);
182
182
 
183
- exports.default = PlainValue;
184
- module.exports = exports.default;
185
- module.exports.default = exports.default;
183
+ exports.default = PlainValue;
@@ -254,6 +254,4 @@ function (_Node) {
254
254
  return QuoteDouble;
255
255
  }(_Node2.default);
256
256
 
257
- exports.default = QuoteDouble;
258
- module.exports = exports.default;
259
- module.exports.default = exports.default;
257
+ exports.default = QuoteDouble;
@@ -129,6 +129,4 @@ function (_Node) {
129
129
  return QuoteSingle;
130
130
  }(_Node2.default);
131
131
 
132
- exports.default = QuoteSingle;
133
- module.exports = exports.default;
134
- module.exports.default = exports.default;
132
+ exports.default = QuoteSingle;
@@ -74,6 +74,4 @@ function () {
74
74
  return Range;
75
75
  }();
76
76
 
77
- exports.default = Range;
78
- module.exports = exports.default;
79
- module.exports.default = exports.default;
77
+ exports.default = Range;
@@ -24,7 +24,7 @@ function findLineStarts(src) {
24
24
  * the latter, starting indices for lines are cached in the document as
25
25
  * `lineStarts: number[]`.
26
26
  *
27
- * Returns a zero-indexed `{ line, col }` location if found, or
27
+ * Returns a one-indexed `{ line, col }` location if found, or
28
28
  * `undefined` otherwise.
29
29
  *
30
30
  * @param {number} offset
@@ -55,30 +55,25 @@ function getLinePos(offset, cst) {
55
55
  var start = lineStarts[i];
56
56
 
57
57
  if (offset < start) {
58
- var _line = i - 1;
59
-
60
58
  return {
61
- line: _line,
62
- col: offset - lineStarts[_line]
59
+ line: i,
60
+ col: offset - lineStarts[i - 1] + 1
63
61
  };
64
62
  }
65
63
 
66
64
  if (offset === start) return {
67
- line: i,
68
- col: 0
65
+ line: i + 1,
66
+ col: 1
69
67
  };
70
68
  }
71
69
 
72
- var line = lineStarts.length - 1;
70
+ var line = lineStarts.length;
73
71
  return {
74
72
  line: line,
75
- col: offset - lineStarts[line]
73
+ col: offset - lineStarts[line - 1] + 1
76
74
  };
77
75
  }
78
76
  }
79
77
 
80
78
  return undefined;
81
- }
82
-
83
- module.exports = exports.default;
84
- module.exports.default = exports.default;
79
+ }
@@ -56,7 +56,4 @@ function parse(src) {
56
56
  };
57
57
 
58
58
  return documents;
59
- }
60
-
61
- module.exports = exports.default;
62
- module.exports.default = exports.default;
59
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.warnFileDeprecation = warnFileDeprecation;
7
+ exports.warnOptionDeprecation = warnOptionDeprecation;
8
+
9
+ /* global global, console */
10
+ function warn(msg) {
11
+ if (global && global.process && global.process.emitWarning) {
12
+ global.process.emitWarning(msg, 'DeprecationWarning');
13
+ } else {
14
+ // eslint-disable-next-line no-console
15
+ console.warn("DeprecationWarning: ".concat(msg));
16
+ }
17
+ }
18
+
19
+ function warnFileDeprecation(filename) {
20
+ if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
21
+ var path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
22
+ warn("The endpoint 'yaml/".concat(path, "' will be removed in a future release."));
23
+ }
24
+
25
+ var warned = {};
26
+
27
+ function warnOptionDeprecation(name, alternative) {
28
+ if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
29
+ if (warned[name]) return;
30
+ warned[name] = true;
31
+ var msg = "The option '".concat(name, "' will be removed in a future release");
32
+ msg += alternative ? ", use '".concat(alternative, "' instead.") : '.';
33
+ warn(msg);
34
+ }