yaml 1.9.2 → 1.10.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 +4 -4
- package/browser/dist/PlainValue-ff5147c6.js +1277 -0
- package/browser/dist/Schema-2bf2c74e.js +679 -0
- package/browser/dist/index.js +869 -34
- package/browser/dist/legacy-exports.js +3 -0
- package/browser/dist/parse-cst.js +1904 -0
- package/browser/dist/resolveSeq-04825f30.js +2373 -0
- package/browser/dist/types.js +4 -0
- package/browser/dist/util.js +2 -0
- package/browser/dist/warnings-0e4b70d3.js +499 -0
- package/browser/index.js +1 -1
- package/browser/map.js +2 -4
- package/browser/pair.js +2 -4
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +2 -4
- package/browser/schema.js +7 -10
- package/browser/seq.js +2 -4
- package/browser/types/binary.js +7 -5
- package/browser/types/omap.js +3 -4
- package/browser/types/pairs.js +3 -4
- package/browser/types/set.js +3 -4
- package/browser/types/timestamp.js +9 -5
- package/browser/types.js +1 -13
- package/browser/util.js +1 -18
- package/dist/Document-2cf6b08c.js +757 -0
- package/dist/PlainValue-ec8e588e.js +876 -0
- package/dist/Schema-42e9705c.js +522 -0
- package/dist/index.js +20 -84
- package/dist/legacy-exports.js +16 -0
- package/dist/parse-cst.js +1747 -0
- package/dist/resolveSeq-4a68b39b.js +2115 -0
- package/dist/test-events.js +11 -9
- package/dist/types.js +23 -0
- package/dist/util.js +19 -0
- package/dist/warnings-39684f17.js +416 -0
- package/index.d.ts +22 -8
- package/map.js +2 -2
- package/package.json +22 -39
- package/pair.js +2 -2
- package/parse-cst.js +1 -1
- package/scalar.js +2 -2
- package/schema.js +8 -6
- package/seq.js +2 -2
- package/types/binary.js +3 -2
- package/types/omap.js +3 -2
- package/types/pairs.js +3 -2
- package/types/set.js +3 -2
- package/types/timestamp.js +6 -6
- package/types.d.ts +113 -99
- package/types.js +16 -11
- package/types.mjs +15 -19
- package/util.js +14 -14
- package/util.mjs +13 -20
- package/browser/dist/Anchors.js +0 -130
- package/browser/dist/Document.js +0 -824
- package/browser/dist/addComment.js +0 -8
- package/browser/dist/constants.js +0 -26
- package/browser/dist/cst/Alias.js +0 -46
- package/browser/dist/cst/BlankLine.js +0 -52
- package/browser/dist/cst/BlockValue.js +0 -251
- package/browser/dist/cst/Collection.js +0 -278
- package/browser/dist/cst/CollectionItem.js +0 -140
- package/browser/dist/cst/Comment.js +0 -44
- package/browser/dist/cst/Directive.js +0 -76
- package/browser/dist/cst/Document.js +0 -286
- package/browser/dist/cst/FlowCollection.js +0 -220
- package/browser/dist/cst/Node.js +0 -386
- package/browser/dist/cst/ParseContext.js +0 -246
- package/browser/dist/cst/PlainValue.js +0 -170
- package/browser/dist/cst/QuoteDouble.js +0 -245
- package/browser/dist/cst/QuoteSingle.js +0 -120
- package/browser/dist/cst/Range.js +0 -64
- package/browser/dist/cst/parse.js +0 -48
- package/browser/dist/cst/source-utils.js +0 -168
- package/browser/dist/errors.js +0 -127
- package/browser/dist/foldFlowLines.js +0 -138
- package/browser/dist/listTagNames.js +0 -28
- package/browser/dist/schema/Alias.js +0 -135
- package/browser/dist/schema/Collection.js +0 -260
- package/browser/dist/schema/Map.js +0 -161
- package/browser/dist/schema/Merge.js +0 -118
- package/browser/dist/schema/Node.js +0 -4
- package/browser/dist/schema/Pair.js +0 -194
- package/browser/dist/schema/Scalar.js +0 -42
- package/browser/dist/schema/Seq.js +0 -116
- package/browser/dist/schema/index.js +0 -368
- package/browser/dist/schema/parseMap.js +0 -312
- package/browser/dist/schema/parseSeq.js +0 -168
- package/browser/dist/schema/parseUtils.js +0 -106
- package/browser/dist/stringify.js +0 -332
- package/browser/dist/tags/core.js +0 -141
- package/browser/dist/tags/failsafe/index.js +0 -4
- package/browser/dist/tags/failsafe/map.js +0 -53
- package/browser/dist/tags/failsafe/seq.js +0 -39
- package/browser/dist/tags/failsafe/string.js +0 -28
- package/browser/dist/tags/index.js +0 -36
- package/browser/dist/tags/json.js +0 -77
- package/browser/dist/tags/options.js +0 -26
- package/browser/dist/tags/yaml-1.1/binary.js +0 -87
- package/browser/dist/tags/yaml-1.1/index.js +0 -189
- package/browser/dist/tags/yaml-1.1/omap.js +0 -137
- package/browser/dist/tags/yaml-1.1/pairs.js +0 -78
- package/browser/dist/tags/yaml-1.1/set.js +0 -118
- package/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
- package/browser/dist/test-events.js +0 -163
- package/browser/dist/toJSON.js +0 -19
- package/browser/dist/warnings.js +0 -39
- package/dist/Anchors.js +0 -120
- package/dist/Document.js +0 -714
- package/dist/addComment.js +0 -14
- package/dist/constants.js +0 -31
- package/dist/cst/Alias.js +0 -33
- package/dist/cst/BlankLine.js +0 -40
- package/dist/cst/BlockValue.js +0 -243
- package/dist/cst/Collection.js +0 -266
- package/dist/cst/CollectionItem.js +0 -135
- package/dist/cst/Comment.js +0 -33
- package/dist/cst/Directive.js +0 -59
- package/dist/cst/Document.js +0 -276
- package/dist/cst/FlowCollection.js +0 -213
- package/dist/cst/Node.js +0 -360
- package/dist/cst/ParseContext.js +0 -253
- package/dist/cst/PlainValue.js +0 -156
- package/dist/cst/QuoteDouble.js +0 -232
- package/dist/cst/QuoteSingle.js +0 -108
- package/dist/cst/Range.js +0 -60
- package/dist/cst/parse.js +0 -50
- package/dist/cst/source-utils.js +0 -175
- package/dist/errors.js +0 -97
- package/dist/foldFlowLines.js +0 -143
- package/dist/listTagNames.js +0 -33
- package/dist/schema/Alias.js +0 -105
- package/dist/schema/Collection.js +0 -184
- package/dist/schema/Map.js +0 -98
- package/dist/schema/Merge.js +0 -75
- package/dist/schema/Node.js +0 -7
- package/dist/schema/Pair.js +0 -174
- package/dist/schema/Scalar.js +0 -26
- package/dist/schema/Seq.js +0 -73
- package/dist/schema/index.js +0 -310
- package/dist/schema/parseMap.js +0 -334
- package/dist/schema/parseSeq.js +0 -175
- package/dist/schema/parseUtils.js +0 -101
- package/dist/stringify.js +0 -352
- package/dist/tags/core.js +0 -121
- package/dist/tags/failsafe/index.js +0 -12
- package/dist/tags/failsafe/map.js +0 -32
- package/dist/tags/failsafe/seq.js +0 -29
- package/dist/tags/failsafe/string.js +0 -37
- package/dist/tags/index.js +0 -53
- package/dist/tags/json.js +0 -64
- package/dist/tags/options.js +0 -36
- package/dist/tags/yaml-1.1/binary.js +0 -94
- package/dist/tags/yaml-1.1/index.js +0 -162
- package/dist/tags/yaml-1.1/omap.js +0 -100
- package/dist/tags/yaml-1.1/pairs.js +0 -75
- package/dist/tags/yaml-1.1/set.js +0 -82
- package/dist/tags/yaml-1.1/timestamp.js +0 -90
- package/dist/toJSON.js +0 -21
- package/dist/warnings.js +0 -48
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
|
|
8
|
-
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
|
|
10
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
|
|
12
|
-
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
13
|
-
|
|
14
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
|
|
16
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
-
|
|
18
|
-
import { Type } from '../constants';
|
|
19
|
-
import { YAMLReferenceError } from '../errors';
|
|
20
|
-
import { toJSON as _toJSON } from '../toJSON';
|
|
21
|
-
import { Collection } from './Collection';
|
|
22
|
-
import { Node } from './Node';
|
|
23
|
-
import { Pair } from './Pair';
|
|
24
|
-
|
|
25
|
-
var getAliasCount = function getAliasCount(node, anchors) {
|
|
26
|
-
if (node instanceof Alias) {
|
|
27
|
-
var anchor = anchors.get(node.source);
|
|
28
|
-
return anchor.count * anchor.aliasCount;
|
|
29
|
-
} else if (node instanceof Collection) {
|
|
30
|
-
var count = 0;
|
|
31
|
-
|
|
32
|
-
var _iterator = _createForOfIteratorHelper(node.items),
|
|
33
|
-
_step;
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
37
|
-
var item = _step.value;
|
|
38
|
-
var c = getAliasCount(item, anchors);
|
|
39
|
-
if (c > count) count = c;
|
|
40
|
-
}
|
|
41
|
-
} catch (err) {
|
|
42
|
-
_iterator.e(err);
|
|
43
|
-
} finally {
|
|
44
|
-
_iterator.f();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return count;
|
|
48
|
-
} else if (node instanceof Pair) {
|
|
49
|
-
var kc = getAliasCount(node.key, anchors);
|
|
50
|
-
var vc = getAliasCount(node.value, anchors);
|
|
51
|
-
return Math.max(kc, vc);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return 1;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export var Alias = /*#__PURE__*/function (_Node) {
|
|
58
|
-
_inherits(Alias, _Node);
|
|
59
|
-
|
|
60
|
-
var _super = _createSuper(Alias);
|
|
61
|
-
|
|
62
|
-
_createClass(Alias, null, [{
|
|
63
|
-
key: "stringify",
|
|
64
|
-
value: function stringify(_ref, _ref2) {
|
|
65
|
-
var range = _ref.range,
|
|
66
|
-
source = _ref.source;
|
|
67
|
-
var anchors = _ref2.anchors,
|
|
68
|
-
doc = _ref2.doc,
|
|
69
|
-
implicitKey = _ref2.implicitKey,
|
|
70
|
-
inStringifyKey = _ref2.inStringifyKey;
|
|
71
|
-
var anchor = Object.keys(anchors).find(function (a) {
|
|
72
|
-
return anchors[a] === source;
|
|
73
|
-
});
|
|
74
|
-
if (!anchor && inStringifyKey) anchor = doc.anchors.getName(source) || doc.anchors.newName();
|
|
75
|
-
if (anchor) return "*".concat(anchor).concat(implicitKey ? ' ' : '');
|
|
76
|
-
var msg = doc.anchors.getName(source) ? 'Alias node must be after source node' : 'Source node not found for alias node';
|
|
77
|
-
throw new Error("".concat(msg, " [").concat(range, "]"));
|
|
78
|
-
}
|
|
79
|
-
}]);
|
|
80
|
-
|
|
81
|
-
function Alias(source) {
|
|
82
|
-
var _this;
|
|
83
|
-
|
|
84
|
-
_classCallCheck(this, Alias);
|
|
85
|
-
|
|
86
|
-
_this = _super.call(this);
|
|
87
|
-
_this.source = source;
|
|
88
|
-
_this.type = Type.ALIAS;
|
|
89
|
-
return _this;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
_createClass(Alias, [{
|
|
93
|
-
key: "toJSON",
|
|
94
|
-
value: function toJSON(arg, ctx) {
|
|
95
|
-
if (!ctx) return _toJSON(this.source, arg, ctx);
|
|
96
|
-
var anchors = ctx.anchors,
|
|
97
|
-
maxAliasCount = ctx.maxAliasCount;
|
|
98
|
-
var anchor = anchors.get(this.source);
|
|
99
|
-
/* istanbul ignore if */
|
|
100
|
-
|
|
101
|
-
if (!anchor || anchor.res === undefined) {
|
|
102
|
-
var msg = 'This should not happen: Alias anchor was not resolved?';
|
|
103
|
-
if (this.cstNode) throw new YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (maxAliasCount >= 0) {
|
|
107
|
-
anchor.count += 1;
|
|
108
|
-
if (anchor.aliasCount === 0) anchor.aliasCount = getAliasCount(this.source, anchors);
|
|
109
|
-
|
|
110
|
-
if (anchor.count * anchor.aliasCount > maxAliasCount) {
|
|
111
|
-
var _msg = 'Excessive alias count indicates a resource exhaustion attack';
|
|
112
|
-
if (this.cstNode) throw new YAMLReferenceError(this.cstNode, _msg);else throw new ReferenceError(_msg);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return anchor.res;
|
|
117
|
-
} // Only called when stringifying an alias mapping key while constructing
|
|
118
|
-
// Object output.
|
|
119
|
-
|
|
120
|
-
}, {
|
|
121
|
-
key: "toString",
|
|
122
|
-
value: function toString(ctx) {
|
|
123
|
-
return Alias.stringify(this, ctx);
|
|
124
|
-
}
|
|
125
|
-
}, {
|
|
126
|
-
key: "tag",
|
|
127
|
-
set: function set(t) {
|
|
128
|
-
throw new Error('Alias nodes cannot have tags');
|
|
129
|
-
}
|
|
130
|
-
}]);
|
|
131
|
-
|
|
132
|
-
return Alias;
|
|
133
|
-
}(Node);
|
|
134
|
-
|
|
135
|
-
_defineProperty(Alias, "default", true);
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import _toArray from "@babel/runtime/helpers/toArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
10
|
-
|
|
11
|
-
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
|
-
|
|
13
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
-
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
|
-
|
|
17
|
-
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
18
|
-
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
21
|
-
import { addComment } from '../addComment';
|
|
22
|
-
import { Type } from '../constants';
|
|
23
|
-
import { Node } from './Node';
|
|
24
|
-
import { Scalar } from './Scalar';
|
|
25
|
-
|
|
26
|
-
function collectionFromPath(schema, path, value) {
|
|
27
|
-
var v = value;
|
|
28
|
-
|
|
29
|
-
for (var i = path.length - 1; i >= 0; --i) {
|
|
30
|
-
var k = path[i];
|
|
31
|
-
var o = Number.isInteger(k) && k >= 0 ? [] : {};
|
|
32
|
-
o[k] = v;
|
|
33
|
-
v = o;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return schema.createNode(v, false);
|
|
37
|
-
} // null, undefined, or an empty non-string iterable (e.g. [])
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export var isEmptyPath = function isEmptyPath(path) {
|
|
41
|
-
return path == null || _typeof(path) === 'object' && path[Symbol.iterator]().next().done;
|
|
42
|
-
};
|
|
43
|
-
export var Collection = /*#__PURE__*/function (_Node) {
|
|
44
|
-
_inherits(Collection, _Node);
|
|
45
|
-
|
|
46
|
-
var _super = _createSuper(Collection);
|
|
47
|
-
|
|
48
|
-
function Collection(schema) {
|
|
49
|
-
var _this;
|
|
50
|
-
|
|
51
|
-
_classCallCheck(this, Collection);
|
|
52
|
-
|
|
53
|
-
_this = _super.call(this);
|
|
54
|
-
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "items", []);
|
|
56
|
-
|
|
57
|
-
_this.schema = schema;
|
|
58
|
-
return _this;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
_createClass(Collection, [{
|
|
62
|
-
key: "addIn",
|
|
63
|
-
value: function addIn(path, value) {
|
|
64
|
-
if (isEmptyPath(path)) this.add(value);else {
|
|
65
|
-
var _path = _toArray(path),
|
|
66
|
-
key = _path[0],
|
|
67
|
-
rest = _path.slice(1);
|
|
68
|
-
|
|
69
|
-
var node = this.get(key, true);
|
|
70
|
-
if (node instanceof Collection) node.addIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error("Expected YAML collection at ".concat(key, ". Remaining path: ").concat(rest));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "deleteIn",
|
|
75
|
-
value: function deleteIn(_ref) {
|
|
76
|
-
var _ref2 = _toArray(_ref),
|
|
77
|
-
key = _ref2[0],
|
|
78
|
-
rest = _ref2.slice(1);
|
|
79
|
-
|
|
80
|
-
if (rest.length === 0) return this.delete(key);
|
|
81
|
-
var node = this.get(key, true);
|
|
82
|
-
if (node instanceof Collection) return node.deleteIn(rest);else throw new Error("Expected YAML collection at ".concat(key, ". Remaining path: ").concat(rest));
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "getIn",
|
|
86
|
-
value: function getIn(_ref3, keepScalar) {
|
|
87
|
-
var _ref4 = _toArray(_ref3),
|
|
88
|
-
key = _ref4[0],
|
|
89
|
-
rest = _ref4.slice(1);
|
|
90
|
-
|
|
91
|
-
var node = this.get(key, true);
|
|
92
|
-
if (rest.length === 0) return !keepScalar && node instanceof Scalar ? node.value : node;else return node instanceof Collection ? node.getIn(rest, keepScalar) : undefined;
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
key: "hasAllNullValues",
|
|
96
|
-
value: function hasAllNullValues() {
|
|
97
|
-
return this.items.every(function (node) {
|
|
98
|
-
if (!node || node.type !== 'PAIR') return false;
|
|
99
|
-
var n = node.value;
|
|
100
|
-
return n == null || n instanceof Scalar && n.value == null && !n.commentBefore && !n.comment && !n.tag;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}, {
|
|
104
|
-
key: "hasIn",
|
|
105
|
-
value: function hasIn(_ref5) {
|
|
106
|
-
var _ref6 = _toArray(_ref5),
|
|
107
|
-
key = _ref6[0],
|
|
108
|
-
rest = _ref6.slice(1);
|
|
109
|
-
|
|
110
|
-
if (rest.length === 0) return this.has(key);
|
|
111
|
-
var node = this.get(key, true);
|
|
112
|
-
return node instanceof Collection ? node.hasIn(rest) : false;
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "setIn",
|
|
116
|
-
value: function setIn(_ref7, value) {
|
|
117
|
-
var _ref8 = _toArray(_ref7),
|
|
118
|
-
key = _ref8[0],
|
|
119
|
-
rest = _ref8.slice(1);
|
|
120
|
-
|
|
121
|
-
if (rest.length === 0) {
|
|
122
|
-
this.set(key, value);
|
|
123
|
-
} else {
|
|
124
|
-
var node = this.get(key, true);
|
|
125
|
-
if (node instanceof Collection) node.setIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error("Expected YAML collection at ".concat(key, ". Remaining path: ").concat(rest));
|
|
126
|
-
}
|
|
127
|
-
} // overridden in implementations
|
|
128
|
-
|
|
129
|
-
/* istanbul ignore next */
|
|
130
|
-
|
|
131
|
-
}, {
|
|
132
|
-
key: "toJSON",
|
|
133
|
-
value: function toJSON() {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}, {
|
|
137
|
-
key: "toString",
|
|
138
|
-
value: function toString(ctx, _ref9, onComment, onChompKeep) {
|
|
139
|
-
var _this2 = this;
|
|
140
|
-
|
|
141
|
-
var blockItem = _ref9.blockItem,
|
|
142
|
-
flowChars = _ref9.flowChars,
|
|
143
|
-
isMap = _ref9.isMap,
|
|
144
|
-
itemIndent = _ref9.itemIndent;
|
|
145
|
-
var _ctx = ctx,
|
|
146
|
-
doc = _ctx.doc,
|
|
147
|
-
indent = _ctx.indent,
|
|
148
|
-
indentStep = _ctx.indentStep;
|
|
149
|
-
var inFlow = this.type === Type.FLOW_MAP || this.type === Type.FLOW_SEQ || ctx.inFlow;
|
|
150
|
-
if (inFlow) itemIndent += indentStep;
|
|
151
|
-
var allNullValues = isMap && this.hasAllNullValues();
|
|
152
|
-
ctx = Object.assign({}, ctx, {
|
|
153
|
-
allNullValues: allNullValues,
|
|
154
|
-
indent: itemIndent,
|
|
155
|
-
inFlow: inFlow,
|
|
156
|
-
type: null
|
|
157
|
-
});
|
|
158
|
-
var chompKeep = false;
|
|
159
|
-
var hasItemWithNewLine = false;
|
|
160
|
-
var nodes = this.items.reduce(function (nodes, item, i) {
|
|
161
|
-
var comment;
|
|
162
|
-
|
|
163
|
-
if (item) {
|
|
164
|
-
if (!chompKeep && item.spaceBefore) nodes.push({
|
|
165
|
-
type: 'comment',
|
|
166
|
-
str: ''
|
|
167
|
-
});
|
|
168
|
-
if (item.commentBefore) item.commentBefore.match(/^.*$/gm).forEach(function (line) {
|
|
169
|
-
nodes.push({
|
|
170
|
-
type: 'comment',
|
|
171
|
-
str: "#".concat(line)
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
if (item.comment) comment = item.comment;
|
|
175
|
-
if (inFlow && (!chompKeep && item.spaceBefore || item.commentBefore || item.comment || item.key && (item.key.commentBefore || item.key.comment) || item.value && (item.value.commentBefore || item.value.comment))) hasItemWithNewLine = true;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
chompKeep = false;
|
|
179
|
-
var str = doc.schema.stringify(item, ctx, function () {
|
|
180
|
-
return comment = null;
|
|
181
|
-
}, function () {
|
|
182
|
-
return chompKeep = true;
|
|
183
|
-
});
|
|
184
|
-
if (inFlow && !hasItemWithNewLine && str.includes('\n')) hasItemWithNewLine = true;
|
|
185
|
-
if (inFlow && i < _this2.items.length - 1) str += ',';
|
|
186
|
-
str = addComment(str, itemIndent, comment);
|
|
187
|
-
if (chompKeep && (comment || inFlow)) chompKeep = false;
|
|
188
|
-
nodes.push({
|
|
189
|
-
type: 'item',
|
|
190
|
-
str: str
|
|
191
|
-
});
|
|
192
|
-
return nodes;
|
|
193
|
-
}, []);
|
|
194
|
-
var str;
|
|
195
|
-
|
|
196
|
-
if (nodes.length === 0) {
|
|
197
|
-
str = flowChars.start + flowChars.end;
|
|
198
|
-
} else if (inFlow) {
|
|
199
|
-
var start = flowChars.start,
|
|
200
|
-
end = flowChars.end;
|
|
201
|
-
var strings = nodes.map(function (n) {
|
|
202
|
-
return n.str;
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
if (hasItemWithNewLine || strings.reduce(function (sum, str) {
|
|
206
|
-
return sum + str.length + 2;
|
|
207
|
-
}, 2) > Collection.maxFlowStringSingleLineLength) {
|
|
208
|
-
str = start;
|
|
209
|
-
|
|
210
|
-
var _iterator = _createForOfIteratorHelper(strings),
|
|
211
|
-
_step;
|
|
212
|
-
|
|
213
|
-
try {
|
|
214
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
215
|
-
var s = _step.value;
|
|
216
|
-
str += s ? "\n".concat(indentStep).concat(indent).concat(s) : '\n';
|
|
217
|
-
}
|
|
218
|
-
} catch (err) {
|
|
219
|
-
_iterator.e(err);
|
|
220
|
-
} finally {
|
|
221
|
-
_iterator.f();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
str += "\n".concat(indent).concat(end);
|
|
225
|
-
} else {
|
|
226
|
-
str = "".concat(start, " ").concat(strings.join(' '), " ").concat(end);
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
var _strings = nodes.map(blockItem);
|
|
230
|
-
|
|
231
|
-
str = _strings.shift();
|
|
232
|
-
|
|
233
|
-
var _iterator2 = _createForOfIteratorHelper(_strings),
|
|
234
|
-
_step2;
|
|
235
|
-
|
|
236
|
-
try {
|
|
237
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
238
|
-
var _s = _step2.value;
|
|
239
|
-
str += _s ? "\n".concat(indent).concat(_s) : '\n';
|
|
240
|
-
}
|
|
241
|
-
} catch (err) {
|
|
242
|
-
_iterator2.e(err);
|
|
243
|
-
} finally {
|
|
244
|
-
_iterator2.f();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (this.comment) {
|
|
249
|
-
str += '\n' + this.comment.replace(/^/gm, "".concat(indent, "#"));
|
|
250
|
-
if (onComment) onComment();
|
|
251
|
-
} else if (chompKeep && onChompKeep) onChompKeep();
|
|
252
|
-
|
|
253
|
-
return str;
|
|
254
|
-
}
|
|
255
|
-
}]);
|
|
256
|
-
|
|
257
|
-
return Collection;
|
|
258
|
-
}(Node);
|
|
259
|
-
|
|
260
|
-
_defineProperty(Collection, "maxFlowStringSingleLineLength", 60);
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _get from "@babel/runtime/helpers/get";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
|
|
8
|
-
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
|
|
10
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
|
|
12
|
-
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
13
|
-
|
|
14
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
|
|
16
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
-
|
|
18
|
-
import { Collection } from './Collection';
|
|
19
|
-
import { Pair } from './Pair';
|
|
20
|
-
import { Scalar } from './Scalar';
|
|
21
|
-
export function findPair(items, key) {
|
|
22
|
-
var k = key instanceof Scalar ? key.value : key;
|
|
23
|
-
|
|
24
|
-
var _iterator = _createForOfIteratorHelper(items),
|
|
25
|
-
_step;
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
29
|
-
var it = _step.value;
|
|
30
|
-
|
|
31
|
-
if (it instanceof Pair) {
|
|
32
|
-
if (it.key === key || it.key === k) return it;
|
|
33
|
-
if (it.key && it.key.value === k) return it;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} catch (err) {
|
|
37
|
-
_iterator.e(err);
|
|
38
|
-
} finally {
|
|
39
|
-
_iterator.f();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
export var YAMLMap = /*#__PURE__*/function (_Collection) {
|
|
45
|
-
_inherits(YAMLMap, _Collection);
|
|
46
|
-
|
|
47
|
-
var _super = _createSuper(YAMLMap);
|
|
48
|
-
|
|
49
|
-
function YAMLMap() {
|
|
50
|
-
_classCallCheck(this, YAMLMap);
|
|
51
|
-
|
|
52
|
-
return _super.apply(this, arguments);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_createClass(YAMLMap, [{
|
|
56
|
-
key: "add",
|
|
57
|
-
value: function add(pair, overwrite) {
|
|
58
|
-
if (!pair) pair = new Pair(pair);else if (!(pair instanceof Pair)) pair = new Pair(pair.key || pair, pair.value);
|
|
59
|
-
var prev = findPair(this.items, pair.key);
|
|
60
|
-
var sortEntries = this.schema && this.schema.sortMapEntries;
|
|
61
|
-
|
|
62
|
-
if (prev) {
|
|
63
|
-
if (overwrite) prev.value = pair.value;else throw new Error("Key ".concat(pair.key, " already set"));
|
|
64
|
-
} else if (sortEntries) {
|
|
65
|
-
var i = this.items.findIndex(function (item) {
|
|
66
|
-
return sortEntries(pair, item) < 0;
|
|
67
|
-
});
|
|
68
|
-
if (i === -1) this.items.push(pair);else this.items.splice(i, 0, pair);
|
|
69
|
-
} else {
|
|
70
|
-
this.items.push(pair);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "delete",
|
|
75
|
-
value: function _delete(key) {
|
|
76
|
-
var it = findPair(this.items, key);
|
|
77
|
-
if (!it) return false;
|
|
78
|
-
var del = this.items.splice(this.items.indexOf(it), 1);
|
|
79
|
-
return del.length > 0;
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "get",
|
|
83
|
-
value: function get(key, keepScalar) {
|
|
84
|
-
var it = findPair(this.items, key);
|
|
85
|
-
var node = it && it.value;
|
|
86
|
-
return !keepScalar && node instanceof Scalar ? node.value : node;
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "has",
|
|
90
|
-
value: function has(key) {
|
|
91
|
-
return !!findPair(this.items, key);
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "set",
|
|
95
|
-
value: function set(key, value) {
|
|
96
|
-
this.add(new Pair(key, value), true);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* @param {*} arg ignored
|
|
100
|
-
* @param {*} ctx Conversion context, originally set in Document#toJSON()
|
|
101
|
-
* @param {Class} Type If set, forces the returned collection type
|
|
102
|
-
* @returns {*} Instance of Type, Map, or Object
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
}, {
|
|
106
|
-
key: "toJSON",
|
|
107
|
-
value: function toJSON(_, ctx, Type) {
|
|
108
|
-
var map = Type ? new Type() : ctx && ctx.mapAsMap ? new Map() : {};
|
|
109
|
-
if (ctx && ctx.onCreate) ctx.onCreate(map);
|
|
110
|
-
|
|
111
|
-
var _iterator2 = _createForOfIteratorHelper(this.items),
|
|
112
|
-
_step2;
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
116
|
-
var item = _step2.value;
|
|
117
|
-
item.addToJSMap(ctx, map);
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
_iterator2.e(err);
|
|
121
|
-
} finally {
|
|
122
|
-
_iterator2.f();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return map;
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "toString",
|
|
129
|
-
value: function toString(ctx, onComment, onChompKeep) {
|
|
130
|
-
if (!ctx) return JSON.stringify(this);
|
|
131
|
-
|
|
132
|
-
var _iterator3 = _createForOfIteratorHelper(this.items),
|
|
133
|
-
_step3;
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
137
|
-
var item = _step3.value;
|
|
138
|
-
if (!(item instanceof Pair)) throw new Error("Map items must all be pairs; found ".concat(JSON.stringify(item), " instead"));
|
|
139
|
-
}
|
|
140
|
-
} catch (err) {
|
|
141
|
-
_iterator3.e(err);
|
|
142
|
-
} finally {
|
|
143
|
-
_iterator3.f();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return _get(_getPrototypeOf(YAMLMap.prototype), "toString", this).call(this, ctx, {
|
|
147
|
-
blockItem: function blockItem(n) {
|
|
148
|
-
return n.str;
|
|
149
|
-
},
|
|
150
|
-
flowChars: {
|
|
151
|
-
start: '{',
|
|
152
|
-
end: '}'
|
|
153
|
-
},
|
|
154
|
-
isMap: true,
|
|
155
|
-
itemIndent: ctx.indent || ''
|
|
156
|
-
}, onComment, onChompKeep);
|
|
157
|
-
}
|
|
158
|
-
}]);
|
|
159
|
-
|
|
160
|
-
return YAMLMap;
|
|
161
|
-
}(Collection);
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _get from "@babel/runtime/helpers/get";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
|
|
9
|
-
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
-
|
|
11
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
-
|
|
15
|
-
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
-
|
|
17
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
-
|
|
19
|
-
import { YAMLMap } from './Map';
|
|
20
|
-
import { Pair } from './Pair';
|
|
21
|
-
import { Scalar } from './Scalar';
|
|
22
|
-
import { YAMLSeq } from './Seq';
|
|
23
|
-
export var MERGE_KEY = '<<';
|
|
24
|
-
export var Merge = /*#__PURE__*/function (_Pair) {
|
|
25
|
-
_inherits(Merge, _Pair);
|
|
26
|
-
|
|
27
|
-
var _super = _createSuper(Merge);
|
|
28
|
-
|
|
29
|
-
function Merge(pair) {
|
|
30
|
-
var _this;
|
|
31
|
-
|
|
32
|
-
_classCallCheck(this, Merge);
|
|
33
|
-
|
|
34
|
-
if (pair instanceof Pair) {
|
|
35
|
-
var seq = pair.value;
|
|
36
|
-
|
|
37
|
-
if (!(seq instanceof YAMLSeq)) {
|
|
38
|
-
seq = new YAMLSeq();
|
|
39
|
-
seq.items.push(pair.value);
|
|
40
|
-
seq.range = pair.value.range;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
_this = _super.call(this, pair.key, seq);
|
|
44
|
-
_this.range = pair.range;
|
|
45
|
-
} else {
|
|
46
|
-
_this = _super.call(this, new Scalar(MERGE_KEY), new YAMLSeq());
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
_this.type = Pair.Type.MERGE_PAIR;
|
|
50
|
-
return _possibleConstructorReturn(_this);
|
|
51
|
-
} // If the value associated with a merge key is a single mapping node, each of
|
|
52
|
-
// its key/value pairs is inserted into the current mapping, unless the key
|
|
53
|
-
// already exists in it. If the value associated with the merge key is a
|
|
54
|
-
// sequence, then this sequence is expected to contain mapping nodes and each
|
|
55
|
-
// of these nodes is merged in turn according to its order in the sequence.
|
|
56
|
-
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
57
|
-
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
_createClass(Merge, [{
|
|
61
|
-
key: "addToJSMap",
|
|
62
|
-
value: function addToJSMap(ctx, map) {
|
|
63
|
-
var _iterator = _createForOfIteratorHelper(this.value.items),
|
|
64
|
-
_step;
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
68
|
-
var source = _step.value.source;
|
|
69
|
-
if (!(source instanceof YAMLMap)) throw new Error('Merge sources must be maps');
|
|
70
|
-
var srcMap = source.toJSON(null, ctx, Map);
|
|
71
|
-
|
|
72
|
-
var _iterator2 = _createForOfIteratorHelper(srcMap),
|
|
73
|
-
_step2;
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
77
|
-
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
78
|
-
key = _step2$value[0],
|
|
79
|
-
value = _step2$value[1];
|
|
80
|
-
|
|
81
|
-
if (map instanceof Map) {
|
|
82
|
-
if (!map.has(key)) map.set(key, value);
|
|
83
|
-
} else if (map instanceof Set) {
|
|
84
|
-
map.add(key);
|
|
85
|
-
} else {
|
|
86
|
-
if (!Object.prototype.hasOwnProperty.call(map, key)) map[key] = value;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} catch (err) {
|
|
90
|
-
_iterator2.e(err);
|
|
91
|
-
} finally {
|
|
92
|
-
_iterator2.f();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
} catch (err) {
|
|
96
|
-
_iterator.e(err);
|
|
97
|
-
} finally {
|
|
98
|
-
_iterator.f();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return map;
|
|
102
|
-
}
|
|
103
|
-
}, {
|
|
104
|
-
key: "toString",
|
|
105
|
-
value: function toString(ctx, onComment) {
|
|
106
|
-
var seq = this.value;
|
|
107
|
-
if (seq.items.length > 1) return _get(_getPrototypeOf(Merge.prototype), "toString", this).call(this, ctx, onComment);
|
|
108
|
-
this.value = seq.items[0];
|
|
109
|
-
|
|
110
|
-
var str = _get(_getPrototypeOf(Merge.prototype), "toString", this).call(this, ctx, onComment);
|
|
111
|
-
|
|
112
|
-
this.value = seq;
|
|
113
|
-
return str;
|
|
114
|
-
}
|
|
115
|
-
}]);
|
|
116
|
-
|
|
117
|
-
return Merge;
|
|
118
|
-
}(Pair);
|