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
@@ -0,0 +1,4 @@
1
+ import './PlainValue-ff5147c6.js';
2
+ export { A as Alias, C as Collection, M as Merge, N as Node, P as Pair, S as Scalar, d as YAMLMap, Y as YAMLSeq, b as binaryOptions, a as boolOptions, i as intOptions, n as nullOptions, s as strOptions } from './resolveSeq-04825f30.js';
3
+ export { S as Schema } from './Schema-2bf2c74e.js';
4
+ import './warnings-0e4b70d3.js';
@@ -0,0 +1,2 @@
1
+ export { T as Type, i as YAMLError, o as YAMLReferenceError, g as YAMLSemanticError, Y as YAMLSyntaxError, f as YAMLWarning } from './PlainValue-ff5147c6.js';
2
+ export { l as findPair, g as parseMap, h as parseSeq, k as stringifyNumber, c as stringifyString, t as toJSON } from './resolveSeq-04825f30.js';
@@ -0,0 +1,499 @@
1
+ import { o as YAMLReferenceError, T as Type, g as YAMLSemanticError, _ as _createForOfIteratorHelper, e as _defineProperty, j as _inherits, k as _createSuper, c as _classCallCheck, p as _assertThisInitialized, b as _createClass, a as _typeof, l as _get, m as _getPrototypeOf } from './PlainValue-ff5147c6.js';
2
+ import { j as resolveString, b as binaryOptions, c as stringifyString, h as resolveSeq, P as Pair, d as YAMLMap, Y as YAMLSeq, t as toJSON, S as Scalar, l as findPair, g as resolveMap, k as stringifyNumber } from './resolveSeq-04825f30.js';
3
+
4
+ /* global atob, btoa, Buffer */
5
+ var binary = {
6
+ identify: function identify(value) {
7
+ return value instanceof Uint8Array;
8
+ },
9
+ // Buffer inherits from Uint8Array
10
+ default: false,
11
+ tag: 'tag:yaml.org,2002:binary',
12
+
13
+ /**
14
+ * Returns a Buffer in node and an Uint8Array in browsers
15
+ *
16
+ * To use the resulting buffer as an image, you'll want to do something like:
17
+ *
18
+ * const blob = new Blob([buffer], { type: 'image/jpeg' })
19
+ * document.querySelector('#photo').src = URL.createObjectURL(blob)
20
+ */
21
+ resolve: function resolve(doc, node) {
22
+ var src = resolveString(doc, node);
23
+
24
+ if (typeof Buffer === 'function') {
25
+ return Buffer.from(src, 'base64');
26
+ } else if (typeof atob === 'function') {
27
+ // On IE 11, atob() can't handle newlines
28
+ var str = atob(src.replace(/[\n\r]/g, ''));
29
+ var buffer = new Uint8Array(str.length);
30
+
31
+ for (var i = 0; i < str.length; ++i) {
32
+ buffer[i] = str.charCodeAt(i);
33
+ }
34
+
35
+ return buffer;
36
+ } else {
37
+ var msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
38
+ doc.errors.push(new YAMLReferenceError(node, msg));
39
+ return null;
40
+ }
41
+ },
42
+ options: binaryOptions,
43
+ stringify: function stringify(_ref, ctx, onComment, onChompKeep) {
44
+ var comment = _ref.comment,
45
+ type = _ref.type,
46
+ value = _ref.value;
47
+ var src;
48
+
49
+ if (typeof Buffer === 'function') {
50
+ src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
51
+ } else if (typeof btoa === 'function') {
52
+ var s = '';
53
+
54
+ for (var i = 0; i < value.length; ++i) {
55
+ s += String.fromCharCode(value[i]);
56
+ }
57
+
58
+ src = btoa(s);
59
+ } else {
60
+ throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
61
+ }
62
+
63
+ if (!type) type = binaryOptions.defaultType;
64
+
65
+ if (type === Type.QUOTE_DOUBLE) {
66
+ value = src;
67
+ } else {
68
+ var lineWidth = binaryOptions.lineWidth;
69
+ var n = Math.ceil(src.length / lineWidth);
70
+ var lines = new Array(n);
71
+
72
+ for (var _i = 0, o = 0; _i < n; ++_i, o += lineWidth) {
73
+ lines[_i] = src.substr(o, lineWidth);
74
+ }
75
+
76
+ value = lines.join(type === Type.BLOCK_LITERAL ? '\n' : ' ');
77
+ }
78
+
79
+ return stringifyString({
80
+ comment: comment,
81
+ type: type,
82
+ value: value
83
+ }, ctx, onComment, onChompKeep);
84
+ }
85
+ };
86
+
87
+ function parsePairs(doc, cst) {
88
+ var seq = resolveSeq(doc, cst);
89
+
90
+ for (var i = 0; i < seq.items.length; ++i) {
91
+ var item = seq.items[i];
92
+ if (item instanceof Pair) continue;else if (item instanceof YAMLMap) {
93
+ if (item.items.length > 1) {
94
+ var msg = 'Each pair must have its own sequence indicator';
95
+ throw new YAMLSemanticError(cst, msg);
96
+ }
97
+
98
+ var pair = item.items[0] || new Pair();
99
+ if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore;
100
+ if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment;
101
+ item = pair;
102
+ }
103
+ seq.items[i] = item instanceof Pair ? item : new Pair(item);
104
+ }
105
+
106
+ return seq;
107
+ }
108
+ function createPairs(schema, iterable, ctx) {
109
+ var pairs = new YAMLSeq(schema);
110
+ pairs.tag = 'tag:yaml.org,2002:pairs';
111
+
112
+ var _iterator = _createForOfIteratorHelper(iterable),
113
+ _step;
114
+
115
+ try {
116
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
117
+ var it = _step.value;
118
+ var key = void 0,
119
+ value = void 0;
120
+
121
+ if (Array.isArray(it)) {
122
+ if (it.length === 2) {
123
+ key = it[0];
124
+ value = it[1];
125
+ } else throw new TypeError("Expected [key, value] tuple: ".concat(it));
126
+ } else if (it && it instanceof Object) {
127
+ var keys = Object.keys(it);
128
+
129
+ if (keys.length === 1) {
130
+ key = keys[0];
131
+ value = it[key];
132
+ } else throw new TypeError("Expected { key: value } tuple: ".concat(it));
133
+ } else {
134
+ key = it;
135
+ }
136
+
137
+ var pair = schema.createPair(key, value, ctx);
138
+ pairs.items.push(pair);
139
+ }
140
+ } catch (err) {
141
+ _iterator.e(err);
142
+ } finally {
143
+ _iterator.f();
144
+ }
145
+
146
+ return pairs;
147
+ }
148
+ var pairs = {
149
+ default: false,
150
+ tag: 'tag:yaml.org,2002:pairs',
151
+ resolve: parsePairs,
152
+ createNode: createPairs
153
+ };
154
+
155
+ var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
156
+ _inherits(YAMLOMap, _YAMLSeq);
157
+
158
+ var _super = _createSuper(YAMLOMap);
159
+
160
+ function YAMLOMap() {
161
+ var _this;
162
+
163
+ _classCallCheck(this, YAMLOMap);
164
+
165
+ _this = _super.call(this);
166
+
167
+ _defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this)));
168
+
169
+ _defineProperty(_assertThisInitialized(_this), "delete", YAMLMap.prototype.delete.bind(_assertThisInitialized(_this)));
170
+
171
+ _defineProperty(_assertThisInitialized(_this), "get", YAMLMap.prototype.get.bind(_assertThisInitialized(_this)));
172
+
173
+ _defineProperty(_assertThisInitialized(_this), "has", YAMLMap.prototype.has.bind(_assertThisInitialized(_this)));
174
+
175
+ _defineProperty(_assertThisInitialized(_this), "set", YAMLMap.prototype.set.bind(_assertThisInitialized(_this)));
176
+
177
+ _this.tag = YAMLOMap.tag;
178
+ return _this;
179
+ }
180
+
181
+ _createClass(YAMLOMap, [{
182
+ key: "toJSON",
183
+ value: function toJSON$1(_, ctx) {
184
+ var map = new Map();
185
+ if (ctx && ctx.onCreate) ctx.onCreate(map);
186
+
187
+ var _iterator = _createForOfIteratorHelper(this.items),
188
+ _step;
189
+
190
+ try {
191
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
192
+ var pair = _step.value;
193
+ var key = void 0,
194
+ value = void 0;
195
+
196
+ if (pair instanceof Pair) {
197
+ key = toJSON(pair.key, '', ctx);
198
+ value = toJSON(pair.value, key, ctx);
199
+ } else {
200
+ key = toJSON(pair, '', ctx);
201
+ }
202
+
203
+ if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
204
+ map.set(key, value);
205
+ }
206
+ } catch (err) {
207
+ _iterator.e(err);
208
+ } finally {
209
+ _iterator.f();
210
+ }
211
+
212
+ return map;
213
+ }
214
+ }]);
215
+
216
+ return YAMLOMap;
217
+ }(YAMLSeq);
218
+
219
+ _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
220
+
221
+ function parseOMap(doc, cst) {
222
+ var pairs = parsePairs(doc, cst);
223
+ var seenKeys = [];
224
+
225
+ var _iterator2 = _createForOfIteratorHelper(pairs.items),
226
+ _step2;
227
+
228
+ try {
229
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
230
+ var key = _step2.value.key;
231
+
232
+ if (key instanceof Scalar) {
233
+ if (seenKeys.includes(key.value)) {
234
+ var msg = 'Ordered maps must not include duplicate keys';
235
+ throw new YAMLSemanticError(cst, msg);
236
+ } else {
237
+ seenKeys.push(key.value);
238
+ }
239
+ }
240
+ }
241
+ } catch (err) {
242
+ _iterator2.e(err);
243
+ } finally {
244
+ _iterator2.f();
245
+ }
246
+
247
+ return Object.assign(new YAMLOMap(), pairs);
248
+ }
249
+
250
+ function createOMap(schema, iterable, ctx) {
251
+ var pairs = createPairs(schema, iterable, ctx);
252
+ var omap = new YAMLOMap();
253
+ omap.items = pairs.items;
254
+ return omap;
255
+ }
256
+
257
+ var omap = {
258
+ identify: function identify(value) {
259
+ return value instanceof Map;
260
+ },
261
+ nodeClass: YAMLOMap,
262
+ default: false,
263
+ tag: 'tag:yaml.org,2002:omap',
264
+ resolve: parseOMap,
265
+ createNode: createOMap
266
+ };
267
+
268
+ var YAMLSet = /*#__PURE__*/function (_YAMLMap) {
269
+ _inherits(YAMLSet, _YAMLMap);
270
+
271
+ var _super = _createSuper(YAMLSet);
272
+
273
+ function YAMLSet() {
274
+ var _this;
275
+
276
+ _classCallCheck(this, YAMLSet);
277
+
278
+ _this = _super.call(this);
279
+ _this.tag = YAMLSet.tag;
280
+ return _this;
281
+ }
282
+
283
+ _createClass(YAMLSet, [{
284
+ key: "add",
285
+ value: function add(key) {
286
+ var pair = key instanceof Pair ? key : new Pair(key);
287
+ var prev = findPair(this.items, pair.key);
288
+ if (!prev) this.items.push(pair);
289
+ }
290
+ }, {
291
+ key: "get",
292
+ value: function get(key, keepPair) {
293
+ var pair = findPair(this.items, key);
294
+ return !keepPair && pair instanceof Pair ? pair.key instanceof Scalar ? pair.key.value : pair.key : pair;
295
+ }
296
+ }, {
297
+ key: "set",
298
+ value: function set(key, value) {
299
+ if (typeof value !== 'boolean') throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat(_typeof(value)));
300
+ var prev = findPair(this.items, key);
301
+
302
+ if (prev && !value) {
303
+ this.items.splice(this.items.indexOf(prev), 1);
304
+ } else if (!prev && value) {
305
+ this.items.push(new Pair(key));
306
+ }
307
+ }
308
+ }, {
309
+ key: "toJSON",
310
+ value: function toJSON(_, ctx) {
311
+ return _get(_getPrototypeOf(YAMLSet.prototype), "toJSON", this).call(this, _, ctx, Set);
312
+ }
313
+ }, {
314
+ key: "toString",
315
+ value: function toString(ctx, onComment, onChompKeep) {
316
+ if (!ctx) return JSON.stringify(this);
317
+ if (this.hasAllNullValues()) return _get(_getPrototypeOf(YAMLSet.prototype), "toString", this).call(this, ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
318
+ }
319
+ }]);
320
+
321
+ return YAMLSet;
322
+ }(YAMLMap);
323
+
324
+ _defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
325
+
326
+ function parseSet(doc, cst) {
327
+ var map = resolveMap(doc, cst);
328
+ if (!map.hasAllNullValues()) throw new YAMLSemanticError(cst, 'Set items must all have null values');
329
+ return Object.assign(new YAMLSet(), map);
330
+ }
331
+
332
+ function createSet(schema, iterable, ctx) {
333
+ var set = new YAMLSet();
334
+
335
+ var _iterator = _createForOfIteratorHelper(iterable),
336
+ _step;
337
+
338
+ try {
339
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
340
+ var value = _step.value;
341
+ set.items.push(schema.createPair(value, null, ctx));
342
+ }
343
+ } catch (err) {
344
+ _iterator.e(err);
345
+ } finally {
346
+ _iterator.f();
347
+ }
348
+
349
+ return set;
350
+ }
351
+
352
+ var set = {
353
+ identify: function identify(value) {
354
+ return value instanceof Set;
355
+ },
356
+ nodeClass: YAMLSet,
357
+ default: false,
358
+ tag: 'tag:yaml.org,2002:set',
359
+ resolve: parseSet,
360
+ createNode: createSet
361
+ };
362
+
363
+ var parseSexagesimal = function parseSexagesimal(sign, parts) {
364
+ var n = parts.split(':').reduce(function (n, p) {
365
+ return n * 60 + Number(p);
366
+ }, 0);
367
+ return sign === '-' ? -n : n;
368
+ }; // hhhh:mm:ss.sss
369
+
370
+
371
+ var stringifySexagesimal = function stringifySexagesimal(_ref) {
372
+ var value = _ref.value;
373
+ if (isNaN(value) || !isFinite(value)) return stringifyNumber(value);
374
+ var sign = '';
375
+
376
+ if (value < 0) {
377
+ sign = '-';
378
+ value = Math.abs(value);
379
+ }
380
+
381
+ var parts = [value % 60]; // seconds, including ms
382
+
383
+ if (value < 60) {
384
+ parts.unshift(0); // at least one : is required
385
+ } else {
386
+ value = Math.round((value - parts[0]) / 60);
387
+ parts.unshift(value % 60); // minutes
388
+
389
+ if (value >= 60) {
390
+ value = Math.round((value - parts[0]) / 60);
391
+ parts.unshift(value); // hours
392
+ }
393
+ }
394
+
395
+ return sign + parts.map(function (n) {
396
+ return n < 10 ? '0' + String(n) : String(n);
397
+ }).join(':').replace(/000000\d*$/, '') // % 60 may introduce error
398
+ ;
399
+ };
400
+
401
+ var intTime = {
402
+ identify: function identify(value) {
403
+ return typeof value === 'number';
404
+ },
405
+ default: true,
406
+ tag: 'tag:yaml.org,2002:int',
407
+ format: 'TIME',
408
+ test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,
409
+ resolve: function resolve(str, sign, parts) {
410
+ return parseSexagesimal(sign, parts.replace(/_/g, ''));
411
+ },
412
+ stringify: stringifySexagesimal
413
+ };
414
+ var floatTime = {
415
+ identify: function identify(value) {
416
+ return typeof value === 'number';
417
+ },
418
+ default: true,
419
+ tag: 'tag:yaml.org,2002:float',
420
+ format: 'TIME',
421
+ test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,
422
+ resolve: function resolve(str, sign, parts) {
423
+ return parseSexagesimal(sign, parts.replace(/_/g, ''));
424
+ },
425
+ stringify: stringifySexagesimal
426
+ };
427
+ var timestamp = {
428
+ identify: function identify(value) {
429
+ return value instanceof Date;
430
+ },
431
+ default: true,
432
+ tag: 'tag:yaml.org,2002:timestamp',
433
+ // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
434
+ // may be omitted altogether, resulting in a date format. In such a case, the time part is
435
+ // assumed to be 00:00:00Z (start of day, UTC).
436
+ test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd
437
+ '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace
438
+ '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)?
439
+ '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
440
+ ')?' + ')$'),
441
+ resolve: function resolve(str, year, month, day, hour, minute, second, millisec, tz) {
442
+ if (millisec) millisec = (millisec + '00').substr(1, 3);
443
+ var date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0);
444
+
445
+ if (tz && tz !== 'Z') {
446
+ var d = parseSexagesimal(tz[0], tz.slice(1));
447
+ if (Math.abs(d) < 30) d *= 60;
448
+ date -= 60000 * d;
449
+ }
450
+
451
+ return new Date(date);
452
+ },
453
+ stringify: function stringify(_ref2) {
454
+ var value = _ref2.value;
455
+ return value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '');
456
+ }
457
+ };
458
+
459
+ /* global console, process, YAML_SILENCE_DEPRECATION_WARNINGS, YAML_SILENCE_WARNINGS */
460
+ function shouldWarn(deprecation) {
461
+ var env = typeof process !== 'undefined' && process.env || {};
462
+
463
+ if (deprecation) {
464
+ if (typeof YAML_SILENCE_DEPRECATION_WARNINGS !== 'undefined') return !YAML_SILENCE_DEPRECATION_WARNINGS;
465
+ return !env.YAML_SILENCE_DEPRECATION_WARNINGS;
466
+ }
467
+
468
+ if (typeof YAML_SILENCE_WARNINGS !== 'undefined') return !YAML_SILENCE_WARNINGS;
469
+ return !env.YAML_SILENCE_WARNINGS;
470
+ }
471
+
472
+ function warn(warning, type) {
473
+ if (shouldWarn(false)) {
474
+ var emit = typeof process !== 'undefined' && process.emitWarning; // This will throw in Jest if `warning` is an Error instance due to
475
+ // https://github.com/facebook/jest/issues/2549
476
+
477
+ if (emit) emit(warning, type);else {
478
+ // eslint-disable-next-line no-console
479
+ console.warn(type ? "".concat(type, ": ").concat(warning) : warning);
480
+ }
481
+ }
482
+ }
483
+ function warnFileDeprecation(filename) {
484
+ if (shouldWarn(true)) {
485
+ var path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
486
+ warn("The endpoint 'yaml/".concat(path, "' will be removed in a future release."), 'DeprecationWarning');
487
+ }
488
+ }
489
+ var warned = {};
490
+ function warnOptionDeprecation(name, alternative) {
491
+ if (!warned[name] && shouldWarn(true)) {
492
+ warned[name] = true;
493
+ var msg = "The option '".concat(name, "' will be removed in a future release");
494
+ msg += alternative ? ", use '".concat(alternative, "' instead.") : '.';
495
+ warn(msg, 'DeprecationWarning');
496
+ }
497
+ }
498
+
499
+ export { warnOptionDeprecation as a, binary as b, warnFileDeprecation as c, floatTime as f, intTime as i, omap as o, pairs as p, set as s, timestamp as t, warn as w };
package/browser/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist').default
1
+ module.exports = require('./dist').YAML
package/browser/map.js CHANGED
@@ -1,2 +1,2 @@
1
- module.exports = require('./dist/schema/Map').default
2
- require('./dist/warnings').warnFileDeprecation(__filename)
1
+ module.exports = require('./dist/types').YAMLMap
2
+ require('./dist/legacy-exports').warnFileDeprecation(__filename)
package/browser/pair.js CHANGED
@@ -1,2 +1,2 @@
1
- module.exports = require('./dist/schema/Pair').default
2
- require('./dist/warnings').warnFileDeprecation(__filename)
1
+ module.exports = require('./dist/types').Pair
2
+ require('./dist/legacy-exports').warnFileDeprecation(__filename)
@@ -1 +1 @@
1
- module.exports = require('./dist/cst/parse').default
1
+ module.exports = require('./dist/parse-cst').parse
package/browser/scalar.js CHANGED
@@ -1,2 +1,2 @@
1
- module.exports = require('./dist/schema/Scalar').default
2
- require('./dist/warnings').warnFileDeprecation(__filename)
1
+ module.exports = require('./dist/types').Scalar
2
+ require('./dist/legacy-exports').warnFileDeprecation(__filename)
package/browser/schema.js CHANGED
@@ -1,7 +1,9 @@
1
- module.exports = require('./dist/schema').default
2
- var opt = require('./dist/tags/options')
3
- module.exports.nullOptions = opt.nullOptions
4
- module.exports.strOptions = opt.strOptions
5
- module.exports.stringify = require('./dist/stringify').stringifyString
1
+ const types = require('./dist/types')
2
+ const util = require('./dist/util')
6
3
 
7
- require('./dist/warnings').warnFileDeprecation(__filename)
4
+ module.exports = types.Schema
5
+ module.exports.nullOptions = types.nullOptions
6
+ module.exports.strOptions = types.strOptions
7
+ module.exports.stringify = util.stringifyString
8
+
9
+ require('./dist/legacy-exports').warnFileDeprecation(__filename)
package/browser/seq.js CHANGED
@@ -1,2 +1,2 @@
1
- module.exports = require('./dist/schema/Seq').default
2
- require('./dist/warnings').warnFileDeprecation(__filename)
1
+ module.exports = require('./dist/types').YAMLSeq
2
+ require('./dist/legacy-exports').warnFileDeprecation(__filename)
@@ -1,7 +1,8 @@
1
1
  'use strict'
2
2
  Object.defineProperty(exports, '__esModule', { value: true })
3
3
 
4
- exports.binary = require('../dist/tags/yaml-1.1/binary').default
4
+ const legacy = require('../dist/legacy-exports')
5
+ exports.binary = legacy.binary
5
6
  exports.default = [exports.binary]
6
7
 
7
- require('../dist/warnings').warnFileDeprecation(__filename)
8
+ legacy.warnFileDeprecation(__filename)
@@ -1,2 +1,3 @@
1
- module.exports = require('../dist/tags/yaml-1.1/omap').default
2
- require('../dist/warnings').warnFileDeprecation(__filename)
1
+ const legacy = require('../dist/legacy-exports')
2
+ module.exports = legacy.omap
3
+ legacy.warnFileDeprecation(__filename)
@@ -1,2 +1,3 @@
1
- module.exports = require('../dist/tags/yaml-1.1/pairs').default
2
- require('../dist/warnings').warnFileDeprecation(__filename)
1
+ const legacy = require('../dist/legacy-exports')
2
+ module.exports = legacy.pairs
3
+ legacy.warnFileDeprecation(__filename)
@@ -1,2 +1,3 @@
1
- module.exports = require('../dist/tags/yaml-1.1/set').default
2
- require('../dist/warnings').warnFileDeprecation(__filename)
1
+ const legacy = require('../dist/legacy-exports')
2
+ module.exports = legacy.set
3
+ legacy.warnFileDeprecation(__filename)
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
  Object.defineProperty(exports, '__esModule', { value: true })
3
3
 
4
- var ts = require('../dist/tags/yaml-1.1/timestamp')
5
- exports.default = [ts.intTime, ts.floatTime, ts.timestamp]
6
- exports.floatTime = ts.floatTime
7
- exports.intTime = ts.intTime
8
- exports.timestamp = ts.timestamp
4
+ const legacy = require('../dist/legacy-exports')
5
+ exports.default = [legacy.intTime, legacy.floatTime, legacy.timestamp]
6
+ exports.floatTime = legacy.floatTime
7
+ exports.intTime = legacy.intTime
8
+ exports.timestamp = legacy.timestamp
9
9
 
10
- require('../dist/warnings').warnFileDeprecation(__filename)
10
+ legacy.warnFileDeprecation(__filename)
package/browser/types.js CHANGED
@@ -1,11 +1 @@
1
- var opt = require('./dist/tags/options')
2
- exports.binaryOptions = opt.binaryOptions
3
- exports.boolOptions = opt.boolOptions
4
- exports.nullOptions = opt.nullOptions
5
- exports.strOptions = opt.strOptions
6
-
7
- exports.Schema = require('./dist/schema').default
8
- exports.YAMLMap = require('./dist/schema/Map').default
9
- exports.YAMLSeq = require('./dist/schema/Seq').default
10
- exports.Pair = require('./dist/schema/Pair').default
11
- exports.Scalar = require('./dist/schema/Scalar').default
1
+ export * from './dist/types.js'
package/browser/util.js CHANGED
@@ -1,15 +1 @@
1
- exports.findPair = require('./dist/schema/Map').findPair
2
- exports.parseMap = require('./dist/schema/parseMap').default
3
- exports.parseSeq = require('./dist/schema/parseSeq').default
4
-
5
- var str = require('./dist/stringify')
6
- exports.stringifyNumber = str.stringifyNumber
7
- exports.stringifyString = str.stringifyString
8
- exports.toJSON = require('./dist/toJSON').default
9
- exports.Type = require('./dist/constants').Type
10
-
11
- var err = require('./dist/errors')
12
- exports.YAMLReferenceError = err.YAMLReferenceError
13
- exports.YAMLSemanticError = err.YAMLSemanticError
14
- exports.YAMLSyntaxError = err.YAMLSyntaxError
15
- exports.YAMLWarning = err.YAMLWarning
1
+ export * from './dist/util.js'