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,194 +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
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
8
|
-
|
|
9
|
-
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); }; }
|
|
10
|
-
|
|
11
|
-
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; } }
|
|
12
|
-
|
|
13
|
-
// Published as 'yaml/pair'
|
|
14
|
-
import { addComment } from '../addComment';
|
|
15
|
-
import { Type } from '../constants';
|
|
16
|
-
import { toJSON } from '../toJSON';
|
|
17
|
-
import { Collection } from './Collection';
|
|
18
|
-
import { Node } from './Node';
|
|
19
|
-
import { Scalar } from './Scalar';
|
|
20
|
-
import { YAMLSeq } from './Seq';
|
|
21
|
-
|
|
22
|
-
var stringifyKey = function stringifyKey(key, jsKey, ctx) {
|
|
23
|
-
if (jsKey === null) return '';
|
|
24
|
-
if (_typeof(jsKey) !== 'object') return String(jsKey);
|
|
25
|
-
if (key instanceof Node && ctx && ctx.doc) return key.toString({
|
|
26
|
-
anchors: {},
|
|
27
|
-
doc: ctx.doc,
|
|
28
|
-
indent: '',
|
|
29
|
-
indentStep: ctx.indentStep,
|
|
30
|
-
inFlow: true,
|
|
31
|
-
inStringifyKey: true
|
|
32
|
-
});
|
|
33
|
-
return JSON.stringify(jsKey);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export var Pair = /*#__PURE__*/function (_Node) {
|
|
37
|
-
_inherits(Pair, _Node);
|
|
38
|
-
|
|
39
|
-
var _super = _createSuper(Pair);
|
|
40
|
-
|
|
41
|
-
function Pair(key) {
|
|
42
|
-
var _this;
|
|
43
|
-
|
|
44
|
-
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
45
|
-
|
|
46
|
-
_classCallCheck(this, Pair);
|
|
47
|
-
|
|
48
|
-
_this = _super.call(this);
|
|
49
|
-
_this.key = key;
|
|
50
|
-
_this.value = value;
|
|
51
|
-
_this.type = Pair.Type.PAIR;
|
|
52
|
-
return _this;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_createClass(Pair, [{
|
|
56
|
-
key: "addToJSMap",
|
|
57
|
-
value: function addToJSMap(ctx, map) {
|
|
58
|
-
var key = toJSON(this.key, '', ctx);
|
|
59
|
-
|
|
60
|
-
if (map instanceof Map) {
|
|
61
|
-
var value = toJSON(this.value, key, ctx);
|
|
62
|
-
map.set(key, value);
|
|
63
|
-
} else if (map instanceof Set) {
|
|
64
|
-
map.add(key);
|
|
65
|
-
} else {
|
|
66
|
-
var stringKey = stringifyKey(this.key, key, ctx);
|
|
67
|
-
map[stringKey] = toJSON(this.value, stringKey, ctx);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return map;
|
|
71
|
-
}
|
|
72
|
-
}, {
|
|
73
|
-
key: "toJSON",
|
|
74
|
-
value: function toJSON(_, ctx) {
|
|
75
|
-
var pair = ctx && ctx.mapAsMap ? new Map() : {};
|
|
76
|
-
return this.addToJSMap(ctx, pair);
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
key: "toString",
|
|
80
|
-
value: function toString(ctx, onComment, onChompKeep) {
|
|
81
|
-
if (!ctx || !ctx.doc) return JSON.stringify(this);
|
|
82
|
-
var _ctx$doc$options = ctx.doc.options,
|
|
83
|
-
indentSize = _ctx$doc$options.indent,
|
|
84
|
-
indentSeq = _ctx$doc$options.indentSeq,
|
|
85
|
-
simpleKeys = _ctx$doc$options.simpleKeys;
|
|
86
|
-
var key = this.key,
|
|
87
|
-
value = this.value;
|
|
88
|
-
var keyComment = key instanceof Node && key.comment;
|
|
89
|
-
|
|
90
|
-
if (simpleKeys) {
|
|
91
|
-
if (keyComment) {
|
|
92
|
-
throw new Error('With simple keys, key nodes cannot have comments');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (key instanceof Collection) {
|
|
96
|
-
var msg = 'With simple keys, collection cannot be used as a key value';
|
|
97
|
-
throw new Error(msg);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
var explicitKey = !simpleKeys && (!key || keyComment || key instanceof Collection || key.type === Type.BLOCK_FOLDED || key.type === Type.BLOCK_LITERAL);
|
|
102
|
-
var _ctx = ctx,
|
|
103
|
-
doc = _ctx.doc,
|
|
104
|
-
indent = _ctx.indent,
|
|
105
|
-
indentStep = _ctx.indentStep;
|
|
106
|
-
ctx = Object.assign({}, ctx, {
|
|
107
|
-
implicitKey: !explicitKey,
|
|
108
|
-
indent: indent + indentStep
|
|
109
|
-
});
|
|
110
|
-
var chompKeep = false;
|
|
111
|
-
var str = doc.schema.stringify(key, ctx, function () {
|
|
112
|
-
return keyComment = null;
|
|
113
|
-
}, function () {
|
|
114
|
-
return chompKeep = true;
|
|
115
|
-
});
|
|
116
|
-
str = addComment(str, ctx.indent, keyComment);
|
|
117
|
-
|
|
118
|
-
if (ctx.allNullValues && !simpleKeys) {
|
|
119
|
-
if (this.comment) {
|
|
120
|
-
str = addComment(str, ctx.indent, this.comment);
|
|
121
|
-
if (onComment) onComment();
|
|
122
|
-
} else if (chompKeep && !keyComment && onChompKeep) onChompKeep();
|
|
123
|
-
|
|
124
|
-
return ctx.inFlow ? str : "? ".concat(str);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
str = explicitKey ? "? ".concat(str, "\n").concat(indent, ":") : "".concat(str, ":");
|
|
128
|
-
|
|
129
|
-
if (this.comment) {
|
|
130
|
-
// expected (but not strictly required) to be a single-line comment
|
|
131
|
-
str = addComment(str, ctx.indent, this.comment);
|
|
132
|
-
if (onComment) onComment();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
var vcb = '';
|
|
136
|
-
var valueComment = null;
|
|
137
|
-
|
|
138
|
-
if (value instanceof Node) {
|
|
139
|
-
if (value.spaceBefore) vcb = '\n';
|
|
140
|
-
|
|
141
|
-
if (value.commentBefore) {
|
|
142
|
-
var cs = value.commentBefore.replace(/^/gm, "".concat(ctx.indent, "#"));
|
|
143
|
-
vcb += "\n".concat(cs);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
valueComment = value.comment;
|
|
147
|
-
} else if (value && _typeof(value) === 'object') {
|
|
148
|
-
value = doc.schema.createNode(value, true);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
ctx.implicitKey = false;
|
|
152
|
-
if (!explicitKey && !this.comment && value instanceof Scalar) ctx.indentAtStart = str.length + 1;
|
|
153
|
-
chompKeep = false;
|
|
154
|
-
|
|
155
|
-
if (!indentSeq && indentSize >= 2 && !ctx.inFlow && !explicitKey && value instanceof YAMLSeq && value.type !== Type.FLOW_SEQ && !value.tag && !doc.anchors.getName(value)) {
|
|
156
|
-
// If indentSeq === false, consider '- ' as part of indentation where possible
|
|
157
|
-
ctx.indent = ctx.indent.substr(2);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
var valueStr = doc.schema.stringify(value, ctx, function () {
|
|
161
|
-
return valueComment = null;
|
|
162
|
-
}, function () {
|
|
163
|
-
return chompKeep = true;
|
|
164
|
-
});
|
|
165
|
-
var ws = ' ';
|
|
166
|
-
|
|
167
|
-
if (vcb || this.comment) {
|
|
168
|
-
ws = "".concat(vcb, "\n").concat(ctx.indent);
|
|
169
|
-
} else if (!explicitKey && value instanceof Collection) {
|
|
170
|
-
var flow = valueStr[0] === '[' || valueStr[0] === '{';
|
|
171
|
-
if (!flow || valueStr.includes('\n')) ws = "\n".concat(ctx.indent);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (chompKeep && !valueComment && onChompKeep) onChompKeep();
|
|
175
|
-
return addComment(str + ws + valueStr, ctx.indent, valueComment);
|
|
176
|
-
}
|
|
177
|
-
}, {
|
|
178
|
-
key: "commentBefore",
|
|
179
|
-
get: function get() {
|
|
180
|
-
return this.key && this.key.commentBefore;
|
|
181
|
-
},
|
|
182
|
-
set: function set(cb) {
|
|
183
|
-
if (this.key == null) this.key = new Scalar(null);
|
|
184
|
-
this.key.commentBefore = cb;
|
|
185
|
-
}
|
|
186
|
-
}]);
|
|
187
|
-
|
|
188
|
-
return Pair;
|
|
189
|
-
}(Node);
|
|
190
|
-
|
|
191
|
-
_defineProperty(Pair, "Type", {
|
|
192
|
-
PAIR: 'PAIR',
|
|
193
|
-
MERGE_PAIR: 'MERGE_PAIR'
|
|
194
|
-
});
|
|
@@ -1,42 +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
|
-
|
|
7
|
-
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); }; }
|
|
8
|
-
|
|
9
|
-
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; } }
|
|
10
|
-
|
|
11
|
-
// Published as 'yaml/scalar'
|
|
12
|
-
import { toJSON as _toJSON } from '../toJSON';
|
|
13
|
-
import { Node } from './Node';
|
|
14
|
-
export var Scalar = /*#__PURE__*/function (_Node) {
|
|
15
|
-
_inherits(Scalar, _Node);
|
|
16
|
-
|
|
17
|
-
var _super = _createSuper(Scalar);
|
|
18
|
-
|
|
19
|
-
function Scalar(value) {
|
|
20
|
-
var _this;
|
|
21
|
-
|
|
22
|
-
_classCallCheck(this, Scalar);
|
|
23
|
-
|
|
24
|
-
_this = _super.call(this);
|
|
25
|
-
_this.value = value;
|
|
26
|
-
return _this;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
_createClass(Scalar, [{
|
|
30
|
-
key: "toJSON",
|
|
31
|
-
value: function toJSON(arg, ctx) {
|
|
32
|
-
return ctx && ctx.keep ? this.value : _toJSON(this.value, arg, ctx);
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
key: "toString",
|
|
36
|
-
value: function toString() {
|
|
37
|
-
return String(this.value);
|
|
38
|
-
}
|
|
39
|
-
}]);
|
|
40
|
-
|
|
41
|
-
return Scalar;
|
|
42
|
-
}(Node);
|
|
@@ -1,116 +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 _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; } } }; }
|
|
9
|
-
|
|
10
|
-
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); }
|
|
11
|
-
|
|
12
|
-
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; }
|
|
13
|
-
|
|
14
|
-
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); }; }
|
|
15
|
-
|
|
16
|
-
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; } }
|
|
17
|
-
|
|
18
|
-
// Published as 'yaml/seq'
|
|
19
|
-
import { toJSON as _toJSON } from '../toJSON';
|
|
20
|
-
import { Collection } from './Collection';
|
|
21
|
-
import { Scalar } from './Scalar';
|
|
22
|
-
|
|
23
|
-
function asItemIndex(key) {
|
|
24
|
-
var idx = key instanceof Scalar ? key.value : key;
|
|
25
|
-
if (idx && typeof idx === 'string') idx = Number(idx);
|
|
26
|
-
return Number.isInteger(idx) && idx >= 0 ? idx : null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export var YAMLSeq = /*#__PURE__*/function (_Collection) {
|
|
30
|
-
_inherits(YAMLSeq, _Collection);
|
|
31
|
-
|
|
32
|
-
var _super = _createSuper(YAMLSeq);
|
|
33
|
-
|
|
34
|
-
function YAMLSeq() {
|
|
35
|
-
_classCallCheck(this, YAMLSeq);
|
|
36
|
-
|
|
37
|
-
return _super.apply(this, arguments);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
_createClass(YAMLSeq, [{
|
|
41
|
-
key: "add",
|
|
42
|
-
value: function add(value) {
|
|
43
|
-
this.items.push(value);
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: "delete",
|
|
47
|
-
value: function _delete(key) {
|
|
48
|
-
var idx = asItemIndex(key);
|
|
49
|
-
if (typeof idx !== 'number') return false;
|
|
50
|
-
var del = this.items.splice(idx, 1);
|
|
51
|
-
return del.length > 0;
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "get",
|
|
55
|
-
value: function get(key, keepScalar) {
|
|
56
|
-
var idx = asItemIndex(key);
|
|
57
|
-
if (typeof idx !== 'number') return undefined;
|
|
58
|
-
var it = this.items[idx];
|
|
59
|
-
return !keepScalar && it instanceof Scalar ? it.value : it;
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "has",
|
|
63
|
-
value: function has(key) {
|
|
64
|
-
var idx = asItemIndex(key);
|
|
65
|
-
return typeof idx === 'number' && idx < this.items.length;
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "set",
|
|
69
|
-
value: function set(key, value) {
|
|
70
|
-
var idx = asItemIndex(key);
|
|
71
|
-
if (typeof idx !== 'number') throw new Error("Expected a valid index, not ".concat(key, "."));
|
|
72
|
-
this.items[idx] = value;
|
|
73
|
-
}
|
|
74
|
-
}, {
|
|
75
|
-
key: "toJSON",
|
|
76
|
-
value: function toJSON(_, ctx) {
|
|
77
|
-
var seq = [];
|
|
78
|
-
if (ctx && ctx.onCreate) ctx.onCreate(seq);
|
|
79
|
-
var i = 0;
|
|
80
|
-
|
|
81
|
-
var _iterator = _createForOfIteratorHelper(this.items),
|
|
82
|
-
_step;
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
86
|
-
var item = _step.value;
|
|
87
|
-
seq.push(_toJSON(item, String(i++), ctx));
|
|
88
|
-
}
|
|
89
|
-
} catch (err) {
|
|
90
|
-
_iterator.e(err);
|
|
91
|
-
} finally {
|
|
92
|
-
_iterator.f();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return seq;
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "toString",
|
|
99
|
-
value: function toString(ctx, onComment, onChompKeep) {
|
|
100
|
-
if (!ctx) return JSON.stringify(this);
|
|
101
|
-
return _get(_getPrototypeOf(YAMLSeq.prototype), "toString", this).call(this, ctx, {
|
|
102
|
-
blockItem: function blockItem(n) {
|
|
103
|
-
return n.type === 'comment' ? n.str : "- ".concat(n.str);
|
|
104
|
-
},
|
|
105
|
-
flowChars: {
|
|
106
|
-
start: '[',
|
|
107
|
-
end: ']'
|
|
108
|
-
},
|
|
109
|
-
isMap: false,
|
|
110
|
-
itemIndent: (ctx.indent || '') + ' '
|
|
111
|
-
}, onComment, onChompKeep);
|
|
112
|
-
}
|
|
113
|
-
}]);
|
|
114
|
-
|
|
115
|
-
return YAMLSeq;
|
|
116
|
-
}(Collection);
|