yaml 1.8.3 → 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 +923 -38
- 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 -2
- package/browser/pair.js +2 -2
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +2 -2
- package/browser/schema.js +8 -6
- package/browser/seq.js +2 -2
- package/browser/types/binary.js +3 -2
- package/browser/types/omap.js +3 -2
- package/browser/types/pairs.js +3 -2
- package/browser/types/set.js +3 -2
- package/browser/types/timestamp.js +6 -6
- package/browser/types.js +1 -11
- package/browser/util.js +1 -15
- 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 +21 -43
- 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 -14
- package/dist/types.js +23 -0
- package/dist/util.js +19 -0
- package/dist/warnings-39684f17.js +416 -0
- package/index.d.ts +372 -0
- package/index.js +1 -1
- package/map.js +2 -2
- package/package.json +32 -45
- package/pair.js +2 -2
- package/parse-cst.d.ts +187 -0
- 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 +407 -0
- package/types.js +16 -10
- package/types.mjs +15 -18
- package/util.d.ts +86 -0
- package/util.js +14 -13
- package/util.mjs +13 -19
- package/browser/dist/Anchors.js +0 -133
- package/browser/dist/Document.js +0 -819
- package/browser/dist/addComment.js +0 -8
- package/browser/dist/constants.js +0 -26
- package/browser/dist/cst/Alias.js +0 -42
- package/browser/dist/cst/BlankLine.js +0 -56
- package/browser/dist/cst/BlockValue.js +0 -247
- package/browser/dist/cst/Collection.js +0 -274
- package/browser/dist/cst/CollectionItem.js +0 -136
- package/browser/dist/cst/Comment.js +0 -40
- package/browser/dist/cst/Directive.js +0 -72
- package/browser/dist/cst/Document.js +0 -282
- package/browser/dist/cst/FlowCollection.js +0 -216
- package/browser/dist/cst/Node.js +0 -388
- package/browser/dist/cst/ParseContext.js +0 -248
- package/browser/dist/cst/PlainValue.js +0 -166
- package/browser/dist/cst/QuoteDouble.js +0 -241
- package/browser/dist/cst/QuoteSingle.js +0 -116
- package/browser/dist/cst/Range.js +0 -67
- package/browser/dist/cst/parse.js +0 -48
- package/browser/dist/cst/source-utils.js +0 -168
- package/browser/dist/errors.js +0 -112
- package/browser/dist/foldFlowLines.js +0 -138
- package/browser/dist/listTagNames.js +0 -28
- package/browser/dist/schema/Alias.js +0 -139
- package/browser/dist/schema/Collection.js +0 -267
- package/browser/dist/schema/Map.js +0 -178
- package/browser/dist/schema/Merge.js +0 -127
- package/browser/dist/schema/Node.js +0 -7
- package/browser/dist/schema/Pair.js +0 -171
- package/browser/dist/schema/Scalar.js +0 -38
- package/browser/dist/schema/Seq.js +0 -114
- package/browser/dist/schema/index.js +0 -382
- package/browser/dist/schema/parseMap.js +0 -312
- package/browser/dist/schema/parseSeq.js +0 -168
- package/browser/dist/schema/parseUtils.js +0 -110
- package/browser/dist/stringify.js +0 -331
- package/browser/dist/tags/core.js +0 -126
- package/browser/dist/tags/failsafe/index.js +0 -4
- package/browser/dist/tags/failsafe/map.js +0 -56
- package/browser/dist/tags/failsafe/seq.js +0 -43
- package/browser/dist/tags/failsafe/string.js +0 -28
- package/browser/dist/tags/index.js +0 -36
- package/browser/dist/tags/json.js +0 -76
- package/browser/dist/tags/options.js +0 -23
- package/browser/dist/tags/yaml-1.1/binary.js +0 -87
- package/browser/dist/tags/yaml-1.1/index.js +0 -157
- package/browser/dist/tags/yaml-1.1/omap.js +0 -142
- package/browser/dist/tags/yaml-1.1/pairs.js +0 -81
- package/browser/dist/tags/yaml-1.1/set.js +0 -114
- 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 -20
- package/browser/dist/warnings.js +0 -28
- package/dist/Anchors.js +0 -125
- package/dist/Document.js +0 -710
- package/dist/addComment.js +0 -17
- package/dist/constants.js +0 -34
- package/dist/cst/Alias.js +0 -38
- package/dist/cst/BlankLine.js +0 -56
- package/dist/cst/BlockValue.js +0 -248
- package/dist/cst/Collection.js +0 -271
- package/dist/cst/CollectionItem.js +0 -140
- package/dist/cst/Comment.js +0 -38
- package/dist/cst/Directive.js +0 -64
- package/dist/cst/Document.js +0 -281
- package/dist/cst/FlowCollection.js +0 -218
- package/dist/cst/Node.js +0 -365
- package/dist/cst/ParseContext.js +0 -258
- package/dist/cst/PlainValue.js +0 -161
- package/dist/cst/QuoteDouble.js +0 -237
- package/dist/cst/QuoteSingle.js +0 -113
- package/dist/cst/Range.js +0 -63
- package/dist/cst/parse.js +0 -55
- package/dist/cst/source-utils.js +0 -178
- package/dist/errors.js +0 -102
- package/dist/foldFlowLines.js +0 -146
- package/dist/listTagNames.js +0 -38
- package/dist/schema/Alias.js +0 -110
- package/dist/schema/Collection.js +0 -188
- package/dist/schema/Map.js +0 -103
- package/dist/schema/Merge.js +0 -80
- package/dist/schema/Node.js +0 -10
- package/dist/schema/Pair.js +0 -161
- package/dist/schema/Scalar.js +0 -31
- package/dist/schema/Seq.js +0 -78
- package/dist/schema/index.js +0 -315
- package/dist/schema/parseMap.js +0 -343
- package/dist/schema/parseSeq.js +0 -180
- package/dist/schema/parseUtils.js +0 -104
- package/dist/stringify.js +0 -358
- package/dist/tags/core.js +0 -114
- package/dist/tags/failsafe/index.js +0 -17
- package/dist/tags/failsafe/map.js +0 -37
- package/dist/tags/failsafe/seq.js +0 -34
- package/dist/tags/failsafe/string.js +0 -40
- package/dist/tags/index.js +0 -62
- package/dist/tags/json.js +0 -60
- package/dist/tags/options.js +0 -35
- package/dist/tags/yaml-1.1/binary.js +0 -97
- package/dist/tags/yaml-1.1/index.js +0 -131
- package/dist/tags/yaml-1.1/omap.js +0 -105
- package/dist/tags/yaml-1.1/pairs.js +0 -80
- package/dist/tags/yaml-1.1/set.js +0 -91
- package/dist/tags/yaml-1.1/timestamp.js +0 -93
- package/dist/toJSON.js +0 -23
- package/dist/warnings.js +0 -39
|
@@ -1,127 +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 _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _get from "@babel/runtime/helpers/get";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
-
import YAMLMap from './Map';
|
|
9
|
-
import Pair from './Pair';
|
|
10
|
-
import Scalar from './Scalar';
|
|
11
|
-
import Seq from './Seq';
|
|
12
|
-
export var MERGE_KEY = '<<';
|
|
13
|
-
|
|
14
|
-
var Merge = /*#__PURE__*/function (_Pair) {
|
|
15
|
-
_inherits(Merge, _Pair);
|
|
16
|
-
|
|
17
|
-
function Merge(pair) {
|
|
18
|
-
var _this;
|
|
19
|
-
|
|
20
|
-
_classCallCheck(this, Merge);
|
|
21
|
-
|
|
22
|
-
if (pair instanceof Pair) {
|
|
23
|
-
var seq = pair.value;
|
|
24
|
-
|
|
25
|
-
if (!(seq instanceof Seq)) {
|
|
26
|
-
seq = new Seq();
|
|
27
|
-
seq.items.push(pair.value);
|
|
28
|
-
seq.range = pair.value.range;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
_this = _possibleConstructorReturn(this, _getPrototypeOf(Merge).call(this, pair.key, seq));
|
|
32
|
-
_this.range = pair.range;
|
|
33
|
-
} else {
|
|
34
|
-
_this = _possibleConstructorReturn(this, _getPrototypeOf(Merge).call(this, new Scalar(MERGE_KEY), new Seq()));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
_this.type = 'MERGE_PAIR';
|
|
38
|
-
return _possibleConstructorReturn(_this);
|
|
39
|
-
} // If the value associated with a merge key is a single mapping node, each of
|
|
40
|
-
// its key/value pairs is inserted into the current mapping, unless the key
|
|
41
|
-
// already exists in it. If the value associated with the merge key is a
|
|
42
|
-
// sequence, then this sequence is expected to contain mapping nodes and each
|
|
43
|
-
// of these nodes is merged in turn according to its order in the sequence.
|
|
44
|
-
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
45
|
-
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
_createClass(Merge, [{
|
|
49
|
-
key: "addToJSMap",
|
|
50
|
-
value: function addToJSMap(ctx, map) {
|
|
51
|
-
var _iteratorNormalCompletion = true;
|
|
52
|
-
var _didIteratorError = false;
|
|
53
|
-
var _iteratorError = undefined;
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
for (var _iterator = this.value.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
57
|
-
var source = _step.value.source;
|
|
58
|
-
if (!(source instanceof YAMLMap)) throw new Error('Merge sources must be maps');
|
|
59
|
-
var srcMap = source.toJSON(null, ctx, Map);
|
|
60
|
-
var _iteratorNormalCompletion2 = true;
|
|
61
|
-
var _didIteratorError2 = false;
|
|
62
|
-
var _iteratorError2 = undefined;
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
for (var _iterator2 = srcMap[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
66
|
-
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
67
|
-
key = _step2$value[0],
|
|
68
|
-
value = _step2$value[1];
|
|
69
|
-
|
|
70
|
-
if (map instanceof Map) {
|
|
71
|
-
if (!map.has(key)) map.set(key, value);
|
|
72
|
-
} else if (map instanceof Set) {
|
|
73
|
-
map.add(key);
|
|
74
|
-
} else {
|
|
75
|
-
if (!Object.prototype.hasOwnProperty.call(map, key)) map[key] = value;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
} catch (err) {
|
|
79
|
-
_didIteratorError2 = true;
|
|
80
|
-
_iteratorError2 = err;
|
|
81
|
-
} finally {
|
|
82
|
-
try {
|
|
83
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
84
|
-
_iterator2.return();
|
|
85
|
-
}
|
|
86
|
-
} finally {
|
|
87
|
-
if (_didIteratorError2) {
|
|
88
|
-
throw _iteratorError2;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
} catch (err) {
|
|
94
|
-
_didIteratorError = true;
|
|
95
|
-
_iteratorError = err;
|
|
96
|
-
} finally {
|
|
97
|
-
try {
|
|
98
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
99
|
-
_iterator.return();
|
|
100
|
-
}
|
|
101
|
-
} finally {
|
|
102
|
-
if (_didIteratorError) {
|
|
103
|
-
throw _iteratorError;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return map;
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "toString",
|
|
112
|
-
value: function toString(ctx, onComment) {
|
|
113
|
-
var seq = this.value;
|
|
114
|
-
if (seq.items.length > 1) return _get(_getPrototypeOf(Merge.prototype), "toString", this).call(this, ctx, onComment);
|
|
115
|
-
this.value = seq.items[0];
|
|
116
|
-
|
|
117
|
-
var str = _get(_getPrototypeOf(Merge.prototype), "toString", this).call(this, ctx, onComment);
|
|
118
|
-
|
|
119
|
-
this.value = seq;
|
|
120
|
-
return str;
|
|
121
|
-
}
|
|
122
|
-
}]);
|
|
123
|
-
|
|
124
|
-
return Merge;
|
|
125
|
-
}(Pair);
|
|
126
|
-
|
|
127
|
-
export { Merge as default };
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
7
|
-
// Published as 'yaml/pair'
|
|
8
|
-
import addComment from '../addComment';
|
|
9
|
-
import { Type } from '../constants';
|
|
10
|
-
import toJSON from '../toJSON';
|
|
11
|
-
import Collection from './Collection';
|
|
12
|
-
import Node from './Node';
|
|
13
|
-
import Scalar from './Scalar';
|
|
14
|
-
|
|
15
|
-
var stringifyKey = function stringifyKey(key, jsKey, ctx) {
|
|
16
|
-
if (jsKey === null) return '';
|
|
17
|
-
if (_typeof(jsKey) !== 'object') return String(jsKey);
|
|
18
|
-
if (key instanceof Node && ctx && ctx.doc) return key.toString({
|
|
19
|
-
anchors: {},
|
|
20
|
-
doc: ctx.doc,
|
|
21
|
-
indent: '',
|
|
22
|
-
inFlow: true,
|
|
23
|
-
inStringifyKey: true
|
|
24
|
-
});
|
|
25
|
-
return JSON.stringify(jsKey);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
var Pair = /*#__PURE__*/function (_Node) {
|
|
29
|
-
_inherits(Pair, _Node);
|
|
30
|
-
|
|
31
|
-
function Pair(key) {
|
|
32
|
-
var _this;
|
|
33
|
-
|
|
34
|
-
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
35
|
-
|
|
36
|
-
_classCallCheck(this, Pair);
|
|
37
|
-
|
|
38
|
-
_this = _possibleConstructorReturn(this, _getPrototypeOf(Pair).call(this));
|
|
39
|
-
_this.key = key;
|
|
40
|
-
_this.value = value;
|
|
41
|
-
_this.type = 'PAIR';
|
|
42
|
-
return _this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_createClass(Pair, [{
|
|
46
|
-
key: "addToJSMap",
|
|
47
|
-
value: function addToJSMap(ctx, map) {
|
|
48
|
-
var key = toJSON(this.key, '', ctx);
|
|
49
|
-
|
|
50
|
-
if (map instanceof Map) {
|
|
51
|
-
var value = toJSON(this.value, key, ctx);
|
|
52
|
-
map.set(key, value);
|
|
53
|
-
} else if (map instanceof Set) {
|
|
54
|
-
map.add(key);
|
|
55
|
-
} else {
|
|
56
|
-
var stringKey = stringifyKey(this.key, key, ctx);
|
|
57
|
-
map[stringKey] = toJSON(this.value, stringKey, ctx);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return map;
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "toJSON",
|
|
64
|
-
value: function toJSON(_, ctx) {
|
|
65
|
-
var pair = ctx && ctx.mapAsMap ? new Map() : {};
|
|
66
|
-
return this.addToJSMap(ctx, pair);
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "toString",
|
|
70
|
-
value: function toString(ctx, onComment, onChompKeep) {
|
|
71
|
-
if (!ctx || !ctx.doc) return JSON.stringify(this);
|
|
72
|
-
var simpleKeys = ctx.doc.options.simpleKeys;
|
|
73
|
-
var key = this.key,
|
|
74
|
-
value = this.value;
|
|
75
|
-
var keyComment = key instanceof Node && key.comment;
|
|
76
|
-
|
|
77
|
-
if (simpleKeys) {
|
|
78
|
-
if (keyComment) {
|
|
79
|
-
throw new Error('With simple keys, key nodes cannot have comments');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (key instanceof Collection) {
|
|
83
|
-
var msg = 'With simple keys, collection cannot be used as a key value';
|
|
84
|
-
throw new Error(msg);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var explicitKey = !simpleKeys && (!key || keyComment || key instanceof Collection || key.type === Type.BLOCK_FOLDED || key.type === Type.BLOCK_LITERAL);
|
|
89
|
-
var _ctx = ctx,
|
|
90
|
-
doc = _ctx.doc,
|
|
91
|
-
indent = _ctx.indent;
|
|
92
|
-
ctx = Object.assign({}, ctx, {
|
|
93
|
-
implicitKey: !explicitKey,
|
|
94
|
-
indent: indent + ' '
|
|
95
|
-
});
|
|
96
|
-
var chompKeep = false;
|
|
97
|
-
var str = doc.schema.stringify(key, ctx, function () {
|
|
98
|
-
return keyComment = null;
|
|
99
|
-
}, function () {
|
|
100
|
-
return chompKeep = true;
|
|
101
|
-
});
|
|
102
|
-
str = addComment(str, ctx.indent, keyComment);
|
|
103
|
-
|
|
104
|
-
if (ctx.allNullValues && !simpleKeys) {
|
|
105
|
-
if (this.comment) {
|
|
106
|
-
str = addComment(str, ctx.indent, this.comment);
|
|
107
|
-
if (onComment) onComment();
|
|
108
|
-
} else if (chompKeep && !keyComment && onChompKeep) onChompKeep();
|
|
109
|
-
|
|
110
|
-
return ctx.inFlow ? str : "? ".concat(str);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
str = explicitKey ? "? ".concat(str, "\n").concat(indent, ":") : "".concat(str, ":");
|
|
114
|
-
|
|
115
|
-
if (this.comment) {
|
|
116
|
-
// expected (but not strictly required) to be a single-line comment
|
|
117
|
-
str = addComment(str, ctx.indent, this.comment);
|
|
118
|
-
if (onComment) onComment();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var vcb = '';
|
|
122
|
-
var valueComment = null;
|
|
123
|
-
|
|
124
|
-
if (value instanceof Node) {
|
|
125
|
-
if (value.spaceBefore) vcb = '\n';
|
|
126
|
-
|
|
127
|
-
if (value.commentBefore) {
|
|
128
|
-
var cs = value.commentBefore.replace(/^/gm, "".concat(ctx.indent, "#"));
|
|
129
|
-
vcb += "\n".concat(cs);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
valueComment = value.comment;
|
|
133
|
-
} else if (value && _typeof(value) === 'object') {
|
|
134
|
-
value = doc.schema.createNode(value, true);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
ctx.implicitKey = false;
|
|
138
|
-
if (!explicitKey && !this.comment && value instanceof Scalar) ctx.indentAtStart = str.length + 1;
|
|
139
|
-
chompKeep = false;
|
|
140
|
-
var valueStr = doc.schema.stringify(value, ctx, function () {
|
|
141
|
-
return valueComment = null;
|
|
142
|
-
}, function () {
|
|
143
|
-
return chompKeep = true;
|
|
144
|
-
});
|
|
145
|
-
var ws = ' ';
|
|
146
|
-
|
|
147
|
-
if (vcb || this.comment) {
|
|
148
|
-
ws = "".concat(vcb, "\n").concat(ctx.indent);
|
|
149
|
-
} else if (!explicitKey && value instanceof Collection) {
|
|
150
|
-
var flow = valueStr[0] === '[' || valueStr[0] === '{';
|
|
151
|
-
if (!flow || valueStr.includes('\n')) ws = "\n".concat(ctx.indent);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (chompKeep && !valueComment && onChompKeep) onChompKeep();
|
|
155
|
-
return addComment(str + ws + valueStr, ctx.indent, valueComment);
|
|
156
|
-
}
|
|
157
|
-
}, {
|
|
158
|
-
key: "commentBefore",
|
|
159
|
-
get: function get() {
|
|
160
|
-
return this.key && this.key.commentBefore;
|
|
161
|
-
},
|
|
162
|
-
set: function set(cb) {
|
|
163
|
-
if (this.key == null) this.key = new Scalar(null);
|
|
164
|
-
this.key.commentBefore = cb;
|
|
165
|
-
}
|
|
166
|
-
}]);
|
|
167
|
-
|
|
168
|
-
return Pair;
|
|
169
|
-
}(Node);
|
|
170
|
-
|
|
171
|
-
export { Pair as default };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
// Published as 'yaml/scalar'
|
|
7
|
-
import _toJSON from '../toJSON';
|
|
8
|
-
import Node from './Node';
|
|
9
|
-
|
|
10
|
-
var Scalar = /*#__PURE__*/function (_Node) {
|
|
11
|
-
_inherits(Scalar, _Node);
|
|
12
|
-
|
|
13
|
-
function Scalar(value) {
|
|
14
|
-
var _this;
|
|
15
|
-
|
|
16
|
-
_classCallCheck(this, Scalar);
|
|
17
|
-
|
|
18
|
-
_this = _possibleConstructorReturn(this, _getPrototypeOf(Scalar).call(this));
|
|
19
|
-
_this.value = value;
|
|
20
|
-
return _this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
_createClass(Scalar, [{
|
|
24
|
-
key: "toJSON",
|
|
25
|
-
value: function toJSON(arg, ctx) {
|
|
26
|
-
return ctx && ctx.keep ? this.value : _toJSON(this.value, arg, ctx);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "toString",
|
|
30
|
-
value: function toString() {
|
|
31
|
-
return String(this.value);
|
|
32
|
-
}
|
|
33
|
-
}]);
|
|
34
|
-
|
|
35
|
-
return Scalar;
|
|
36
|
-
}(Node);
|
|
37
|
-
|
|
38
|
-
export { Scalar as default };
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _get from "@babel/runtime/helpers/get";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
-
// Published as 'yaml/seq'
|
|
8
|
-
import _toJSON from '../toJSON';
|
|
9
|
-
import Collection from './Collection';
|
|
10
|
-
import Scalar from './Scalar';
|
|
11
|
-
|
|
12
|
-
function asItemIndex(key) {
|
|
13
|
-
var idx = key instanceof Scalar ? key.value : key;
|
|
14
|
-
if (idx && typeof idx === 'string') idx = Number(idx);
|
|
15
|
-
return Number.isInteger(idx) && idx >= 0 ? idx : null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var YAMLSeq = /*#__PURE__*/function (_Collection) {
|
|
19
|
-
_inherits(YAMLSeq, _Collection);
|
|
20
|
-
|
|
21
|
-
function YAMLSeq() {
|
|
22
|
-
_classCallCheck(this, YAMLSeq);
|
|
23
|
-
|
|
24
|
-
return _possibleConstructorReturn(this, _getPrototypeOf(YAMLSeq).apply(this, arguments));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
_createClass(YAMLSeq, [{
|
|
28
|
-
key: "add",
|
|
29
|
-
value: function add(value) {
|
|
30
|
-
this.items.push(value);
|
|
31
|
-
}
|
|
32
|
-
}, {
|
|
33
|
-
key: "delete",
|
|
34
|
-
value: function _delete(key) {
|
|
35
|
-
var idx = asItemIndex(key);
|
|
36
|
-
if (typeof idx !== 'number') return false;
|
|
37
|
-
var del = this.items.splice(idx, 1);
|
|
38
|
-
return del.length > 0;
|
|
39
|
-
}
|
|
40
|
-
}, {
|
|
41
|
-
key: "get",
|
|
42
|
-
value: function get(key, keepScalar) {
|
|
43
|
-
var idx = asItemIndex(key);
|
|
44
|
-
if (typeof idx !== 'number') return undefined;
|
|
45
|
-
var it = this.items[idx];
|
|
46
|
-
return !keepScalar && it instanceof Scalar ? it.value : it;
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
key: "has",
|
|
50
|
-
value: function has(key) {
|
|
51
|
-
var idx = asItemIndex(key);
|
|
52
|
-
return typeof idx === 'number' && idx < this.items.length;
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "set",
|
|
56
|
-
value: function set(key, value) {
|
|
57
|
-
var idx = asItemIndex(key);
|
|
58
|
-
if (typeof idx !== 'number') throw new Error("Expected a valid index, not ".concat(key, "."));
|
|
59
|
-
this.items[idx] = value;
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "toJSON",
|
|
63
|
-
value: function toJSON(_, ctx) {
|
|
64
|
-
var seq = [];
|
|
65
|
-
if (ctx && ctx.onCreate) ctx.onCreate(seq);
|
|
66
|
-
var i = 0;
|
|
67
|
-
var _iteratorNormalCompletion = true;
|
|
68
|
-
var _didIteratorError = false;
|
|
69
|
-
var _iteratorError = undefined;
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
for (var _iterator = this.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
73
|
-
var item = _step.value;
|
|
74
|
-
seq.push(_toJSON(item, String(i++), ctx));
|
|
75
|
-
}
|
|
76
|
-
} catch (err) {
|
|
77
|
-
_didIteratorError = true;
|
|
78
|
-
_iteratorError = err;
|
|
79
|
-
} finally {
|
|
80
|
-
try {
|
|
81
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
82
|
-
_iterator.return();
|
|
83
|
-
}
|
|
84
|
-
} finally {
|
|
85
|
-
if (_didIteratorError) {
|
|
86
|
-
throw _iteratorError;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return seq;
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "toString",
|
|
95
|
-
value: function toString(ctx, onComment, onChompKeep) {
|
|
96
|
-
if (!ctx) return JSON.stringify(this);
|
|
97
|
-
return _get(_getPrototypeOf(YAMLSeq.prototype), "toString", this).call(this, ctx, {
|
|
98
|
-
blockItem: function blockItem(n) {
|
|
99
|
-
return n.type === 'comment' ? n.str : "- ".concat(n.str);
|
|
100
|
-
},
|
|
101
|
-
flowChars: {
|
|
102
|
-
start: '[',
|
|
103
|
-
end: ']'
|
|
104
|
-
},
|
|
105
|
-
isMap: false,
|
|
106
|
-
itemIndent: (ctx.indent || '') + ' '
|
|
107
|
-
}, onComment, onChompKeep);
|
|
108
|
-
}
|
|
109
|
-
}]);
|
|
110
|
-
|
|
111
|
-
return YAMLSeq;
|
|
112
|
-
}(Collection);
|
|
113
|
-
|
|
114
|
-
export { YAMLSeq as default };
|