yaml 1.8.2 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/browser/dist/Anchors.js +10 -13
  2. package/browser/dist/Document.js +72 -67
  3. package/browser/dist/addComment.js +1 -1
  4. package/browser/dist/cst/Alias.js +12 -8
  5. package/browser/dist/cst/BlankLine.js +16 -20
  6. package/browser/dist/cst/BlockValue.js +14 -10
  7. package/browser/dist/cst/Collection.js +17 -13
  8. package/browser/dist/cst/CollectionItem.js +15 -11
  9. package/browser/dist/cst/Comment.js +13 -9
  10. package/browser/dist/cst/Directive.js +13 -9
  11. package/browser/dist/cst/Document.js +17 -13
  12. package/browser/dist/cst/FlowCollection.js +17 -13
  13. package/browser/dist/cst/Node.js +3 -5
  14. package/browser/dist/cst/ParseContext.js +12 -14
  15. package/browser/dist/cst/PlainValue.js +12 -8
  16. package/browser/dist/cst/QuoteDouble.js +13 -9
  17. package/browser/dist/cst/QuoteSingle.js +13 -9
  18. package/browser/dist/cst/Range.js +2 -5
  19. package/browser/dist/cst/parse.js +3 -3
  20. package/browser/dist/errors.js +23 -8
  21. package/browser/dist/foldFlowLines.js +1 -1
  22. package/browser/dist/index.js +71 -21
  23. package/browser/dist/listTagNames.js +5 -5
  24. package/browser/dist/schema/Alias.js +30 -34
  25. package/browser/dist/schema/Collection.js +40 -47
  26. package/browser/dist/schema/Map.js +39 -56
  27. package/browser/dist/schema/Merge.js +37 -46
  28. package/browser/dist/schema/Node.js +2 -5
  29. package/browser/dist/schema/Pair.js +36 -13
  30. package/browser/dist/schema/Scalar.js +13 -9
  31. package/browser/dist/schema/Seq.js +27 -25
  32. package/browser/dist/schema/index.js +25 -39
  33. package/browser/dist/schema/parseMap.js +8 -8
  34. package/browser/dist/schema/parseSeq.js +5 -5
  35. package/browser/dist/schema/parseUtils.js +11 -15
  36. package/browser/dist/stringify.js +2 -1
  37. package/browser/dist/tags/core.js +39 -23
  38. package/browser/dist/tags/failsafe/index.js +4 -4
  39. package/browser/dist/tags/failsafe/map.js +15 -18
  40. package/browser/dist/tags/failsafe/seq.js +14 -18
  41. package/browser/dist/tags/failsafe/string.js +1 -1
  42. package/browser/dist/tags/index.js +10 -10
  43. package/browser/dist/tags/json.js +27 -26
  44. package/browser/dist/tags/options.js +3 -0
  45. package/browser/dist/tags/yaml-1.1/binary.js +10 -8
  46. package/browser/dist/tags/yaml-1.1/index.js +75 -43
  47. package/browser/dist/tags/yaml-1.1/omap.js +34 -39
  48. package/browser/dist/tags/yaml-1.1/pairs.js +17 -20
  49. package/browser/dist/tags/yaml-1.1/set.js +27 -23
  50. package/browser/dist/test-events.js +4 -4
  51. package/browser/dist/toJSON.js +3 -4
  52. package/browser/dist/warnings.js +29 -18
  53. package/browser/index.js +1 -1
  54. package/browser/map.js +4 -2
  55. package/browser/pair.js +4 -2
  56. package/browser/parse-cst.js +1 -1
  57. package/browser/scalar.js +4 -2
  58. package/browser/schema.js +11 -6
  59. package/browser/seq.js +4 -2
  60. package/browser/types/binary.js +5 -6
  61. package/browser/types/omap.js +4 -2
  62. package/browser/types/pairs.js +4 -2
  63. package/browser/types/set.js +4 -2
  64. package/browser/types/timestamp.js +5 -9
  65. package/browser/types.js +12 -10
  66. package/browser/util.js +16 -13
  67. package/dist/Anchors.js +13 -18
  68. package/dist/Document.js +52 -48
  69. package/dist/addComment.js +1 -4
  70. package/dist/constants.js +0 -3
  71. package/dist/cst/Alias.js +8 -13
  72. package/dist/cst/BlankLine.js +8 -24
  73. package/dist/cst/BlockValue.js +12 -17
  74. package/dist/cst/Collection.js +22 -27
  75. package/dist/cst/CollectionItem.js +16 -21
  76. package/dist/cst/Comment.js +6 -11
  77. package/dist/cst/Directive.js +7 -12
  78. package/dist/cst/Document.js +23 -28
  79. package/dist/cst/FlowCollection.js +21 -26
  80. package/dist/cst/Node.js +4 -9
  81. package/dist/cst/ParseContext.js +38 -43
  82. package/dist/cst/PlainValue.js +10 -15
  83. package/dist/cst/QuoteDouble.js +9 -14
  84. package/dist/cst/QuoteSingle.js +9 -14
  85. package/dist/cst/Range.js +2 -5
  86. package/dist/cst/parse.js +5 -10
  87. package/dist/cst/source-utils.js +0 -3
  88. package/dist/errors.js +4 -9
  89. package/dist/foldFlowLines.js +1 -4
  90. package/dist/index.js +59 -17
  91. package/dist/listTagNames.js +9 -14
  92. package/dist/schema/Alias.js +12 -17
  93. package/dist/schema/Collection.js +16 -20
  94. package/dist/schema/Map.js +12 -17
  95. package/dist/schema/Merge.js +13 -18
  96. package/dist/schema/Node.js +2 -5
  97. package/dist/schema/Pair.js +44 -31
  98. package/dist/schema/Scalar.js +6 -11
  99. package/dist/schema/Seq.js +9 -14
  100. package/dist/schema/index.js +22 -27
  101. package/dist/schema/parseMap.js +19 -28
  102. package/dist/schema/parseSeq.js +10 -15
  103. package/dist/schema/parseUtils.js +0 -3
  104. package/dist/stringify.js +6 -12
  105. package/dist/tags/core.js +34 -26
  106. package/dist/tags/failsafe/index.js +6 -11
  107. package/dist/tags/failsafe/map.js +8 -13
  108. package/dist/tags/failsafe/seq.js +8 -13
  109. package/dist/tags/failsafe/string.js +3 -6
  110. package/dist/tags/index.js +20 -29
  111. package/dist/tags/json.js +26 -22
  112. package/dist/tags/options.js +5 -4
  113. package/dist/tags/yaml-1.1/binary.js +11 -11
  114. package/dist/tags/yaml-1.1/index.js +69 -38
  115. package/dist/tags/yaml-1.1/omap.js +19 -24
  116. package/dist/tags/yaml-1.1/pairs.js +12 -17
  117. package/dist/tags/yaml-1.1/set.js +12 -21
  118. package/dist/tags/yaml-1.1/timestamp.js +0 -3
  119. package/dist/test-events.js +4 -9
  120. package/dist/toJSON.js +3 -5
  121. package/dist/warnings.js +31 -22
  122. package/index.d.ts +358 -0
  123. package/index.js +1 -1
  124. package/map.js +1 -1
  125. package/package.json +29 -23
  126. package/pair.js +1 -1
  127. package/parse-cst.d.ts +187 -0
  128. package/parse-cst.js +1 -1
  129. package/scalar.js +1 -1
  130. package/schema.js +2 -2
  131. package/seq.js +1 -1
  132. package/types/binary.js +1 -1
  133. package/types/omap.js +1 -1
  134. package/types/pairs.js +1 -1
  135. package/types/set.js +1 -1
  136. package/types/timestamp.js +1 -1
  137. package/types.d.ts +393 -0
  138. package/types.js +7 -6
  139. package/types.mjs +6 -5
  140. package/util.d.ts +86 -0
  141. package/util.js +6 -5
  142. package/util.mjs +4 -3
package/dist/Document.js CHANGED
@@ -1,37 +1,28 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
3
+ exports.Document = void 0;
7
4
 
8
- var _addComment = _interopRequireDefault(require("./addComment"));
5
+ var _addComment = require("./addComment");
9
6
 
10
- var _Anchors = _interopRequireDefault(require("./Anchors"));
7
+ var _Anchors = require("./Anchors");
11
8
 
12
9
  var _constants = require("./constants");
13
10
 
14
11
  var _errors = require("./errors");
15
12
 
16
- var _listTagNames = _interopRequireDefault(require("./listTagNames"));
13
+ var _listTagNames = require("./listTagNames");
17
14
 
18
- var _schema = _interopRequireDefault(require("./schema"));
15
+ var _schema = require("./schema");
19
16
 
20
- var _Alias = _interopRequireDefault(require("./schema/Alias"));
17
+ var _Alias = require("./schema/Alias");
21
18
 
22
- var _Collection = _interopRequireWildcard(require("./schema/Collection"));
19
+ var _Collection = require("./schema/Collection");
23
20
 
24
- var _Node = _interopRequireDefault(require("./schema/Node"));
21
+ var _Node = require("./schema/Node");
25
22
 
26
- var _Scalar = _interopRequireDefault(require("./schema/Scalar"));
23
+ var _Scalar = require("./schema/Scalar");
27
24
 
28
- var _toJSON = _interopRequireDefault(require("./toJSON"));
29
-
30
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
31
-
32
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
-
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+ var _toJSON = require("./toJSON");
35
26
 
36
27
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
28
 
@@ -39,7 +30,7 @@ const isCollectionItem = node => node && [_constants.Type.MAP_KEY, _constants.Ty
39
30
 
40
31
  class Document {
41
32
  constructor(options) {
42
- this.anchors = new _Anchors.default(options.anchorPrefix);
33
+ this.anchors = new _Anchors.Anchors(options.anchorPrefix);
43
34
  this.commentBefore = null;
44
35
  this.comment = null;
45
36
  this.contents = null;
@@ -53,7 +44,7 @@ class Document {
53
44
  }
54
45
 
55
46
  assertCollectionContents() {
56
- if (this.contents instanceof _Collection.default) return true;
47
+ if (this.contents instanceof _Collection.Collection) return true;
57
48
  throw new Error('Expected a YAML collection as document contents');
58
49
  }
59
50
 
@@ -88,21 +79,21 @@ class Document {
88
79
  }
89
80
 
90
81
  get(key, keepScalar) {
91
- return this.contents instanceof _Collection.default ? this.contents.get(key, keepScalar) : undefined;
82
+ return this.contents instanceof _Collection.Collection ? this.contents.get(key, keepScalar) : undefined;
92
83
  }
93
84
 
94
85
  getIn(path, keepScalar) {
95
- if ((0, _Collection.isEmptyPath)(path)) return !keepScalar && this.contents instanceof _Scalar.default ? this.contents.value : this.contents;
96
- return this.contents instanceof _Collection.default ? this.contents.getIn(path, keepScalar) : undefined;
86
+ if ((0, _Collection.isEmptyPath)(path)) return !keepScalar && this.contents instanceof _Scalar.Scalar ? this.contents.value : this.contents;
87
+ return this.contents instanceof _Collection.Collection ? this.contents.getIn(path, keepScalar) : undefined;
97
88
  }
98
89
 
99
90
  has(key) {
100
- return this.contents instanceof _Collection.default ? this.contents.has(key) : false;
91
+ return this.contents instanceof _Collection.Collection ? this.contents.has(key) : false;
101
92
  }
102
93
 
103
94
  hasIn(path) {
104
95
  if ((0, _Collection.isEmptyPath)(path)) return this.contents !== undefined;
105
- return this.contents instanceof _Collection.default ? this.contents.hasIn(path) : false;
96
+ return this.contents instanceof _Collection.Collection ? this.contents.hasIn(path) : false;
106
97
  }
107
98
 
108
99
  set(key, value) {
@@ -130,7 +121,7 @@ class Document {
130
121
 
131
122
  if (Array.isArray(customTags)) this.options.customTags = customTags;
132
123
  const opt = Object.assign({}, this.getDefaults(), this.options);
133
- this.schema = new _schema.default(opt);
124
+ this.schema = new _schema.Schema(opt);
134
125
  }
135
126
 
136
127
  parse(node, prevDoc) {
@@ -263,7 +254,7 @@ class Document {
263
254
  const cb = comments.before.join('\n') || null;
264
255
 
265
256
  if (cb) {
266
- const cbNode = this.contents instanceof _Collection.default && this.contents.items[0] ? this.contents.items[0] : this.contents;
257
+ const cbNode = this.contents instanceof _Collection.Collection && this.contents.items[0] ? this.contents.items[0] : this.contents;
267
258
  cbNode.commentBefore = cbNode.commentBefore ? `${cb}\n${cbNode.commentBefore}` : cb;
268
259
  }
269
260
  } else {
@@ -384,18 +375,18 @@ class Document {
384
375
  case _constants.Type.BLOCK_LITERAL:
385
376
  case _constants.Type.QUOTE_DOUBLE:
386
377
  case _constants.Type.QUOTE_SINGLE:
387
- return _schema.default.defaultTags.STR;
378
+ return _schema.Schema.defaultTags.STR;
388
379
 
389
380
  case _constants.Type.FLOW_MAP:
390
381
  case _constants.Type.MAP:
391
- return _schema.default.defaultTags.MAP;
382
+ return _schema.Schema.defaultTags.MAP;
392
383
 
393
384
  case _constants.Type.FLOW_SEQ:
394
385
  case _constants.Type.SEQ:
395
- return _schema.default.defaultTags.SEQ;
386
+ return _schema.Schema.defaultTags.SEQ;
396
387
 
397
388
  case _constants.Type.PLAIN:
398
- return nonSpecific ? _schema.default.defaultTags.STR : null;
389
+ return nonSpecific ? _schema.Schema.defaultTags.STR : null;
399
390
 
400
391
  default:
401
392
  return null;
@@ -493,7 +484,7 @@ class Document {
493
484
  } // Lazy resolution for circular references
494
485
 
495
486
 
496
- res = new _Alias.default(src);
487
+ res = new _Alias.Alias(src);
497
488
 
498
489
  anchors._cstAliases.push(res);
499
490
  } else {
@@ -536,7 +527,7 @@ class Document {
536
527
  }
537
528
 
538
529
  listNonDefaultTags() {
539
- return (0, _listTagNames.default)(this.contents).filter(t => t.indexOf(_schema.default.defaultPrefix) !== 0);
530
+ return (0, _listTagNames.listTagNames)(this.contents).filter(t => t.indexOf(_schema.Schema.defaultPrefix) !== 0);
540
531
  }
541
532
 
542
533
  setTagPrefix(handle, prefix) {
@@ -580,31 +571,43 @@ class Document {
580
571
  }
581
572
  }
582
573
 
583
- toJSON(arg) {
574
+ toJSON(arg, onAnchor) {
584
575
  const {
585
576
  keepBlobsInJSON,
586
577
  mapAsMap,
587
578
  maxAliasCount
588
579
  } = this.options;
589
- const keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof _Scalar.default));
580
+ const keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof _Scalar.Scalar));
590
581
  const ctx = {
591
582
  doc: this,
583
+ indentStep: ' ',
592
584
  keep,
593
585
  mapAsMap: keep && !!mapAsMap,
594
586
  maxAliasCount
595
587
  };
596
588
  const anchorNames = Object.keys(this.anchors.map);
597
- if (anchorNames.length > 0) ctx.anchors = anchorNames.map(name => ({
589
+ if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(name => [this.anchors.map[name], {
598
590
  alias: [],
599
591
  aliasCount: 0,
600
- count: 1,
601
- node: this.anchors.map[name]
602
- }));
603
- return (0, _toJSON.default)(this.contents, arg, ctx);
592
+ count: 1
593
+ }]));
594
+ const res = (0, _toJSON.toJSON)(this.contents, arg, ctx);
595
+ if (typeof onAnchor === 'function' && ctx.anchors) for (const {
596
+ count,
597
+ res
598
+ } of ctx.anchors.values()) onAnchor(res, count);
599
+ return res;
604
600
  }
605
601
 
606
602
  toString() {
607
603
  if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified');
604
+ const indentSize = this.options.indent;
605
+
606
+ if (!Number.isInteger(indentSize) || indentSize <= 0) {
607
+ const s = JSON.stringify(indentSize);
608
+ throw new Error(`"indent" option must be a positive integer, not ${s}`);
609
+ }
610
+
608
611
  this.setSchema();
609
612
  const lines = [];
610
613
  let hasDirectives = false;
@@ -640,13 +643,14 @@ class Document {
640
643
  const ctx = {
641
644
  anchors: {},
642
645
  doc: this,
643
- indent: ''
646
+ indent: '',
647
+ indentStep: ' '.repeat(indentSize)
644
648
  };
645
649
  let chompKeep = false;
646
650
  let contentComment = null;
647
651
 
648
652
  if (this.contents) {
649
- if (this.contents instanceof _Node.default) {
653
+ if (this.contents instanceof _Node.Node) {
650
654
  if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
651
655
  if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
652
656
 
@@ -656,7 +660,7 @@ class Document {
656
660
 
657
661
  const onChompKeep = contentComment ? null : () => chompKeep = true;
658
662
  const body = this.schema.stringify(this.contents, ctx, () => contentComment = null, onChompKeep);
659
- lines.push((0, _addComment.default)(body, '', contentComment));
663
+ lines.push((0, _addComment.addComment)(body, '', contentComment));
660
664
  } else if (this.contents !== undefined) {
661
665
  lines.push(this.schema.stringify(this.contents, ctx));
662
666
  }
@@ -671,7 +675,7 @@ class Document {
671
675
 
672
676
  }
673
677
 
674
- exports.default = Document;
678
+ exports.Document = Document;
675
679
 
676
680
  _defineProperty(Document, "defaults", {
677
681
  '1.0': {
@@ -679,7 +683,7 @@ _defineProperty(Document, "defaults", {
679
683
  merge: true,
680
684
  tagPrefixes: [{
681
685
  handle: '!',
682
- prefix: _schema.default.defaultPrefix
686
+ prefix: _schema.Schema.defaultPrefix
683
687
  }, {
684
688
  handle: '!!',
685
689
  prefix: 'tag:private.yaml.org,2002:'
@@ -693,7 +697,7 @@ _defineProperty(Document, "defaults", {
693
697
  prefix: '!'
694
698
  }, {
695
699
  handle: '!!',
696
- prefix: _schema.default.defaultPrefix
700
+ prefix: _schema.Schema.defaultPrefix
697
701
  }]
698
702
  },
699
703
  '1.2': {
@@ -704,7 +708,7 @@ _defineProperty(Document, "defaults", {
704
708
  prefix: '!'
705
709
  }, {
706
710
  handle: '!!',
707
- prefix: _schema.default.defaultPrefix
711
+ prefix: _schema.Schema.defaultPrefix
708
712
  }]
709
713
  }
710
714
  });
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
3
  exports.addCommentBefore = addCommentBefore;
7
- exports.default = addComment;
4
+ exports.addComment = addComment;
8
5
 
9
6
  function addCommentBefore(str, indent, comment) {
10
7
  if (!comment) return str;
package/dist/constants.js CHANGED
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
3
  exports.Type = exports.Char = void 0;
7
4
  const Char = {
8
5
  ANCHOR: '&',
package/dist/cst/Alias.js CHANGED
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
3
+ exports.Alias = void 0;
7
4
 
8
- var _Node = _interopRequireDefault(require("./Node"));
5
+ var _Node = require("./Node");
9
6
 
10
- var _Range = _interopRequireDefault(require("./Range"));
7
+ var _Range = require("./Range");
11
8
 
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- class Alias extends _Node.default {
9
+ class Alias extends _Node.Node {
15
10
  /**
16
11
  * Parses an *alias from the source
17
12
  *
@@ -25,14 +20,14 @@ class Alias extends _Node.default {
25
20
  src
26
21
  } = context;
27
22
 
28
- let offset = _Node.default.endOfIdentifier(src, start + 1);
23
+ let offset = _Node.Node.endOfIdentifier(src, start + 1);
29
24
 
30
- this.valueRange = new _Range.default(start + 1, offset);
31
- offset = _Node.default.endOfWhiteSpace(src, offset);
25
+ this.valueRange = new _Range.Range(start + 1, offset);
26
+ offset = _Node.Node.endOfWhiteSpace(src, offset);
32
27
  offset = this.parseComment(offset);
33
28
  return offset;
34
29
  }
35
30
 
36
31
  }
37
32
 
38
- exports.default = Alias;
33
+ exports.Alias = Alias;
@@ -1,19 +1,14 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
3
+ exports.BlankLine = void 0;
7
4
 
8
5
  var _constants = require("../constants");
9
6
 
10
- var _Node = _interopRequireDefault(require("./Node"));
7
+ var _Node = require("./Node");
11
8
 
12
- var _Range = _interopRequireDefault(require("./Range"));
9
+ var _Range = require("./Range");
13
10
 
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- class BlankLine extends _Node.default {
11
+ class BlankLine extends _Node.Node {
17
12
  constructor() {
18
13
  super(_constants.Type.BLANK_LINE);
19
14
  }
@@ -26,7 +21,7 @@ class BlankLine extends _Node.default {
26
21
  return true;
27
22
  }
28
23
  /**
29
- * Parses blank lines from the source
24
+ * Parses a blank line from the source
30
25
  *
31
26
  * @param {ParseContext} context
32
27
  * @param {number} start - Index of first \n character
@@ -36,21 +31,10 @@ class BlankLine extends _Node.default {
36
31
 
37
32
  parse(context, start) {
38
33
  this.context = context;
39
- const {
40
- src
41
- } = context;
42
- let offset = start + 1;
43
-
44
- while (_Node.default.atBlank(src, offset)) {
45
- const lineEnd = _Node.default.endOfWhiteSpace(src, offset);
46
-
47
- if (lineEnd === '\n') offset = lineEnd + 1;else break;
48
- }
49
-
50
- this.range = new _Range.default(start, offset);
51
- return offset;
34
+ this.range = new _Range.Range(start, start + 1);
35
+ return start + 1;
52
36
  }
53
37
 
54
38
  }
55
39
 
56
- exports.default = BlankLine;
40
+ exports.BlankLine = BlankLine;
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.Chomp = void 0;
3
+ exports.BlockValue = exports.Chomp = void 0;
7
4
 
8
5
  var _constants = require("../constants");
9
6
 
10
- var _Node = _interopRequireDefault(require("./Node"));
7
+ var _Node = require("./Node");
11
8
 
12
- var _Range = _interopRequireDefault(require("./Range"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var _Range = require("./Range");
15
10
 
16
11
  const Chomp = {
17
12
  CLIP: 'CLIP',
@@ -20,7 +15,7 @@ const Chomp = {
20
15
  };
21
16
  exports.Chomp = Chomp;
22
17
 
23
- class BlockValue extends _Node.default {
18
+ class BlockValue extends _Node.Node {
24
19
  constructor(type, props) {
25
20
  super(type, props);
26
21
  this.blockIndent = null;
@@ -86,7 +81,7 @@ class BlockValue extends _Node.default {
86
81
  if (ch === '\n') {
87
82
  if (sep === '\n') str += '\n';else sep = '\n';
88
83
  } else {
89
- const lineEnd = _Node.default.endOfLine(src, i);
84
+ const lineEnd = _Node.Node.endOfLine(src, i);
90
85
 
91
86
  const line = src.slice(i, lineEnd);
92
87
  i = lineEnd;
@@ -144,7 +139,7 @@ class BlockValue extends _Node.default {
144
139
 
145
140
  default:
146
141
  this.blockIndent = Number(bi) || null;
147
- this.header = new _Range.default(start, offset);
142
+ this.header = new _Range.Range(start, offset);
148
143
  return offset;
149
144
  }
150
145
 
@@ -164,9 +159,9 @@ class BlockValue extends _Node.default {
164
159
 
165
160
  for (let ch = src[offset]; ch === '\n'; ch = src[offset]) {
166
161
  offset += 1;
167
- if (_Node.default.atDocumentBoundary(src, offset)) break;
162
+ if (_Node.Node.atDocumentBoundary(src, offset)) break;
168
163
 
169
- const end = _Node.default.endOfBlockIndent(src, bi, offset); // should not include tab?
164
+ const end = _Node.Node.endOfBlockIndent(src, bi, offset); // should not include tab?
170
165
 
171
166
 
172
167
  if (end === null) break;
@@ -193,7 +188,7 @@ class BlockValue extends _Node.default {
193
188
  if (src[end] === '\n') {
194
189
  offset = end;
195
190
  } else {
196
- offset = valueEnd = _Node.default.endOfLine(src, end);
191
+ offset = valueEnd = _Node.Node.endOfLine(src, end);
197
192
  }
198
193
  }
199
194
 
@@ -201,7 +196,7 @@ class BlockValue extends _Node.default {
201
196
  offset = src[valueEnd] ? valueEnd + 1 : valueEnd;
202
197
  }
203
198
 
204
- this.valueRange = new _Range.default(start + 1, offset);
199
+ this.valueRange = new _Range.Range(start + 1, offset);
205
200
  return offset;
206
201
  }
207
202
  /**
@@ -232,7 +227,7 @@ class BlockValue extends _Node.default {
232
227
  src
233
228
  } = context;
234
229
  let offset = this.parseBlockHeader(start);
235
- offset = _Node.default.endOfWhiteSpace(src, offset);
230
+ offset = _Node.Node.endOfWhiteSpace(src, offset);
236
231
  offset = this.parseComment(offset);
237
232
  offset = this.parseBlockValue(offset);
238
233
  return offset;
@@ -245,4 +240,4 @@ class BlockValue extends _Node.default {
245
240
 
246
241
  }
247
242
 
248
- exports.default = BlockValue;
243
+ exports.BlockValue = BlockValue;
@@ -1,29 +1,24 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
3
  exports.grabCollectionEndComments = grabCollectionEndComments;
7
- exports.default = void 0;
4
+ exports.Collection = void 0;
8
5
 
9
6
  var _constants = require("../constants");
10
7
 
11
- var _BlankLine = _interopRequireDefault(require("./BlankLine"));
8
+ var _BlankLine = require("./BlankLine");
12
9
 
13
- var _CollectionItem = _interopRequireDefault(require("./CollectionItem"));
10
+ var _CollectionItem = require("./CollectionItem");
14
11
 
15
- var _Comment = _interopRequireDefault(require("./Comment"));
12
+ var _Comment = require("./Comment");
16
13
 
17
- var _Node = _interopRequireDefault(require("./Node"));
14
+ var _Node = require("./Node");
18
15
 
19
- var _Range = _interopRequireDefault(require("./Range"));
20
-
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ var _Range = require("./Range");
22
17
 
23
18
  function grabCollectionEndComments(node) {
24
19
  let cnode = node;
25
20
 
26
- while (cnode instanceof _CollectionItem.default) cnode = cnode.node;
21
+ while (cnode instanceof _CollectionItem.CollectionItem) cnode = cnode.node;
27
22
 
28
23
  if (!(cnode instanceof Collection)) return null;
29
24
  const len = cnode.items.length;
@@ -57,10 +52,10 @@ function grabCollectionEndComments(node) {
57
52
  return ca;
58
53
  }
59
54
 
60
- class Collection extends _Node.default {
55
+ class Collection extends _Node.Node {
61
56
  static nextContentHasIndent(src, offset, indent) {
62
- const lineStart = _Node.default.endOfLine(src, offset) + 1;
63
- offset = _Node.default.endOfWhiteSpace(src, lineStart);
57
+ const lineStart = _Node.Node.endOfLine(src, offset) + 1;
58
+ offset = _Node.Node.endOfWhiteSpace(src, lineStart);
64
59
  const ch = src[offset];
65
60
  if (!ch) return false;
66
61
  if (offset >= lineStart + indent) return true;
@@ -105,24 +100,24 @@ class Collection extends _Node.default {
105
100
  } = context; // It's easier to recalculate lineStart here rather than tracking down the
106
101
  // last context from which to read it -- eemeli/yaml#2
107
102
 
108
- let lineStart = _Node.default.startOfLine(src, start);
103
+ let lineStart = _Node.Node.startOfLine(src, start);
109
104
 
110
105
  const firstItem = this.items[0]; // First-item context needs to be correct for later comment handling
111
106
  // -- eemeli/yaml#17
112
107
 
113
108
  firstItem.context.parent = this;
114
- this.valueRange = _Range.default.copy(firstItem.valueRange);
109
+ this.valueRange = _Range.Range.copy(firstItem.valueRange);
115
110
  const indent = firstItem.range.start - firstItem.context.lineStart;
116
111
  let offset = start;
117
- offset = _Node.default.normalizeOffset(src, offset);
112
+ offset = _Node.Node.normalizeOffset(src, offset);
118
113
  let ch = src[offset];
119
- let atLineStart = _Node.default.endOfWhiteSpace(src, lineStart) === offset;
114
+ let atLineStart = _Node.Node.endOfWhiteSpace(src, lineStart) === offset;
120
115
  let prevIncludesTrailingLines = false;
121
116
 
122
117
  while (ch) {
123
118
  while (ch === '\n' || ch === '#') {
124
119
  if (atLineStart && ch === '\n' && !prevIncludesTrailingLines) {
125
- const blankLine = new _BlankLine.default();
120
+ const blankLine = new _BlankLine.BlankLine();
126
121
  offset = blankLine.parse({
127
122
  src
128
123
  }, offset);
@@ -140,7 +135,7 @@ class Collection extends _Node.default {
140
135
  return offset;
141
136
  }
142
137
 
143
- const comment = new _Comment.default();
138
+ const comment = new _Comment.Comment();
144
139
  offset = comment.parse({
145
140
  indent,
146
141
  lineStart,
@@ -156,10 +151,10 @@ class Collection extends _Node.default {
156
151
  }
157
152
 
158
153
  lineStart = offset + 1;
159
- offset = _Node.default.endOfIndent(src, lineStart);
154
+ offset = _Node.Node.endOfIndent(src, lineStart);
160
155
 
161
- if (_Node.default.atBlank(src, offset)) {
162
- const wsEnd = _Node.default.endOfWhiteSpace(src, offset);
156
+ if (_Node.Node.atBlank(src, offset)) {
157
+ const wsEnd = _Node.Node.endOfWhiteSpace(src, offset);
163
158
 
164
159
  const next = src[wsEnd];
165
160
 
@@ -207,7 +202,7 @@ class Collection extends _Node.default {
207
202
 
208
203
  this.items.push(node);
209
204
  this.valueRange.end = node.valueRange.end;
210
- offset = _Node.default.normalizeOffset(src, node.range.end);
205
+ offset = _Node.Node.normalizeOffset(src, node.range.end);
211
206
  ch = src[offset];
212
207
  atLineStart = false;
213
208
  prevIncludesTrailingLines = node.includesTrailingLines; // Need to reset lineStart and atLineStart here if preceding node's range
@@ -263,9 +258,9 @@ class Collection extends _Node.default {
263
258
  str += String(item);
264
259
  }
265
260
 
266
- return _Node.default.addStringTerminator(src, range.end, str);
261
+ return _Node.Node.addStringTerminator(src, range.end, str);
267
262
  }
268
263
 
269
264
  }
270
265
 
271
- exports.default = Collection;
266
+ exports.Collection = Collection;