yaml 1.4.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 (136) hide show
  1. package/README.md +3 -5
  2. package/browser/dist/Anchors.js +1 -3
  3. package/browser/dist/Document.js +94 -37
  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 +7 -7
  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 +1 -4
  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 +5 -4
  25. package/browser/dist/listTagNames.js +1 -3
  26. package/browser/dist/schema/Alias.js +85 -10
  27. package/browser/dist/schema/Map.js +14 -121
  28. package/browser/dist/schema/Merge.js +74 -1
  29. package/browser/dist/schema/Node.js +1 -3
  30. package/browser/dist/schema/Pair.js +36 -22
  31. package/browser/dist/schema/Scalar.js +1 -3
  32. package/browser/dist/schema/Seq.js +1 -3
  33. package/browser/dist/schema/index.js +61 -45
  34. package/browser/dist/schema/parseMap.js +18 -21
  35. package/browser/dist/schema/parseSeq.js +9 -12
  36. package/browser/dist/stringify.js +54 -39
  37. package/browser/dist/{schema → tags}/core.js +32 -20
  38. package/browser/dist/tags/failsafe/index.js +17 -0
  39. package/browser/dist/tags/failsafe/map.js +65 -0
  40. package/browser/dist/tags/failsafe/seq.js +54 -0
  41. package/browser/dist/{schema/_string.js → tags/failsafe/string.js} +11 -11
  42. package/browser/dist/tags/index.js +50 -0
  43. package/browser/dist/{schema → tags}/json.js +8 -8
  44. package/browser/dist/tags/options.js +35 -0
  45. package/browser/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +16 -22
  46. package/browser/dist/{schema/yaml-1.1.js → tags/yaml-1.1/index.js} +43 -29
  47. package/browser/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +8 -11
  48. package/browser/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +8 -12
  49. package/browser/dist/tags/yaml-1.1/set.js +140 -0
  50. package/browser/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +4 -7
  51. package/browser/dist/test-events.js +1 -4
  52. package/browser/dist/toJSON.js +1 -4
  53. package/browser/index.js +1 -0
  54. package/browser/map.js +2 -1
  55. package/browser/pair.js +2 -1
  56. package/browser/parse-cst.js +1 -1
  57. package/browser/scalar.js +2 -1
  58. package/browser/schema.js +7 -4
  59. package/browser/seq.js +2 -1
  60. package/browser/types/binary.js +7 -1
  61. package/browser/types/omap.js +2 -1
  62. package/browser/types/pairs.js +2 -1
  63. package/browser/types/set.js +2 -1
  64. package/browser/types/timestamp.js +10 -1
  65. package/browser/types.js +11 -0
  66. package/browser/util.js +15 -0
  67. package/dist/Anchors.js +1 -3
  68. package/dist/Document.js +38 -25
  69. package/dist/constants.js +34 -0
  70. package/dist/cst/Alias.js +1 -3
  71. package/dist/cst/BlankLine.js +5 -7
  72. package/dist/cst/BlockValue.js +4 -4
  73. package/dist/cst/Collection.js +7 -7
  74. package/dist/cst/CollectionItem.js +6 -8
  75. package/dist/cst/Comment.js +5 -7
  76. package/dist/cst/Directive.js +5 -7
  77. package/dist/cst/Document.js +8 -10
  78. package/dist/cst/FlowCollection.js +5 -7
  79. package/dist/cst/Node.js +12 -40
  80. package/dist/cst/ParseContext.js +32 -34
  81. package/dist/cst/PlainValue.js +1 -3
  82. package/dist/cst/QuoteDouble.js +1 -3
  83. package/dist/cst/QuoteSingle.js +1 -3
  84. package/dist/cst/Range.js +1 -3
  85. package/dist/cst/getLinePos.js +1 -4
  86. package/dist/cst/parse.js +1 -4
  87. package/dist/deprecation.js +34 -0
  88. package/dist/errors.js +29 -35
  89. package/dist/index.js +5 -4
  90. package/dist/listTagNames.js +1 -3
  91. package/dist/schema/Alias.js +66 -12
  92. package/dist/schema/Map.js +9 -77
  93. package/dist/schema/Merge.js +31 -0
  94. package/dist/schema/Node.js +1 -3
  95. package/dist/schema/Pair.js +29 -15
  96. package/dist/schema/Scalar.js +1 -3
  97. package/dist/schema/Seq.js +1 -3
  98. package/dist/schema/index.js +55 -45
  99. package/dist/schema/parseMap.js +18 -21
  100. package/dist/schema/parseSeq.js +9 -12
  101. package/dist/stringify.js +46 -32
  102. package/dist/{schema → tags}/core.js +32 -19
  103. package/dist/tags/failsafe/index.js +17 -0
  104. package/dist/tags/failsafe/map.js +33 -0
  105. package/dist/tags/failsafe/seq.js +34 -0
  106. package/dist/tags/failsafe/string.js +40 -0
  107. package/dist/tags/index.js +50 -0
  108. package/dist/{schema → tags}/json.js +8 -8
  109. package/dist/tags/options.js +35 -0
  110. package/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +15 -21
  111. package/dist/{schema/yaml-1.1.js → tags/yaml-1.1/index.js} +43 -30
  112. package/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +8 -9
  113. package/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +8 -10
  114. package/dist/{schema/_set.js → tags/yaml-1.1/set.js} +9 -42
  115. package/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +4 -7
  116. package/dist/test-events.js +1 -4
  117. package/dist/toJSON.js +1 -4
  118. package/index.js +1 -0
  119. package/map.js +2 -1
  120. package/package.json +17 -15
  121. package/pair.js +2 -1
  122. package/parse-cst.js +1 -1
  123. package/scalar.js +2 -1
  124. package/schema.js +7 -4
  125. package/seq.js +2 -1
  126. package/types/binary.js +7 -1
  127. package/types/omap.js +2 -1
  128. package/types/pairs.js +2 -1
  129. package/types/set.js +2 -1
  130. package/types/timestamp.js +10 -1
  131. package/types.js +11 -0
  132. package/util.js +15 -0
  133. package/browser/dist/schema/_set.js +0 -215
  134. package/browser/dist/schema/failsafe.js +0 -125
  135. package/dist/schema/_string.js +0 -40
  136. package/dist/schema/failsafe.js +0 -74
@@ -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;
@@ -76,7 +76,4 @@ function getLinePos(offset, cst) {
76
76
  }
77
77
 
78
78
  return undefined;
79
- }
80
-
81
- module.exports = exports.default;
82
- 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
+ }
@@ -5,10 +5,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.YAMLWarning = exports.YAMLSyntaxError = exports.YAMLSemanticError = exports.YAMLReferenceError = void 0;
8
+ exports.YAMLWarning = exports.YAMLSyntaxError = exports.YAMLSemanticError = exports.YAMLReferenceError = exports.YAMLError = void 0;
9
9
 
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
 
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
12
14
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
15
 
14
16
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
@@ -19,106 +21,95 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
19
21
 
20
22
  var _Node = _interopRequireDefault(require("./cst/Node"));
21
23
 
22
- var YAMLReferenceError =
24
+ var YAMLError =
23
25
  /*#__PURE__*/
24
- function (_ReferenceError) {
25
- (0, _inherits2.default)(YAMLReferenceError, _ReferenceError);
26
+ function (_Error) {
27
+ (0, _inherits2.default)(YAMLError, _Error);
26
28
 
27
- function YAMLReferenceError(source, message) {
29
+ function YAMLError(name, source, message) {
28
30
  var _this;
29
31
 
30
- (0, _classCallCheck2.default)(this, YAMLReferenceError);
31
-
32
- if (!message || !(source instanceof _Node.default)) {
33
- throw new Error('Invalid arguments for new YAMLReferenceError');
34
- }
35
-
36
- _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLReferenceError).call(this));
37
- _this.name = 'YAMLReferenceError';
32
+ (0, _classCallCheck2.default)(this, YAMLError);
33
+ if (!message || !(source instanceof _Node.default)) throw new Error("Invalid arguments for new ".concat(name));
34
+ _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLError).call(this));
35
+ _this.name = name;
38
36
  _this.message = message;
39
37
  _this.source = source;
40
38
  return _this;
41
39
  }
42
40
 
41
+ (0, _createClass2.default)(YAMLError, [{
42
+ key: "makePretty",
43
+ value: function makePretty() {
44
+ if (this.source) {
45
+ this.nodeType = this.source.type;
46
+ this.range = this.source.range;
47
+ this.linePos = this.source.rangeAsLinePos;
48
+ delete this.source;
49
+ }
50
+ }
51
+ }]);
52
+ return YAMLError;
53
+ }((0, _wrapNativeSuper2.default)(Error));
54
+
55
+ exports.YAMLError = YAMLError;
56
+
57
+ var YAMLReferenceError =
58
+ /*#__PURE__*/
59
+ function (_YAMLError) {
60
+ (0, _inherits2.default)(YAMLReferenceError, _YAMLError);
61
+
62
+ function YAMLReferenceError(source, message) {
63
+ (0, _classCallCheck2.default)(this, YAMLReferenceError);
64
+ return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLReferenceError).call(this, 'YAMLReferenceError', source, message));
65
+ }
66
+
43
67
  return YAMLReferenceError;
44
- }((0, _wrapNativeSuper2.default)(ReferenceError));
68
+ }(YAMLError);
45
69
 
46
70
  exports.YAMLReferenceError = YAMLReferenceError;
47
71
 
48
72
  var YAMLSemanticError =
49
73
  /*#__PURE__*/
50
- function (_SyntaxError) {
51
- (0, _inherits2.default)(YAMLSemanticError, _SyntaxError);
74
+ function (_YAMLError2) {
75
+ (0, _inherits2.default)(YAMLSemanticError, _YAMLError2);
52
76
 
53
77
  function YAMLSemanticError(source, message) {
54
- var _this2;
55
-
56
78
  (0, _classCallCheck2.default)(this, YAMLSemanticError);
57
-
58
- if (!message || !(source instanceof _Node.default)) {
59
- throw new Error('Invalid arguments for new YAMLSemanticError');
60
- }
61
-
62
- _this2 = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLSemanticError).call(this));
63
- _this2.name = 'YAMLSemanticError';
64
- _this2.message = message;
65
- _this2.source = source;
66
- return _this2;
79
+ return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLSemanticError).call(this, 'YAMLSemanticError', source, message));
67
80
  }
68
81
 
69
82
  return YAMLSemanticError;
70
- }((0, _wrapNativeSuper2.default)(SyntaxError));
83
+ }(YAMLError);
71
84
 
72
85
  exports.YAMLSemanticError = YAMLSemanticError;
73
86
 
74
87
  var YAMLSyntaxError =
75
88
  /*#__PURE__*/
76
- function (_SyntaxError2) {
77
- (0, _inherits2.default)(YAMLSyntaxError, _SyntaxError2);
89
+ function (_YAMLError3) {
90
+ (0, _inherits2.default)(YAMLSyntaxError, _YAMLError3);
78
91
 
79
92
  function YAMLSyntaxError(source, message) {
80
- var _this3;
81
-
82
93
  (0, _classCallCheck2.default)(this, YAMLSyntaxError);
83
-
84
- if (!message || !(source instanceof _Node.default)) {
85
- throw new Error('Invalid arguments for new YAMLSyntaxError');
86
- }
87
-
88
- _this3 = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLSyntaxError).call(this));
89
- _this3.name = 'YAMLSyntaxError';
90
- _this3.message = message;
91
- _this3.source = source;
92
- return _this3;
94
+ return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLSyntaxError).call(this, 'YAMLSyntaxError', source, message));
93
95
  }
94
96
 
95
97
  return YAMLSyntaxError;
96
- }((0, _wrapNativeSuper2.default)(SyntaxError));
98
+ }(YAMLError);
97
99
 
98
100
  exports.YAMLSyntaxError = YAMLSyntaxError;
99
101
 
100
102
  var YAMLWarning =
101
103
  /*#__PURE__*/
102
- function (_Error) {
103
- (0, _inherits2.default)(YAMLWarning, _Error);
104
+ function (_YAMLError4) {
105
+ (0, _inherits2.default)(YAMLWarning, _YAMLError4);
104
106
 
105
107
  function YAMLWarning(source, message) {
106
- var _this4;
107
-
108
108
  (0, _classCallCheck2.default)(this, YAMLWarning);
109
-
110
- if (!message || !(source instanceof _Node.default)) {
111
- throw new Error('Invalid arguments for new YAMLWarning');
112
- }
113
-
114
- _this4 = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLWarning).call(this));
115
- _this4.name = 'YAMLWarning';
116
- _this4.message = message;
117
- _this4.source = source;
118
- return _this4;
109
+ return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(YAMLWarning).call(this, 'YAMLWarning', source, message));
119
110
  }
120
111
 
121
112
  return YAMLWarning;
122
- }((0, _wrapNativeSuper2.default)(Error));
113
+ }(YAMLError);
123
114
 
124
115
  exports.YAMLWarning = YAMLWarning;
@@ -26,11 +26,14 @@ var _schema = _interopRequireDefault(require("./schema"));
26
26
  /* global console */
27
27
  var defaultOptions = {
28
28
  anchorPrefix: 'a',
29
+ customTags: null,
29
30
  keepCstNodes: false,
30
31
  keepNodeTypes: true,
31
32
  keepBlobsInJSON: true,
32
33
  mapAsMap: false,
33
- tags: null,
34
+ maxAliasCount: 100,
35
+ prettyErrors: false,
36
+ // TODO Set true in v2
34
37
  version: '1.2'
35
38
  };
36
39
 
@@ -105,6 +108,4 @@ var _default = {
105
108
  parseDocument: parseDocument,
106
109
  stringify: stringify
107
110
  };
108
- exports.default = _default;
109
- module.exports = exports.default;
110
- module.exports.default = exports.default;
111
+ exports.default = _default;
@@ -39,6 +39,4 @@ var _default = function _default(node) {
39
39
  return Object.keys(visit(node, {}));
40
40
  };
41
41
 
42
- exports.default = _default;
43
- module.exports = exports.default;
44
- module.exports.default = exports.default;
42
+ exports.default = _default;