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.
Files changed (163) hide show
  1. package/README.md +4 -4
  2. package/browser/dist/PlainValue-ff5147c6.js +1277 -0
  3. package/browser/dist/Schema-2bf2c74e.js +679 -0
  4. package/browser/dist/index.js +923 -38
  5. package/browser/dist/legacy-exports.js +3 -0
  6. package/browser/dist/parse-cst.js +1904 -0
  7. package/browser/dist/resolveSeq-04825f30.js +2373 -0
  8. package/browser/dist/types.js +4 -0
  9. package/browser/dist/util.js +2 -0
  10. package/browser/dist/warnings-0e4b70d3.js +499 -0
  11. package/browser/index.js +1 -1
  12. package/browser/map.js +2 -2
  13. package/browser/pair.js +2 -2
  14. package/browser/parse-cst.js +1 -1
  15. package/browser/scalar.js +2 -2
  16. package/browser/schema.js +8 -6
  17. package/browser/seq.js +2 -2
  18. package/browser/types/binary.js +3 -2
  19. package/browser/types/omap.js +3 -2
  20. package/browser/types/pairs.js +3 -2
  21. package/browser/types/set.js +3 -2
  22. package/browser/types/timestamp.js +6 -6
  23. package/browser/types.js +1 -11
  24. package/browser/util.js +1 -15
  25. package/dist/Document-2cf6b08c.js +757 -0
  26. package/dist/PlainValue-ec8e588e.js +876 -0
  27. package/dist/Schema-42e9705c.js +522 -0
  28. package/dist/index.js +21 -43
  29. package/dist/legacy-exports.js +16 -0
  30. package/dist/parse-cst.js +1747 -0
  31. package/dist/resolveSeq-4a68b39b.js +2115 -0
  32. package/dist/test-events.js +11 -14
  33. package/dist/types.js +23 -0
  34. package/dist/util.js +19 -0
  35. package/dist/warnings-39684f17.js +416 -0
  36. package/index.d.ts +372 -0
  37. package/index.js +1 -1
  38. package/map.js +2 -2
  39. package/package.json +32 -45
  40. package/pair.js +2 -2
  41. package/parse-cst.d.ts +187 -0
  42. package/parse-cst.js +1 -1
  43. package/scalar.js +2 -2
  44. package/schema.js +8 -6
  45. package/seq.js +2 -2
  46. package/types/binary.js +3 -2
  47. package/types/omap.js +3 -2
  48. package/types/pairs.js +3 -2
  49. package/types/set.js +3 -2
  50. package/types/timestamp.js +6 -6
  51. package/types.d.ts +407 -0
  52. package/types.js +16 -10
  53. package/types.mjs +15 -18
  54. package/util.d.ts +86 -0
  55. package/util.js +14 -13
  56. package/util.mjs +13 -19
  57. package/browser/dist/Anchors.js +0 -133
  58. package/browser/dist/Document.js +0 -819
  59. package/browser/dist/addComment.js +0 -8
  60. package/browser/dist/constants.js +0 -26
  61. package/browser/dist/cst/Alias.js +0 -42
  62. package/browser/dist/cst/BlankLine.js +0 -56
  63. package/browser/dist/cst/BlockValue.js +0 -247
  64. package/browser/dist/cst/Collection.js +0 -274
  65. package/browser/dist/cst/CollectionItem.js +0 -136
  66. package/browser/dist/cst/Comment.js +0 -40
  67. package/browser/dist/cst/Directive.js +0 -72
  68. package/browser/dist/cst/Document.js +0 -282
  69. package/browser/dist/cst/FlowCollection.js +0 -216
  70. package/browser/dist/cst/Node.js +0 -388
  71. package/browser/dist/cst/ParseContext.js +0 -248
  72. package/browser/dist/cst/PlainValue.js +0 -166
  73. package/browser/dist/cst/QuoteDouble.js +0 -241
  74. package/browser/dist/cst/QuoteSingle.js +0 -116
  75. package/browser/dist/cst/Range.js +0 -67
  76. package/browser/dist/cst/parse.js +0 -48
  77. package/browser/dist/cst/source-utils.js +0 -168
  78. package/browser/dist/errors.js +0 -112
  79. package/browser/dist/foldFlowLines.js +0 -138
  80. package/browser/dist/listTagNames.js +0 -28
  81. package/browser/dist/schema/Alias.js +0 -139
  82. package/browser/dist/schema/Collection.js +0 -267
  83. package/browser/dist/schema/Map.js +0 -178
  84. package/browser/dist/schema/Merge.js +0 -127
  85. package/browser/dist/schema/Node.js +0 -7
  86. package/browser/dist/schema/Pair.js +0 -171
  87. package/browser/dist/schema/Scalar.js +0 -38
  88. package/browser/dist/schema/Seq.js +0 -114
  89. package/browser/dist/schema/index.js +0 -382
  90. package/browser/dist/schema/parseMap.js +0 -312
  91. package/browser/dist/schema/parseSeq.js +0 -168
  92. package/browser/dist/schema/parseUtils.js +0 -110
  93. package/browser/dist/stringify.js +0 -331
  94. package/browser/dist/tags/core.js +0 -126
  95. package/browser/dist/tags/failsafe/index.js +0 -4
  96. package/browser/dist/tags/failsafe/map.js +0 -56
  97. package/browser/dist/tags/failsafe/seq.js +0 -43
  98. package/browser/dist/tags/failsafe/string.js +0 -28
  99. package/browser/dist/tags/index.js +0 -36
  100. package/browser/dist/tags/json.js +0 -76
  101. package/browser/dist/tags/options.js +0 -23
  102. package/browser/dist/tags/yaml-1.1/binary.js +0 -87
  103. package/browser/dist/tags/yaml-1.1/index.js +0 -157
  104. package/browser/dist/tags/yaml-1.1/omap.js +0 -142
  105. package/browser/dist/tags/yaml-1.1/pairs.js +0 -81
  106. package/browser/dist/tags/yaml-1.1/set.js +0 -114
  107. package/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
  108. package/browser/dist/test-events.js +0 -163
  109. package/browser/dist/toJSON.js +0 -20
  110. package/browser/dist/warnings.js +0 -28
  111. package/dist/Anchors.js +0 -125
  112. package/dist/Document.js +0 -710
  113. package/dist/addComment.js +0 -17
  114. package/dist/constants.js +0 -34
  115. package/dist/cst/Alias.js +0 -38
  116. package/dist/cst/BlankLine.js +0 -56
  117. package/dist/cst/BlockValue.js +0 -248
  118. package/dist/cst/Collection.js +0 -271
  119. package/dist/cst/CollectionItem.js +0 -140
  120. package/dist/cst/Comment.js +0 -38
  121. package/dist/cst/Directive.js +0 -64
  122. package/dist/cst/Document.js +0 -281
  123. package/dist/cst/FlowCollection.js +0 -218
  124. package/dist/cst/Node.js +0 -365
  125. package/dist/cst/ParseContext.js +0 -258
  126. package/dist/cst/PlainValue.js +0 -161
  127. package/dist/cst/QuoteDouble.js +0 -237
  128. package/dist/cst/QuoteSingle.js +0 -113
  129. package/dist/cst/Range.js +0 -63
  130. package/dist/cst/parse.js +0 -55
  131. package/dist/cst/source-utils.js +0 -178
  132. package/dist/errors.js +0 -102
  133. package/dist/foldFlowLines.js +0 -146
  134. package/dist/listTagNames.js +0 -38
  135. package/dist/schema/Alias.js +0 -110
  136. package/dist/schema/Collection.js +0 -188
  137. package/dist/schema/Map.js +0 -103
  138. package/dist/schema/Merge.js +0 -80
  139. package/dist/schema/Node.js +0 -10
  140. package/dist/schema/Pair.js +0 -161
  141. package/dist/schema/Scalar.js +0 -31
  142. package/dist/schema/Seq.js +0 -78
  143. package/dist/schema/index.js +0 -315
  144. package/dist/schema/parseMap.js +0 -343
  145. package/dist/schema/parseSeq.js +0 -180
  146. package/dist/schema/parseUtils.js +0 -104
  147. package/dist/stringify.js +0 -358
  148. package/dist/tags/core.js +0 -114
  149. package/dist/tags/failsafe/index.js +0 -17
  150. package/dist/tags/failsafe/map.js +0 -37
  151. package/dist/tags/failsafe/seq.js +0 -34
  152. package/dist/tags/failsafe/string.js +0 -40
  153. package/dist/tags/index.js +0 -62
  154. package/dist/tags/json.js +0 -60
  155. package/dist/tags/options.js +0 -35
  156. package/dist/tags/yaml-1.1/binary.js +0 -97
  157. package/dist/tags/yaml-1.1/index.js +0 -131
  158. package/dist/tags/yaml-1.1/omap.js +0 -105
  159. package/dist/tags/yaml-1.1/pairs.js +0 -80
  160. package/dist/tags/yaml-1.1/set.js +0 -91
  161. package/dist/tags/yaml-1.1/timestamp.js +0 -93
  162. package/dist/toJSON.js +0 -23
  163. package/dist/warnings.js +0 -39
package/dist/stringify.js DELETED
@@ -1,358 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.stringifyNumber = stringifyNumber;
7
- exports.stringifyString = stringifyString;
8
-
9
- var _addComment = require("./addComment");
10
-
11
- var _constants = require("./constants");
12
-
13
- var _foldFlowLines = _interopRequireWildcard(require("./foldFlowLines"));
14
-
15
- var _options = require("./tags/options");
16
-
17
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
18
-
19
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
-
21
- const getFoldOptions = ({
22
- indentAtStart
23
- }) => indentAtStart ? Object.assign({
24
- indentAtStart
25
- }, _options.strOptions.fold) : _options.strOptions.fold;
26
-
27
- function stringifyNumber({
28
- format,
29
- minFractionDigits,
30
- tag,
31
- value
32
- }) {
33
- if (!isFinite(value)) return isNaN(value) ? '.nan' : value < 0 ? '-.inf' : '.inf';
34
- let n = JSON.stringify(value);
35
-
36
- if (!format && minFractionDigits && (!tag || tag === 'tag:yaml.org,2002:float') && /^\d/.test(n)) {
37
- let i = n.indexOf('.');
38
-
39
- if (i < 0) {
40
- i = n.length;
41
- n += '.';
42
- }
43
-
44
- let d = minFractionDigits - (n.length - i - 1);
45
-
46
- while (d-- > 0) n += '0';
47
- }
48
-
49
- return n;
50
- }
51
-
52
- function lineLengthOverLimit(str, limit) {
53
- const strLen = str.length;
54
- if (strLen <= limit) return false;
55
-
56
- for (let i = 0, start = 0; i < strLen; ++i) {
57
- if (str[i] === '\n') {
58
- if (i - start > limit) return true;
59
- start = i + 1;
60
- if (strLen - start <= limit) return false;
61
- }
62
- }
63
-
64
- return true;
65
- }
66
-
67
- function doubleQuotedString(value, ctx) {
68
- const {
69
- implicitKey,
70
- indent
71
- } = ctx;
72
- const {
73
- jsonEncoding,
74
- minMultiLineLength
75
- } = _options.strOptions.doubleQuoted;
76
- const json = JSON.stringify(value);
77
- if (jsonEncoding) return json;
78
- let str = '';
79
- let start = 0;
80
-
81
- for (let i = 0, ch = json[i]; ch; ch = json[++i]) {
82
- if (ch === ' ' && json[i + 1] === '\\' && json[i + 2] === 'n') {
83
- // space before newline needs to be escaped to not be folded
84
- str += json.slice(start, i) + '\\ ';
85
- i += 1;
86
- start = i;
87
- ch = '\\';
88
- }
89
-
90
- if (ch === '\\') switch (json[i + 1]) {
91
- case 'u':
92
- {
93
- str += json.slice(start, i);
94
- const code = json.substr(i + 2, 4);
95
-
96
- switch (code) {
97
- case '0000':
98
- str += '\\0';
99
- break;
100
-
101
- case '0007':
102
- str += '\\a';
103
- break;
104
-
105
- case '000b':
106
- str += '\\v';
107
- break;
108
-
109
- case '001b':
110
- str += '\\e';
111
- break;
112
-
113
- case '0085':
114
- str += '\\N';
115
- break;
116
-
117
- case '00a0':
118
- str += '\\_';
119
- break;
120
-
121
- case '2028':
122
- str += '\\L';
123
- break;
124
-
125
- case '2029':
126
- str += '\\P';
127
- break;
128
-
129
- default:
130
- if (code.substr(0, 2) === '00') str += '\\x' + code.substr(2);else str += json.substr(i, 6);
131
- }
132
-
133
- i += 5;
134
- start = i + 1;
135
- }
136
- break;
137
-
138
- case 'n':
139
- if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) {
140
- i += 1;
141
- } else {
142
- // folding will eat first newline
143
- str += json.slice(start, i) + '\n\n';
144
-
145
- while (json[i + 2] === '\\' && json[i + 3] === 'n' && json[i + 4] !== '"') {
146
- str += '\n';
147
- i += 2;
148
- }
149
-
150
- str += indent; // space after newline needs to be escaped to not be folded
151
-
152
- if (json[i + 2] === ' ') str += '\\';
153
- i += 1;
154
- start = i + 1;
155
- }
156
-
157
- break;
158
-
159
- default:
160
- i += 1;
161
- }
162
- }
163
-
164
- str = start ? str + json.slice(start) : json;
165
- return implicitKey ? str : (0, _foldFlowLines.default)(str, indent, _foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx));
166
- }
167
-
168
- function singleQuotedString(value, ctx) {
169
- const {
170
- indent,
171
- implicitKey
172
- } = ctx;
173
-
174
- if (implicitKey) {
175
- if (/\n/.test(value)) return doubleQuotedString(value, ctx);
176
- } else {
177
- // single quoted string can't have leading or trailing whitespace around newline
178
- if (/[ \t]\n|\n[ \t]/.test(value)) return doubleQuotedString(value, ctx);
179
- }
180
-
181
- const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
182
- return implicitKey ? res : (0, _foldFlowLines.default)(res, indent, _foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
183
- }
184
-
185
- function blockString({
186
- comment,
187
- type,
188
- value
189
- }, ctx, onComment, onChompKeep) {
190
- // 1. Block can't end in whitespace unless the last line is non-empty.
191
- // 2. Strings consisting of only whitespace are best rendered explicitly.
192
- if (/\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
193
- return doubleQuotedString(value, ctx);
194
- }
195
-
196
- const indent = ctx.indent || (ctx.forceBlockIndent ? ' ' : '');
197
- const indentSize = indent ? '2' : '1'; // root is at -1
198
-
199
- const literal = type === _constants.Type.BLOCK_FOLDED ? false : type === _constants.Type.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, _options.strOptions.fold.lineWidth - indent.length);
200
- let header = literal ? '|' : '>';
201
- if (!value) return header + '\n';
202
- let wsStart = '';
203
- let wsEnd = '';
204
- value = value.replace(/[\n\t ]*$/, ws => {
205
- const n = ws.indexOf('\n');
206
-
207
- if (n === -1) {
208
- header += '-'; // strip
209
- } else if (value === ws || n !== ws.length - 1) {
210
- header += '+'; // keep
211
-
212
- if (onChompKeep) onChompKeep();
213
- }
214
-
215
- wsEnd = ws.replace(/\n$/, '');
216
- return '';
217
- }).replace(/^[\n ]*/, ws => {
218
- if (ws.indexOf(' ') !== -1) header += indentSize;
219
- const m = ws.match(/ +$/);
220
-
221
- if (m) {
222
- wsStart = ws.slice(0, -m[0].length);
223
- return m[0];
224
- } else {
225
- wsStart = ws;
226
- return '';
227
- }
228
- });
229
- if (wsEnd) wsEnd = wsEnd.replace(/\n+(?!\n|$)/g, `$&${indent}`);
230
- if (wsStart) wsStart = wsStart.replace(/\n+/g, `$&${indent}`);
231
-
232
- if (comment) {
233
- header += ' #' + comment.replace(/ ?[\r\n]+/g, ' ');
234
- if (onComment) onComment();
235
- }
236
-
237
- if (!value) return `${header}${indentSize}\n${indent}${wsEnd}`;
238
-
239
- if (literal) {
240
- value = value.replace(/\n+/g, `$&${indent}`);
241
- return `${header}\n${indent}${wsStart}${value}${wsEnd}`;
242
- }
243
-
244
- value = value.replace(/\n+/g, '\n$&').replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
245
- // ^ ind.line ^ empty ^ capture next empty lines only at end of indent
246
- .replace(/\n+/g, `$&${indent}`);
247
- const body = (0, _foldFlowLines.default)(`${wsStart}${value}${wsEnd}`, indent, _foldFlowLines.FOLD_BLOCK, _options.strOptions.fold);
248
- return `${header}\n${indent}${body}`;
249
- }
250
-
251
- function plainString(item, ctx, onComment, onChompKeep) {
252
- const {
253
- comment,
254
- type,
255
- value
256
- } = item;
257
- const {
258
- actualString,
259
- implicitKey,
260
- indent,
261
- inFlow,
262
- tags
263
- } = ctx;
264
-
265
- if (implicitKey && /[\n[\]{},]/.test(value) || inFlow && /[[\]{},]/.test(value)) {
266
- return doubleQuotedString(value, ctx);
267
- }
268
-
269
- if (!value || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
270
- // not allowed:
271
- // - empty string, '-' or '?'
272
- // - start with an indicator character (except [?:-]) or /[?-] /
273
- // - '\n ', ': ' or ' \n' anywhere
274
- // - '#' not preceded by a non-space char
275
- // - end with ' ' or ':'
276
- return implicitKey || inFlow || value.indexOf('\n') === -1 ? value.indexOf('"') !== -1 && value.indexOf("'") === -1 ? singleQuotedString(value, ctx) : doubleQuotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep);
277
- }
278
-
279
- if (!implicitKey && !inFlow && type !== _constants.Type.PLAIN && value.indexOf('\n') !== -1) {
280
- // Where allowed & type not set explicitly, prefer block style for multiline strings
281
- return blockString(item, ctx, onComment, onChompKeep);
282
- }
283
-
284
- const str = value.replace(/\n+/g, `$&\n${indent}`); // Verify that output will be parsed as a string, as e.g. plain numbers and
285
- // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
286
- // and others in v1.1.
287
-
288
- if (actualString && typeof tags.resolveScalar(str).value !== 'string') {
289
- return doubleQuotedString(value, ctx);
290
- }
291
-
292
- const body = implicitKey ? str : (0, _foldFlowLines.default)(str, indent, _foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
293
-
294
- if (comment && !inFlow && (body.indexOf('\n') !== -1 || comment.indexOf('\n') !== -1)) {
295
- if (onComment) onComment();
296
- return (0, _addComment.addCommentBefore)(body, indent, comment);
297
- }
298
-
299
- return body;
300
- }
301
-
302
- function stringifyString(item, ctx, onComment, onChompKeep) {
303
- const {
304
- defaultType
305
- } = _options.strOptions;
306
- const {
307
- implicitKey,
308
- inFlow
309
- } = ctx;
310
- let {
311
- type,
312
- value
313
- } = item;
314
-
315
- if (typeof value !== 'string') {
316
- value = String(value);
317
- item = Object.assign({}, item, {
318
- value
319
- });
320
- }
321
-
322
- const _stringify = _type => {
323
- switch (_type) {
324
- case _constants.Type.BLOCK_FOLDED:
325
- case _constants.Type.BLOCK_LITERAL:
326
- return blockString(item, ctx, onComment, onChompKeep);
327
-
328
- case _constants.Type.QUOTE_DOUBLE:
329
- return doubleQuotedString(value, ctx);
330
-
331
- case _constants.Type.QUOTE_SINGLE:
332
- return singleQuotedString(value, ctx);
333
-
334
- case _constants.Type.PLAIN:
335
- return plainString(item, ctx, onComment, onChompKeep);
336
-
337
- default:
338
- return null;
339
- }
340
- };
341
-
342
- if (type !== _constants.Type.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(value)) {
343
- // force double quotes on control characters
344
- type = _constants.Type.QUOTE_DOUBLE;
345
- } else if ((implicitKey || inFlow) && (type === _constants.Type.BLOCK_FOLDED || type === _constants.Type.BLOCK_LITERAL)) {
346
- // should not happen; blocks are not valid inside flow containers
347
- type = _constants.Type.QUOTE_DOUBLE;
348
- }
349
-
350
- let res = _stringify(type);
351
-
352
- if (res === null) {
353
- res = _stringify(defaultType);
354
- if (res === null) throw new Error(`Unsupported default string type ${defaultType}`);
355
- }
356
-
357
- return res;
358
- }
package/dist/tags/core.js DELETED
@@ -1,114 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.floatObj = exports.expObj = exports.nanObj = exports.hexObj = exports.intObj = exports.octObj = exports.boolObj = exports.nullObj = void 0;
7
-
8
- var _Scalar = _interopRequireDefault(require("../schema/Scalar"));
9
-
10
- var _stringify = require("../stringify");
11
-
12
- var _failsafe = _interopRequireDefault(require("./failsafe"));
13
-
14
- var _options = require("./options");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const nullObj = {
19
- identify: value => value == null,
20
- createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
21
- default: true,
22
- tag: 'tag:yaml.org,2002:null',
23
- test: /^(?:~|[Nn]ull|NULL)?$/,
24
- resolve: () => null,
25
- options: _options.nullOptions,
26
- stringify: () => _options.nullOptions.nullStr
27
- };
28
- exports.nullObj = nullObj;
29
- const boolObj = {
30
- identify: value => typeof value === 'boolean',
31
- default: true,
32
- tag: 'tag:yaml.org,2002:bool',
33
- test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
34
- resolve: str => str[0] === 't' || str[0] === 'T',
35
- options: _options.boolOptions,
36
- stringify: ({
37
- value
38
- }) => value ? _options.boolOptions.trueStr : _options.boolOptions.falseStr
39
- };
40
- exports.boolObj = boolObj;
41
- const octObj = {
42
- identify: value => typeof value === 'number',
43
- default: true,
44
- tag: 'tag:yaml.org,2002:int',
45
- format: 'OCT',
46
- test: /^0o([0-7]+)$/,
47
- resolve: (str, oct) => parseInt(oct, 8),
48
- stringify: ({
49
- value
50
- }) => '0o' + value.toString(8)
51
- };
52
- exports.octObj = octObj;
53
- const intObj = {
54
- identify: value => typeof value === 'number',
55
- default: true,
56
- tag: 'tag:yaml.org,2002:int',
57
- test: /^[-+]?[0-9]+$/,
58
- resolve: str => parseInt(str, 10),
59
- stringify: _stringify.stringifyNumber
60
- };
61
- exports.intObj = intObj;
62
- const hexObj = {
63
- identify: value => typeof value === 'number',
64
- default: true,
65
- tag: 'tag:yaml.org,2002:int',
66
- format: 'HEX',
67
- test: /^0x([0-9a-fA-F]+)$/,
68
- resolve: (str, hex) => parseInt(hex, 16),
69
- stringify: ({
70
- value
71
- }) => '0x' + value.toString(16)
72
- };
73
- exports.hexObj = hexObj;
74
- const nanObj = {
75
- identify: value => typeof value === 'number',
76
- default: true,
77
- tag: 'tag:yaml.org,2002:float',
78
- test: /^(?:[-+]?\.inf|(\.nan))$/i,
79
- resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
80
- stringify: _stringify.stringifyNumber
81
- };
82
- exports.nanObj = nanObj;
83
- const expObj = {
84
- identify: value => typeof value === 'number',
85
- default: true,
86
- tag: 'tag:yaml.org,2002:float',
87
- format: 'EXP',
88
- test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
89
- resolve: str => parseFloat(str),
90
- stringify: ({
91
- value
92
- }) => Number(value).toExponential()
93
- };
94
- exports.expObj = expObj;
95
- const floatObj = {
96
- identify: value => typeof value === 'number',
97
- default: true,
98
- tag: 'tag:yaml.org,2002:float',
99
- test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
100
-
101
- resolve(str, frac1, frac2) {
102
- const frac = frac1 || frac2;
103
- const node = new _Scalar.default(parseFloat(str));
104
- if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
105
- return node;
106
- },
107
-
108
- stringify: _stringify.stringifyNumber
109
- };
110
- exports.floatObj = floatObj;
111
-
112
- var _default = _failsafe.default.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);
113
-
114
- exports.default = _default;
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _map = _interopRequireDefault(require("./map"));
9
-
10
- var _seq = _interopRequireDefault(require("./seq"));
11
-
12
- var _string = _interopRequireDefault(require("./string"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- var _default = [_map.default, _seq.default, _string.default];
17
- exports.default = _default;
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _Map = _interopRequireDefault(require("../../schema/Map"));
9
-
10
- var _parseMap = _interopRequireDefault(require("../../schema/parseMap"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function createMap(schema, obj, ctx) {
15
- const map = new _Map.default(schema);
16
-
17
- if (obj instanceof Map) {
18
- for (const [key, value] of obj) map.items.push(schema.createPair(key, value, ctx));
19
- } else if (obj && typeof obj === 'object') {
20
- for (const key of Object.keys(obj)) map.items.push(schema.createPair(key, obj[key], ctx));
21
- }
22
-
23
- if (typeof schema.sortMapEntries === 'function') {
24
- map.items.sort(schema.sortMapEntries);
25
- }
26
-
27
- return map;
28
- }
29
-
30
- var _default = {
31
- createNode: createMap,
32
- default: true,
33
- nodeClass: _Map.default,
34
- tag: 'tag:yaml.org,2002:map',
35
- resolve: _parseMap.default
36
- };
37
- exports.default = _default;
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _parseSeq = _interopRequireDefault(require("../../schema/parseSeq"));
9
-
10
- var _Seq = _interopRequireDefault(require("../../schema/Seq"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function createSeq(schema, obj, ctx) {
15
- const seq = new _Seq.default(schema);
16
-
17
- if (obj && obj[Symbol.iterator]) {
18
- for (const it of obj) {
19
- const v = schema.createNode(it, ctx.wrapScalars, null, ctx);
20
- seq.items.push(v);
21
- }
22
- }
23
-
24
- return seq;
25
- }
26
-
27
- var _default = {
28
- createNode: createSeq,
29
- default: true,
30
- nodeClass: _Seq.default,
31
- tag: 'tag:yaml.org,2002:seq',
32
- resolve: _parseSeq.default
33
- };
34
- exports.default = _default;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.resolveString = void 0;
7
-
8
- var _stringify = require("../../stringify");
9
-
10
- var _options = require("../options");
11
-
12
- const resolveString = (doc, node) => {
13
- // on error, will return { str: string, errors: Error[] }
14
- const res = node.strValue;
15
- if (!res) return '';
16
- if (typeof res === 'string') return res;
17
- res.errors.forEach(error => {
18
- if (!error.source) error.source = node;
19
- doc.errors.push(error);
20
- });
21
- return res.str;
22
- };
23
-
24
- exports.resolveString = resolveString;
25
- var _default = {
26
- identify: value => typeof value === 'string',
27
- default: true,
28
- tag: 'tag:yaml.org,2002:str',
29
- resolve: resolveString,
30
-
31
- stringify(item, ctx, onComment, onChompKeep) {
32
- ctx = Object.assign({
33
- actualString: true
34
- }, ctx);
35
- return (0, _stringify.stringifyString)(item, ctx, onComment, onChompKeep);
36
- },
37
-
38
- options: _options.strOptions
39
- };
40
- exports.default = _default;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.tags = exports.schemas = void 0;
7
-
8
- var _core = _interopRequireWildcard(require("./core"));
9
-
10
- var _failsafe = _interopRequireDefault(require("./failsafe"));
11
-
12
- var _json = _interopRequireDefault(require("./json"));
13
-
14
- var _yaml = _interopRequireDefault(require("./yaml-1.1"));
15
-
16
- var _map = _interopRequireDefault(require("./failsafe/map"));
17
-
18
- var _seq = _interopRequireDefault(require("./failsafe/seq"));
19
-
20
- var _binary = _interopRequireDefault(require("./yaml-1.1/binary"));
21
-
22
- var _omap = _interopRequireDefault(require("./yaml-1.1/omap"));
23
-
24
- var _pairs = _interopRequireDefault(require("./yaml-1.1/pairs"));
25
-
26
- var _set = _interopRequireDefault(require("./yaml-1.1/set"));
27
-
28
- var _timestamp = require("./yaml-1.1/timestamp");
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
33
-
34
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
-
36
- const schemas = {
37
- core: _core.default,
38
- failsafe: _failsafe.default,
39
- json: _json.default,
40
- yaml11: _yaml.default
41
- };
42
- exports.schemas = schemas;
43
- const tags = {
44
- binary: _binary.default,
45
- bool: _core.boolObj,
46
- float: _core.floatObj,
47
- floatExp: _core.expObj,
48
- floatNaN: _core.nanObj,
49
- floatTime: _timestamp.floatTime,
50
- int: _core.intObj,
51
- intHex: _core.hexObj,
52
- intOct: _core.octObj,
53
- intTime: _timestamp.intTime,
54
- map: _map.default,
55
- null: _core.nullObj,
56
- omap: _omap.default,
57
- pairs: _pairs.default,
58
- seq: _seq.default,
59
- set: _set.default,
60
- timestamp: _timestamp.timestamp
61
- };
62
- exports.tags = tags;