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.
- package/README.md +29 -23
- package/browser/dist/Anchors.js +12 -10
- package/browser/dist/Document.js +122 -60
- package/browser/dist/constants.js +34 -0
- package/browser/dist/cst/Alias.js +1 -3
- package/browser/dist/cst/BlankLine.js +5 -7
- package/browser/dist/cst/BlockValue.js +4 -4
- package/browser/dist/cst/Collection.js +8 -8
- package/browser/dist/cst/CollectionItem.js +6 -8
- package/browser/dist/cst/Comment.js +5 -7
- package/browser/dist/cst/Directive.js +5 -7
- package/browser/dist/cst/Document.js +8 -10
- package/browser/dist/cst/FlowCollection.js +5 -7
- package/browser/dist/cst/Node.js +12 -40
- package/browser/dist/cst/ParseContext.js +32 -34
- package/browser/dist/cst/PlainValue.js +1 -3
- package/browser/dist/cst/QuoteDouble.js +1 -3
- package/browser/dist/cst/QuoteSingle.js +1 -3
- package/browser/dist/cst/Range.js +1 -3
- package/browser/dist/cst/getLinePos.js +8 -13
- package/browser/dist/cst/parse.js +1 -4
- package/browser/dist/deprecation.js +34 -0
- package/browser/dist/errors.js +50 -59
- package/browser/dist/index.js +7 -4
- package/browser/dist/listTagNames.js +1 -3
- package/browser/dist/schema/Alias.js +90 -10
- package/browser/dist/schema/Collection.js +3 -3
- package/browser/dist/schema/Map.js +22 -105
- package/browser/dist/schema/Merge.js +74 -1
- package/browser/dist/schema/Node.js +1 -3
- package/browser/dist/schema/Pair.js +52 -26
- package/browser/dist/schema/Scalar.js +3 -5
- package/browser/dist/schema/Seq.js +30 -7
- package/browser/dist/schema/index.js +158 -82
- package/browser/dist/schema/parseMap.js +18 -21
- package/browser/dist/schema/parseSeq.js +9 -12
- package/browser/dist/{schema/_string.js → stringify.js} +65 -73
- package/browser/dist/tags/core.js +132 -0
- package/browser/dist/tags/failsafe/index.js +17 -0
- package/browser/dist/tags/failsafe/map.js +65 -0
- package/browser/dist/tags/failsafe/seq.js +54 -0
- package/browser/dist/tags/failsafe/string.js +40 -0
- package/browser/dist/tags/index.js +50 -0
- package/browser/dist/tags/json.js +103 -0
- package/browser/dist/tags/options.js +35 -0
- package/browser/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +20 -20
- package/browser/dist/tags/yaml-1.1/index.js +177 -0
- package/browser/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +25 -25
- package/browser/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +9 -13
- package/browser/dist/tags/yaml-1.1/set.js +140 -0
- package/browser/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +13 -10
- package/browser/dist/test-events.js +1 -4
- package/browser/dist/toJSON.js +20 -8
- package/browser/index.js +1 -0
- package/browser/map.js +2 -1
- package/browser/pair.js +2 -1
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +2 -1
- package/browser/schema.js +7 -3
- package/browser/seq.js +2 -1
- package/browser/types/binary.js +7 -1
- package/browser/types/omap.js +2 -1
- package/browser/types/pairs.js +2 -1
- package/browser/types/set.js +2 -1
- package/browser/types/timestamp.js +10 -1
- package/browser/types.js +11 -0
- package/browser/util.js +15 -0
- package/dist/Anchors.js +9 -8
- package/dist/Document.js +55 -39
- package/dist/constants.js +34 -0
- package/dist/cst/Alias.js +1 -3
- package/dist/cst/BlankLine.js +5 -7
- package/dist/cst/BlockValue.js +4 -4
- package/dist/cst/Collection.js +8 -8
- package/dist/cst/CollectionItem.js +6 -8
- package/dist/cst/Comment.js +5 -7
- package/dist/cst/Directive.js +5 -7
- package/dist/cst/Document.js +8 -10
- package/dist/cst/FlowCollection.js +5 -7
- package/dist/cst/Node.js +12 -40
- package/dist/cst/ParseContext.js +32 -34
- package/dist/cst/PlainValue.js +1 -3
- package/dist/cst/QuoteDouble.js +1 -3
- package/dist/cst/QuoteSingle.js +1 -3
- package/dist/cst/Range.js +1 -3
- package/dist/cst/getLinePos.js +8 -12
- package/dist/cst/parse.js +1 -4
- package/dist/deprecation.js +34 -0
- package/dist/errors.js +29 -35
- package/dist/index.js +7 -4
- package/dist/listTagNames.js +1 -3
- package/dist/schema/Alias.js +67 -12
- package/dist/schema/Map.js +10 -74
- package/dist/schema/Merge.js +31 -0
- package/dist/schema/Node.js +1 -3
- package/dist/schema/Pair.js +46 -20
- package/dist/schema/Scalar.js +3 -5
- package/dist/schema/Seq.js +9 -5
- package/dist/schema/index.js +109 -74
- package/dist/schema/parseMap.js +18 -21
- package/dist/schema/parseSeq.js +9 -12
- package/dist/{schema/_string.js → stringify.js} +56 -65
- package/dist/tags/core.js +96 -0
- package/dist/tags/failsafe/index.js +17 -0
- package/dist/tags/failsafe/map.js +33 -0
- package/dist/tags/failsafe/seq.js +34 -0
- package/dist/tags/failsafe/string.js +40 -0
- package/dist/tags/index.js +50 -0
- package/dist/tags/json.js +67 -0
- package/dist/tags/options.js +35 -0
- package/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +18 -20
- package/dist/tags/yaml-1.1/index.js +131 -0
- package/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +16 -16
- package/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +9 -11
- package/dist/{schema/_set.js → tags/yaml-1.1/set.js} +12 -44
- package/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +7 -10
- package/dist/test-events.js +1 -4
- package/dist/toJSON.js +15 -5
- package/index.js +1 -0
- package/map.js +2 -1
- package/package.json +22 -17
- package/pair.js +2 -1
- package/parse-cst.js +1 -1
- package/scalar.js +2 -1
- package/schema.js +7 -3
- package/seq.js +2 -1
- package/types/binary.js +7 -1
- package/types/omap.js +2 -1
- package/types/pairs.js +2 -1
- package/types/set.js +2 -1
- package/types/timestamp.js +10 -1
- package/types.js +11 -0
- package/util.js +15 -0
- package/browser/dist/polyfill.js +0 -251
- package/browser/dist/schema/_set.js +0 -212
- package/browser/dist/schema/core.js +0 -98
- package/browser/dist/schema/failsafe.js +0 -125
- package/browser/dist/schema/json.js +0 -66
- package/browser/dist/schema/yaml-1.1.js +0 -140
- package/dist/linePos.js +0 -58
- package/dist/polyfill.js +0 -27
- package/dist/schema/core.js +0 -79
- package/dist/schema/failsafe.js +0 -74
- package/dist/schema/json.js +0 -56
- package/dist/schema/yaml-1.1.js +0 -115
package/browser/dist/errors.js
CHANGED
|
@@ -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
|
|
24
|
+
var YAMLError =
|
|
23
25
|
/*#__PURE__*/
|
|
24
|
-
function (
|
|
25
|
-
(0, _inherits2.default)(
|
|
26
|
+
function (_Error) {
|
|
27
|
+
(0, _inherits2.default)(YAMLError, _Error);
|
|
26
28
|
|
|
27
|
-
function
|
|
29
|
+
function YAMLError(name, source, message) {
|
|
28
30
|
var _this;
|
|
29
31
|
|
|
30
|
-
(0, _classCallCheck2.default)(this,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
}(
|
|
68
|
+
}(YAMLError);
|
|
45
69
|
|
|
46
70
|
exports.YAMLReferenceError = YAMLReferenceError;
|
|
47
71
|
|
|
48
72
|
var YAMLSemanticError =
|
|
49
73
|
/*#__PURE__*/
|
|
50
|
-
function (
|
|
51
|
-
(0, _inherits2.default)(YAMLSemanticError,
|
|
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
|
-
}(
|
|
83
|
+
}(YAMLError);
|
|
71
84
|
|
|
72
85
|
exports.YAMLSemanticError = YAMLSemanticError;
|
|
73
86
|
|
|
74
87
|
var YAMLSyntaxError =
|
|
75
88
|
/*#__PURE__*/
|
|
76
|
-
function (
|
|
77
|
-
(0, _inherits2.default)(YAMLSyntaxError,
|
|
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
|
-
}(
|
|
98
|
+
}(YAMLError);
|
|
97
99
|
|
|
98
100
|
exports.YAMLSyntaxError = YAMLSyntaxError;
|
|
99
101
|
|
|
100
102
|
var YAMLWarning =
|
|
101
103
|
/*#__PURE__*/
|
|
102
|
-
function (
|
|
103
|
-
(0, _inherits2.default)(YAMLWarning,
|
|
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
|
-
}(
|
|
113
|
+
}(YAMLError);
|
|
123
114
|
|
|
124
115
|
exports.YAMLWarning = YAMLWarning;
|
package/browser/dist/index.js
CHANGED
|
@@ -25,10 +25,15 @@ var _schema = _interopRequireDefault(require("./schema"));
|
|
|
25
25
|
|
|
26
26
|
/* global console */
|
|
27
27
|
var defaultOptions = {
|
|
28
|
+
anchorPrefix: 'a',
|
|
29
|
+
customTags: null,
|
|
30
|
+
keepCstNodes: false,
|
|
28
31
|
keepNodeTypes: true,
|
|
29
32
|
keepBlobsInJSON: true,
|
|
30
33
|
mapAsMap: false,
|
|
31
|
-
|
|
34
|
+
maxAliasCount: 100,
|
|
35
|
+
prettyErrors: false,
|
|
36
|
+
// TODO Set true in v2
|
|
32
37
|
version: '1.2'
|
|
33
38
|
};
|
|
34
39
|
|
|
@@ -103,6 +108,4 @@ var _default = {
|
|
|
103
108
|
parseDocument: parseDocument,
|
|
104
109
|
stringify: stringify
|
|
105
110
|
};
|
|
106
|
-
exports.default = _default;
|
|
107
|
-
module.exports = exports.default;
|
|
108
|
-
module.exports.default = exports.default;
|
|
111
|
+
exports.default = _default;
|
|
@@ -19,11 +19,60 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
19
19
|
|
|
20
20
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _constants = require("../constants");
|
|
23
|
+
|
|
24
|
+
var _errors = require("../errors");
|
|
23
25
|
|
|
24
26
|
var _toJSON2 = _interopRequireDefault(require("../toJSON"));
|
|
25
27
|
|
|
26
|
-
var
|
|
28
|
+
var _Collection = _interopRequireDefault(require("./Collection"));
|
|
29
|
+
|
|
30
|
+
var _Node2 = _interopRequireDefault(require("./Node"));
|
|
31
|
+
|
|
32
|
+
var _Pair = _interopRequireDefault(require("./Pair"));
|
|
33
|
+
|
|
34
|
+
var getAliasCount = function getAliasCount(node, anchors) {
|
|
35
|
+
if (node instanceof Alias) {
|
|
36
|
+
var anchor = anchors.find(function (a) {
|
|
37
|
+
return a.node === node.source;
|
|
38
|
+
});
|
|
39
|
+
return anchor.count * anchor.aliasCount;
|
|
40
|
+
} else if (node instanceof _Collection.default) {
|
|
41
|
+
var count = 0;
|
|
42
|
+
var _iteratorNormalCompletion = true;
|
|
43
|
+
var _didIteratorError = false;
|
|
44
|
+
var _iteratorError = undefined;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
for (var _iterator = node.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
48
|
+
var item = _step.value;
|
|
49
|
+
var c = getAliasCount(item, anchors);
|
|
50
|
+
if (c > count) count = c;
|
|
51
|
+
}
|
|
52
|
+
} catch (err) {
|
|
53
|
+
_didIteratorError = true;
|
|
54
|
+
_iteratorError = err;
|
|
55
|
+
} finally {
|
|
56
|
+
try {
|
|
57
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
58
|
+
_iterator.return();
|
|
59
|
+
}
|
|
60
|
+
} finally {
|
|
61
|
+
if (_didIteratorError) {
|
|
62
|
+
throw _iteratorError;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return count;
|
|
68
|
+
} else if (node instanceof _Pair.default) {
|
|
69
|
+
var kc = getAliasCount(node.key, anchors);
|
|
70
|
+
var vc = getAliasCount(node.value, anchors);
|
|
71
|
+
return Math.max(kc, vc);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return 1;
|
|
75
|
+
};
|
|
27
76
|
|
|
28
77
|
var Alias =
|
|
29
78
|
/*#__PURE__*/
|
|
@@ -36,10 +85,12 @@ function (_Node) {
|
|
|
36
85
|
source = _ref.source;
|
|
37
86
|
var anchors = _ref2.anchors,
|
|
38
87
|
doc = _ref2.doc,
|
|
39
|
-
implicitKey = _ref2.implicitKey
|
|
88
|
+
implicitKey = _ref2.implicitKey,
|
|
89
|
+
inStringifyKey = _ref2.inStringifyKey;
|
|
40
90
|
var anchor = Object.keys(anchors).find(function (a) {
|
|
41
91
|
return anchors[a] === source;
|
|
42
92
|
});
|
|
93
|
+
if (!anchor && inStringifyKey) anchor = doc.anchors.getName(source) || doc.anchors.newName();
|
|
43
94
|
if (anchor) return "*".concat(anchor).concat(implicitKey ? ' ' : '');
|
|
44
95
|
var msg = doc.anchors.getName(source) ? 'Alias node must be after source node' : 'Source node not found for alias node';
|
|
45
96
|
throw new Error("".concat(msg, " [").concat(range, "]"));
|
|
@@ -52,14 +103,45 @@ function (_Node) {
|
|
|
52
103
|
(0, _classCallCheck2.default)(this, Alias);
|
|
53
104
|
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Alias).call(this));
|
|
54
105
|
_this.source = source;
|
|
55
|
-
_this.type =
|
|
106
|
+
_this.type = _constants.Type.ALIAS;
|
|
56
107
|
return _this;
|
|
57
108
|
}
|
|
58
109
|
|
|
59
110
|
(0, _createClass2.default)(Alias, [{
|
|
60
111
|
key: "toJSON",
|
|
61
|
-
value: function toJSON(arg,
|
|
62
|
-
|
|
112
|
+
value: function toJSON(arg, ctx) {
|
|
113
|
+
var _this2 = this;
|
|
114
|
+
|
|
115
|
+
if (!ctx) return (0, _toJSON2.default)(this.source, arg, ctx);
|
|
116
|
+
var anchors = ctx.anchors,
|
|
117
|
+
maxAliasCount = ctx.maxAliasCount;
|
|
118
|
+
var anchor = anchors.find(function (a) {
|
|
119
|
+
return a.node === _this2.source;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (!anchor || !anchor.res) {
|
|
123
|
+
var msg = 'This should not happen: Alias anchor was not resolved?';
|
|
124
|
+
if (this.cstNode) throw new _errors.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (maxAliasCount >= 0) {
|
|
128
|
+
anchor.count += 1;
|
|
129
|
+
if (anchor.aliasCount === 0) anchor.aliasCount = getAliasCount(this.source, anchors);
|
|
130
|
+
|
|
131
|
+
if (anchor.count * anchor.aliasCount > maxAliasCount) {
|
|
132
|
+
var _msg = 'Excessive alias count indicates a resource exhaustion attack';
|
|
133
|
+
if (this.cstNode) throw new _errors.YAMLReferenceError(this.cstNode, _msg);else throw new ReferenceError(_msg);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return anchor.res;
|
|
138
|
+
} // Only called when stringifying an alias mapping key while constructing
|
|
139
|
+
// Object output.
|
|
140
|
+
|
|
141
|
+
}, {
|
|
142
|
+
key: "toString",
|
|
143
|
+
value: function toString(ctx) {
|
|
144
|
+
return Alias.stringify(this, ctx);
|
|
63
145
|
}
|
|
64
146
|
}, {
|
|
65
147
|
key: "tag",
|
|
@@ -68,9 +150,7 @@ function (_Node) {
|
|
|
68
150
|
}
|
|
69
151
|
}]);
|
|
70
152
|
return Alias;
|
|
71
|
-
}(
|
|
153
|
+
}(_Node2.default);
|
|
72
154
|
|
|
73
155
|
exports.default = Alias;
|
|
74
|
-
(0, _defineProperty2.default)(Alias, "default", true);
|
|
75
|
-
module.exports = exports.default;
|
|
76
|
-
module.exports.default = exports.default;
|
|
156
|
+
(0, _defineProperty2.default)(Alias, "default", true);
|
|
@@ -17,10 +17,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
17
17
|
|
|
18
18
|
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
19
|
|
|
20
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
-
|
|
22
20
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
23
21
|
|
|
22
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
+
|
|
24
24
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
25
|
|
|
26
26
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
@@ -57,7 +57,7 @@ function (_Node) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(Collection)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
60
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(
|
|
60
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "items", []);
|
|
61
61
|
return _this;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -8,8 +8,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.findPair = findPair;
|
|
9
9
|
exports.default = void 0;
|
|
10
10
|
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
|
|
13
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
12
|
|
|
15
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -22,17 +20,12 @@ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
|
22
20
|
|
|
23
21
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
24
22
|
|
|
25
|
-
var _toJSON2 = _interopRequireDefault(require("../toJSON"));
|
|
26
|
-
|
|
27
23
|
var _Collection2 = _interopRequireDefault(require("./Collection"));
|
|
28
24
|
|
|
29
|
-
var _Merge = _interopRequireDefault(require("./Merge"));
|
|
30
|
-
|
|
31
25
|
var _Pair = _interopRequireDefault(require("./Pair"));
|
|
32
26
|
|
|
33
27
|
var _Scalar = _interopRequireDefault(require("./Scalar"));
|
|
34
28
|
|
|
35
|
-
// Published as 'yaml/map'
|
|
36
29
|
function findPair(items, key) {
|
|
37
30
|
var k = key instanceof _Scalar.default ? key.value : key;
|
|
38
31
|
var _iteratorNormalCompletion = true;
|
|
@@ -110,52 +103,18 @@ function (_Collection) {
|
|
|
110
103
|
var prev = findPair(this.items, key);
|
|
111
104
|
if (prev) prev.value = value;else this.items.push(new _Pair.default(key, value));
|
|
112
105
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
(function () {
|
|
120
|
-
// If the value associated with a merge key is a single mapping node,
|
|
121
|
-
// each of its key/value pairs is inserted into the current mapping,
|
|
122
|
-
// unless the key already exists in it. If the value associated with the
|
|
123
|
-
// merge key is a sequence, then this sequence is expected to contain
|
|
124
|
-
// mapping nodes and each of these nodes is merged in turn according to
|
|
125
|
-
// its order in the sequence. Keys in mapping nodes earlier in the
|
|
126
|
-
// sequence override keys specified in later mapping nodes.
|
|
127
|
-
// -- http://yaml.org/type/merge.html
|
|
128
|
-
var keys = Object.keys(map);
|
|
129
|
-
var items = item.value.items;
|
|
130
|
-
|
|
131
|
-
for (var i = items.length - 1; i >= 0; --i) {
|
|
132
|
-
var source = items[i].source;
|
|
133
|
-
|
|
134
|
-
if (source instanceof YAMLMap) {
|
|
135
|
-
(function () {
|
|
136
|
-
var obj = source.toJSON('', opt);
|
|
137
|
-
Object.keys(obj).forEach(function (key) {
|
|
138
|
-
if (!keys.includes(key)) map[key] = obj[key];
|
|
139
|
-
});
|
|
140
|
-
})();
|
|
141
|
-
} else {
|
|
142
|
-
throw new Error('Merge sources must be maps');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
})();
|
|
146
|
-
} else {
|
|
147
|
-
var stringKey = item.stringKey,
|
|
148
|
-
value = item.value;
|
|
149
|
-
map[stringKey] = (0, _toJSON2.default)(value, stringKey, opt);
|
|
150
|
-
}
|
|
106
|
+
/**
|
|
107
|
+
* @param {*} arg ignored
|
|
108
|
+
* @param {*} ctx Conversion context, originally set in Document#toJSON()
|
|
109
|
+
* @param {Class} Type If set, forces the returned collection type
|
|
110
|
+
* @returns {*} Instance of Type, Map, or Object
|
|
111
|
+
*/
|
|
151
112
|
|
|
152
|
-
return map;
|
|
153
|
-
}, {});
|
|
154
|
-
}
|
|
155
113
|
}, {
|
|
156
|
-
key: "
|
|
157
|
-
value: function
|
|
158
|
-
var map = new Map();
|
|
114
|
+
key: "toJSON",
|
|
115
|
+
value: function toJSON(_, ctx, Type) {
|
|
116
|
+
var map = Type ? new Type() : ctx && ctx.mapAsMap ? new Map() : {};
|
|
117
|
+
if (ctx && ctx.onCreate) ctx.onCreate(map);
|
|
159
118
|
var _iteratorNormalCompletion2 = true;
|
|
160
119
|
var _didIteratorError2 = false;
|
|
161
120
|
var _iteratorError2 = undefined;
|
|
@@ -163,49 +122,7 @@ function (_Collection) {
|
|
|
163
122
|
try {
|
|
164
123
|
for (var _iterator2 = this.items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
165
124
|
var item = _step2.value;
|
|
166
|
-
|
|
167
|
-
if (item instanceof _Merge.default) {
|
|
168
|
-
var items = item.value.items;
|
|
169
|
-
|
|
170
|
-
for (var i = items.length - 1; i >= 0; --i) {
|
|
171
|
-
var source = items[i].source;
|
|
172
|
-
|
|
173
|
-
if (source instanceof YAMLMap) {
|
|
174
|
-
var _iteratorNormalCompletion3 = true;
|
|
175
|
-
var _didIteratorError3 = false;
|
|
176
|
-
var _iteratorError3 = undefined;
|
|
177
|
-
|
|
178
|
-
try {
|
|
179
|
-
for (var _iterator3 = source.toJSMap(opt)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
180
|
-
var _step3$value = (0, _slicedToArray2.default)(_step3.value, 2),
|
|
181
|
-
key = _step3$value[0],
|
|
182
|
-
value = _step3$value[1];
|
|
183
|
-
|
|
184
|
-
if (!map.has(key)) map.set(key, value);
|
|
185
|
-
}
|
|
186
|
-
} catch (err) {
|
|
187
|
-
_didIteratorError3 = true;
|
|
188
|
-
_iteratorError3 = err;
|
|
189
|
-
} finally {
|
|
190
|
-
try {
|
|
191
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
192
|
-
_iterator3.return();
|
|
193
|
-
}
|
|
194
|
-
} finally {
|
|
195
|
-
if (_didIteratorError3) {
|
|
196
|
-
throw _iteratorError3;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
throw new Error('Merge sources must be maps');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
} else {
|
|
205
|
-
var key = (0, _toJSON2.default)(item.key, '', opt);
|
|
206
|
-
var value = (0, _toJSON2.default)(item.value, key, opt);
|
|
207
|
-
map.set(key, value);
|
|
208
|
-
}
|
|
125
|
+
item.addToJSMap(ctx, map);
|
|
209
126
|
}
|
|
210
127
|
} catch (err) {
|
|
211
128
|
_didIteratorError2 = true;
|
|
@@ -228,26 +145,26 @@ function (_Collection) {
|
|
|
228
145
|
key: "toString",
|
|
229
146
|
value: function toString(ctx, onComment, onChompKeep) {
|
|
230
147
|
if (!ctx) return JSON.stringify(this);
|
|
231
|
-
var
|
|
232
|
-
var
|
|
233
|
-
var
|
|
148
|
+
var _iteratorNormalCompletion3 = true;
|
|
149
|
+
var _didIteratorError3 = false;
|
|
150
|
+
var _iteratorError3 = undefined;
|
|
234
151
|
|
|
235
152
|
try {
|
|
236
|
-
for (var
|
|
237
|
-
var item =
|
|
153
|
+
for (var _iterator3 = this.items[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
154
|
+
var item = _step3.value;
|
|
238
155
|
if (!(item instanceof _Pair.default)) throw new Error("Map items must all be pairs; found ".concat(JSON.stringify(item), " instead"));
|
|
239
156
|
}
|
|
240
157
|
} catch (err) {
|
|
241
|
-
|
|
242
|
-
|
|
158
|
+
_didIteratorError3 = true;
|
|
159
|
+
_iteratorError3 = err;
|
|
243
160
|
} finally {
|
|
244
161
|
try {
|
|
245
|
-
if (!
|
|
246
|
-
|
|
162
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
163
|
+
_iterator3.return();
|
|
247
164
|
}
|
|
248
165
|
} finally {
|
|
249
|
-
if (
|
|
250
|
-
throw
|
|
166
|
+
if (_didIteratorError3) {
|
|
167
|
+
throw _iteratorError3;
|
|
251
168
|
}
|
|
252
169
|
}
|
|
253
170
|
}
|
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.MERGE_KEY = void 0;
|
|
9
9
|
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
10
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
13
|
|
|
12
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -19,6 +21,8 @@ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
|
19
21
|
|
|
20
22
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
23
|
|
|
24
|
+
var _Map = _interopRequireDefault(require("./Map"));
|
|
25
|
+
|
|
22
26
|
var _Pair2 = _interopRequireDefault(require("./Pair"));
|
|
23
27
|
|
|
24
28
|
var _Scalar = _interopRequireDefault(require("./Scalar"));
|
|
@@ -55,9 +59,78 @@ function (_Pair) {
|
|
|
55
59
|
|
|
56
60
|
_this.type = 'MERGE_PAIR';
|
|
57
61
|
return (0, _possibleConstructorReturn2.default)(_this);
|
|
58
|
-
}
|
|
62
|
+
} // If the value associated with a merge key is a single mapping node, each of
|
|
63
|
+
// its key/value pairs is inserted into the current mapping, unless the key
|
|
64
|
+
// already exists in it. If the value associated with the merge key is a
|
|
65
|
+
// sequence, then this sequence is expected to contain mapping nodes and each
|
|
66
|
+
// of these nodes is merged in turn according to its order in the sequence.
|
|
67
|
+
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
68
|
+
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
69
|
+
|
|
59
70
|
|
|
60
71
|
(0, _createClass2.default)(Merge, [{
|
|
72
|
+
key: "addToJSMap",
|
|
73
|
+
value: function addToJSMap(ctx, map) {
|
|
74
|
+
var _iteratorNormalCompletion = true;
|
|
75
|
+
var _didIteratorError = false;
|
|
76
|
+
var _iteratorError = undefined;
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
for (var _iterator = this.value.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
80
|
+
var source = _step.value.source;
|
|
81
|
+
if (!(source instanceof _Map.default)) throw new Error('Merge sources must be maps');
|
|
82
|
+
var srcMap = source.toJSON(null, ctx, Map);
|
|
83
|
+
var _iteratorNormalCompletion2 = true;
|
|
84
|
+
var _didIteratorError2 = false;
|
|
85
|
+
var _iteratorError2 = undefined;
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
for (var _iterator2 = srcMap[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
89
|
+
var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
|
|
90
|
+
key = _step2$value[0],
|
|
91
|
+
value = _step2$value[1];
|
|
92
|
+
|
|
93
|
+
if (map instanceof Map) {
|
|
94
|
+
if (!map.has(key)) map.set(key, value);
|
|
95
|
+
} else if (map instanceof Set) {
|
|
96
|
+
map.add(key);
|
|
97
|
+
} else {
|
|
98
|
+
if (!map.hasOwnProperty(key)) map[key] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} catch (err) {
|
|
102
|
+
_didIteratorError2 = true;
|
|
103
|
+
_iteratorError2 = err;
|
|
104
|
+
} finally {
|
|
105
|
+
try {
|
|
106
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
107
|
+
_iterator2.return();
|
|
108
|
+
}
|
|
109
|
+
} finally {
|
|
110
|
+
if (_didIteratorError2) {
|
|
111
|
+
throw _iteratorError2;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} catch (err) {
|
|
117
|
+
_didIteratorError = true;
|
|
118
|
+
_iteratorError = err;
|
|
119
|
+
} finally {
|
|
120
|
+
try {
|
|
121
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
122
|
+
_iterator.return();
|
|
123
|
+
}
|
|
124
|
+
} finally {
|
|
125
|
+
if (_didIteratorError) {
|
|
126
|
+
throw _iteratorError;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return map;
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
61
134
|
key: "toString",
|
|
62
135
|
value: function toString(ctx, onComment) {
|
|
63
136
|
var seq = this.value;
|