yaml 1.8.2 → 1.9.2
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/browser/dist/Anchors.js +10 -13
- package/browser/dist/Document.js +72 -67
- package/browser/dist/addComment.js +1 -1
- package/browser/dist/cst/Alias.js +12 -8
- package/browser/dist/cst/BlankLine.js +16 -20
- package/browser/dist/cst/BlockValue.js +14 -10
- package/browser/dist/cst/Collection.js +17 -13
- package/browser/dist/cst/CollectionItem.js +15 -11
- package/browser/dist/cst/Comment.js +13 -9
- package/browser/dist/cst/Directive.js +13 -9
- package/browser/dist/cst/Document.js +17 -13
- package/browser/dist/cst/FlowCollection.js +17 -13
- package/browser/dist/cst/Node.js +3 -5
- package/browser/dist/cst/ParseContext.js +12 -14
- package/browser/dist/cst/PlainValue.js +12 -8
- package/browser/dist/cst/QuoteDouble.js +13 -9
- package/browser/dist/cst/QuoteSingle.js +13 -9
- package/browser/dist/cst/Range.js +2 -5
- package/browser/dist/cst/parse.js +3 -3
- package/browser/dist/errors.js +23 -8
- package/browser/dist/foldFlowLines.js +1 -1
- package/browser/dist/index.js +71 -21
- package/browser/dist/listTagNames.js +5 -5
- package/browser/dist/schema/Alias.js +30 -34
- package/browser/dist/schema/Collection.js +40 -47
- package/browser/dist/schema/Map.js +39 -56
- package/browser/dist/schema/Merge.js +37 -46
- package/browser/dist/schema/Node.js +2 -5
- package/browser/dist/schema/Pair.js +36 -13
- package/browser/dist/schema/Scalar.js +13 -9
- package/browser/dist/schema/Seq.js +27 -25
- package/browser/dist/schema/index.js +25 -39
- package/browser/dist/schema/parseMap.js +8 -8
- package/browser/dist/schema/parseSeq.js +5 -5
- package/browser/dist/schema/parseUtils.js +11 -15
- package/browser/dist/stringify.js +2 -1
- package/browser/dist/tags/core.js +39 -23
- package/browser/dist/tags/failsafe/index.js +4 -4
- package/browser/dist/tags/failsafe/map.js +15 -18
- package/browser/dist/tags/failsafe/seq.js +14 -18
- package/browser/dist/tags/failsafe/string.js +1 -1
- package/browser/dist/tags/index.js +10 -10
- package/browser/dist/tags/json.js +27 -26
- package/browser/dist/tags/options.js +3 -0
- package/browser/dist/tags/yaml-1.1/binary.js +10 -8
- package/browser/dist/tags/yaml-1.1/index.js +75 -43
- package/browser/dist/tags/yaml-1.1/omap.js +34 -39
- package/browser/dist/tags/yaml-1.1/pairs.js +17 -20
- package/browser/dist/tags/yaml-1.1/set.js +27 -23
- package/browser/dist/test-events.js +4 -4
- package/browser/dist/toJSON.js +3 -4
- package/browser/dist/warnings.js +29 -18
- package/browser/index.js +1 -1
- package/browser/map.js +4 -2
- package/browser/pair.js +4 -2
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +4 -2
- package/browser/schema.js +11 -6
- package/browser/seq.js +4 -2
- package/browser/types/binary.js +5 -6
- package/browser/types/omap.js +4 -2
- package/browser/types/pairs.js +4 -2
- package/browser/types/set.js +4 -2
- package/browser/types/timestamp.js +5 -9
- package/browser/types.js +12 -10
- package/browser/util.js +16 -13
- package/dist/Anchors.js +13 -18
- package/dist/Document.js +52 -48
- package/dist/addComment.js +1 -4
- package/dist/constants.js +0 -3
- package/dist/cst/Alias.js +8 -13
- package/dist/cst/BlankLine.js +8 -24
- package/dist/cst/BlockValue.js +12 -17
- package/dist/cst/Collection.js +22 -27
- package/dist/cst/CollectionItem.js +16 -21
- package/dist/cst/Comment.js +6 -11
- package/dist/cst/Directive.js +7 -12
- package/dist/cst/Document.js +23 -28
- package/dist/cst/FlowCollection.js +21 -26
- package/dist/cst/Node.js +4 -9
- package/dist/cst/ParseContext.js +38 -43
- package/dist/cst/PlainValue.js +10 -15
- package/dist/cst/QuoteDouble.js +9 -14
- package/dist/cst/QuoteSingle.js +9 -14
- package/dist/cst/Range.js +2 -5
- package/dist/cst/parse.js +5 -10
- package/dist/cst/source-utils.js +0 -3
- package/dist/errors.js +4 -9
- package/dist/foldFlowLines.js +1 -4
- package/dist/index.js +59 -17
- package/dist/listTagNames.js +9 -14
- package/dist/schema/Alias.js +12 -17
- package/dist/schema/Collection.js +16 -20
- package/dist/schema/Map.js +12 -17
- package/dist/schema/Merge.js +13 -18
- package/dist/schema/Node.js +2 -5
- package/dist/schema/Pair.js +44 -31
- package/dist/schema/Scalar.js +6 -11
- package/dist/schema/Seq.js +9 -14
- package/dist/schema/index.js +22 -27
- package/dist/schema/parseMap.js +19 -28
- package/dist/schema/parseSeq.js +10 -15
- package/dist/schema/parseUtils.js +0 -3
- package/dist/stringify.js +6 -12
- package/dist/tags/core.js +34 -26
- package/dist/tags/failsafe/index.js +6 -11
- package/dist/tags/failsafe/map.js +8 -13
- package/dist/tags/failsafe/seq.js +8 -13
- package/dist/tags/failsafe/string.js +3 -6
- package/dist/tags/index.js +20 -29
- package/dist/tags/json.js +26 -22
- package/dist/tags/options.js +5 -4
- package/dist/tags/yaml-1.1/binary.js +11 -11
- package/dist/tags/yaml-1.1/index.js +69 -38
- package/dist/tags/yaml-1.1/omap.js +19 -24
- package/dist/tags/yaml-1.1/pairs.js +12 -17
- package/dist/tags/yaml-1.1/set.js +12 -21
- package/dist/tags/yaml-1.1/timestamp.js +0 -3
- package/dist/test-events.js +4 -9
- package/dist/toJSON.js +3 -5
- package/dist/warnings.js +31 -22
- package/index.d.ts +358 -0
- package/index.js +1 -1
- package/map.js +1 -1
- package/package.json +29 -23
- package/pair.js +1 -1
- package/parse-cst.d.ts +187 -0
- package/parse-cst.js +1 -1
- package/scalar.js +1 -1
- package/schema.js +2 -2
- package/seq.js +1 -1
- package/types/binary.js +1 -1
- package/types/omap.js +1 -1
- package/types/pairs.js +1 -1
- package/types/set.js +1 -1
- package/types/timestamp.js +1 -1
- package/types.d.ts +393 -0
- package/types.js +7 -6
- package/types.mjs +6 -5
- package/util.d.ts +86 -0
- package/util.js +6 -5
- package/util.mjs +4 -3
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
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; } } }; }
|
|
5
|
+
|
|
6
|
+
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); }
|
|
7
|
+
|
|
8
|
+
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; }
|
|
9
|
+
|
|
10
|
+
import { YAMLMap } from '../../schema/Map';
|
|
11
|
+
import { parseMap } from '../../schema/parseMap';
|
|
5
12
|
|
|
6
13
|
function createMap(schema, obj, ctx) {
|
|
7
14
|
var map = new YAMLMap(schema);
|
|
8
15
|
|
|
9
16
|
if (obj instanceof Map) {
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _iteratorError = undefined;
|
|
17
|
+
var _iterator = _createForOfIteratorHelper(obj),
|
|
18
|
+
_step;
|
|
13
19
|
|
|
14
20
|
try {
|
|
15
|
-
for (
|
|
21
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
16
22
|
var _step$value = _slicedToArray(_step.value, 2),
|
|
17
23
|
key = _step$value[0],
|
|
18
24
|
value = _step$value[1];
|
|
@@ -20,18 +26,9 @@ function createMap(schema, obj, ctx) {
|
|
|
20
26
|
map.items.push(schema.createPair(key, value, ctx));
|
|
21
27
|
}
|
|
22
28
|
} catch (err) {
|
|
23
|
-
|
|
24
|
-
_iteratorError = err;
|
|
29
|
+
_iterator.e(err);
|
|
25
30
|
} finally {
|
|
26
|
-
|
|
27
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
28
|
-
_iterator.return();
|
|
29
|
-
}
|
|
30
|
-
} finally {
|
|
31
|
-
if (_didIteratorError) {
|
|
32
|
-
throw _iteratorError;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
31
|
+
_iterator.f();
|
|
35
32
|
}
|
|
36
33
|
} else if (obj && _typeof(obj) === 'object') {
|
|
37
34
|
for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
|
|
@@ -47,7 +44,7 @@ function createMap(schema, obj, ctx) {
|
|
|
47
44
|
return map;
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
export
|
|
47
|
+
export var map = {
|
|
51
48
|
createNode: createMap,
|
|
52
49
|
default: true,
|
|
53
50
|
nodeClass: YAMLMap,
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
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; } } }; }
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
import { parseSeq } from '../../schema/parseSeq';
|
|
8
|
+
import { YAMLSeq } from '../../schema/Seq';
|
|
3
9
|
|
|
4
10
|
function createSeq(schema, obj, ctx) {
|
|
5
11
|
var seq = new YAMLSeq(schema);
|
|
6
12
|
|
|
7
13
|
if (obj && obj[Symbol.iterator]) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _iteratorError = undefined;
|
|
14
|
+
var _iterator = _createForOfIteratorHelper(obj),
|
|
15
|
+
_step;
|
|
11
16
|
|
|
12
17
|
try {
|
|
13
|
-
for (
|
|
18
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14
19
|
var it = _step.value;
|
|
15
20
|
var v = schema.createNode(it, ctx.wrapScalars, null, ctx);
|
|
16
21
|
seq.items.push(v);
|
|
17
22
|
}
|
|
18
23
|
} catch (err) {
|
|
19
|
-
|
|
20
|
-
_iteratorError = err;
|
|
24
|
+
_iterator.e(err);
|
|
21
25
|
} finally {
|
|
22
|
-
|
|
23
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
24
|
-
_iterator.return();
|
|
25
|
-
}
|
|
26
|
-
} finally {
|
|
27
|
-
if (_didIteratorError) {
|
|
28
|
-
throw _iteratorError;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
26
|
+
_iterator.f();
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
return seq;
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
export
|
|
33
|
+
export var seq = {
|
|
38
34
|
createNode: createSeq,
|
|
39
35
|
default: true,
|
|
40
36
|
nodeClass: YAMLSeq,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import core,
|
|
2
|
-
import failsafe from './failsafe';
|
|
3
|
-
import json from './json';
|
|
4
|
-
import yaml11 from './yaml-1.1';
|
|
5
|
-
import map from './failsafe/map';
|
|
6
|
-
import seq from './failsafe/seq';
|
|
7
|
-
import binary from './yaml-1.1/binary';
|
|
8
|
-
import omap from './yaml-1.1/omap';
|
|
9
|
-
import pairs from './yaml-1.1/pairs';
|
|
10
|
-
import set from './yaml-1.1/set';
|
|
1
|
+
import { core, nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj } from './core';
|
|
2
|
+
import { failsafe } from './failsafe';
|
|
3
|
+
import { json } from './json';
|
|
4
|
+
import { yaml11 } from './yaml-1.1';
|
|
5
|
+
import { map } from './failsafe/map';
|
|
6
|
+
import { seq } from './failsafe/seq';
|
|
7
|
+
import { binary } from './yaml-1.1/binary';
|
|
8
|
+
import { omap } from './yaml-1.1/omap';
|
|
9
|
+
import { pairs } from './yaml-1.1/pairs';
|
|
10
|
+
import { set } from './yaml-1.1/set';
|
|
11
11
|
import { floatTime, intTime, timestamp } from './yaml-1.1/timestamp';
|
|
12
12
|
export var schemas = {
|
|
13
13
|
core: core,
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
/* global BigInt */
|
|
2
|
+
import { map } from './failsafe/map';
|
|
3
|
+
import { seq } from './failsafe/seq';
|
|
4
|
+
import { Scalar } from '../schema/Scalar';
|
|
4
5
|
import { resolveString } from './failsafe/string';
|
|
5
|
-
|
|
6
|
+
import { intOptions } from './options';
|
|
7
|
+
|
|
8
|
+
var intIdentify = function intIdentify(value) {
|
|
9
|
+
return typeof value === 'bigint' || Number.isInteger(value);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
var stringifyJSON = function stringifyJSON(_ref) {
|
|
13
|
+
var value = _ref.value;
|
|
14
|
+
return JSON.stringify(value);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export var json = [map, seq, {
|
|
6
18
|
identify: function identify(value) {
|
|
7
19
|
return typeof value === 'string';
|
|
8
20
|
},
|
|
9
21
|
default: true,
|
|
10
22
|
tag: 'tag:yaml.org,2002:str',
|
|
11
23
|
resolve: resolveString,
|
|
12
|
-
stringify:
|
|
13
|
-
return JSON.stringify(value);
|
|
14
|
-
}
|
|
24
|
+
stringify: stringifyJSON
|
|
15
25
|
}, {
|
|
16
26
|
identify: function identify(value) {
|
|
17
27
|
return value == null;
|
|
@@ -25,9 +35,7 @@ var schema = [map, seq, {
|
|
|
25
35
|
resolve: function resolve() {
|
|
26
36
|
return null;
|
|
27
37
|
},
|
|
28
|
-
stringify:
|
|
29
|
-
return JSON.stringify(value);
|
|
30
|
-
}
|
|
38
|
+
stringify: stringifyJSON
|
|
31
39
|
}, {
|
|
32
40
|
identify: function identify(value) {
|
|
33
41
|
return typeof value === 'boolean';
|
|
@@ -38,21 +46,18 @@ var schema = [map, seq, {
|
|
|
38
46
|
resolve: function resolve(str) {
|
|
39
47
|
return str === 'true';
|
|
40
48
|
},
|
|
41
|
-
stringify:
|
|
42
|
-
return JSON.stringify(value);
|
|
43
|
-
}
|
|
49
|
+
stringify: stringifyJSON
|
|
44
50
|
}, {
|
|
45
|
-
identify:
|
|
46
|
-
return typeof value === 'number';
|
|
47
|
-
},
|
|
51
|
+
identify: intIdentify,
|
|
48
52
|
default: true,
|
|
49
53
|
tag: 'tag:yaml.org,2002:int',
|
|
50
54
|
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
51
55
|
resolve: function resolve(str) {
|
|
52
|
-
return parseInt(str, 10);
|
|
56
|
+
return intOptions.asBigInt ? BigInt(str) : parseInt(str, 10);
|
|
53
57
|
},
|
|
54
|
-
stringify: function stringify(
|
|
55
|
-
|
|
58
|
+
stringify: function stringify(_ref2) {
|
|
59
|
+
var value = _ref2.value;
|
|
60
|
+
return intIdentify(value) ? value.toString() : JSON.stringify(value);
|
|
56
61
|
}
|
|
57
62
|
}, {
|
|
58
63
|
identify: function identify(value) {
|
|
@@ -64,13 +69,9 @@ var schema = [map, seq, {
|
|
|
64
69
|
resolve: function resolve(str) {
|
|
65
70
|
return parseFloat(str);
|
|
66
71
|
},
|
|
67
|
-
stringify:
|
|
68
|
-
return JSON.stringify(value);
|
|
69
|
-
}
|
|
72
|
+
stringify: stringifyJSON
|
|
70
73
|
}];
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
json.scalarFallback = function (str) {
|
|
73
76
|
throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(str)));
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default schema;
|
|
77
|
+
};
|
|
@@ -4,7 +4,7 @@ import { YAMLReferenceError } from '../../errors';
|
|
|
4
4
|
import { stringifyString } from '../../stringify';
|
|
5
5
|
import { resolveString } from '../failsafe/string';
|
|
6
6
|
import { binaryOptions as options } from '../options';
|
|
7
|
-
export
|
|
7
|
+
export var binary = {
|
|
8
8
|
identify: function identify(value) {
|
|
9
9
|
return value instanceof Uint8Array;
|
|
10
10
|
},
|
|
@@ -21,21 +21,23 @@ export default {
|
|
|
21
21
|
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
22
22
|
*/
|
|
23
23
|
resolve: function resolve(doc, node) {
|
|
24
|
+
var src = resolveString(doc, node);
|
|
25
|
+
|
|
24
26
|
if (typeof Buffer === 'function') {
|
|
25
|
-
var src = resolveString(doc, node);
|
|
26
27
|
return Buffer.from(src, 'base64');
|
|
27
28
|
} else if (typeof atob === 'function') {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var buffer = new Uint8Array(
|
|
29
|
+
// On IE 11, atob() can't handle newlines
|
|
30
|
+
var str = atob(src.replace(/[\n\r]/g, ''));
|
|
31
|
+
var buffer = new Uint8Array(str.length);
|
|
31
32
|
|
|
32
|
-
for (var i = 0; i <
|
|
33
|
-
buffer[i] =
|
|
33
|
+
for (var i = 0; i < str.length; ++i) {
|
|
34
|
+
buffer[i] = str.charCodeAt(i);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
return buffer;
|
|
37
38
|
} else {
|
|
38
|
-
|
|
39
|
+
var msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
|
|
40
|
+
doc.errors.push(new YAMLReferenceError(node, msg));
|
|
39
41
|
return null;
|
|
40
42
|
}
|
|
41
43
|
},
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/* global BigInt */
|
|
2
|
+
import { Scalar } from '../../schema/Scalar';
|
|
2
3
|
import { stringifyNumber } from '../../stringify';
|
|
3
|
-
import failsafe from '../failsafe';
|
|
4
|
-
import { boolOptions, nullOptions } from '../options';
|
|
5
|
-
import binary from './binary';
|
|
6
|
-
import omap from './omap';
|
|
7
|
-
import pairs from './pairs';
|
|
8
|
-
import set from './set';
|
|
4
|
+
import { failsafe } from '../failsafe';
|
|
5
|
+
import { boolOptions, intOptions, nullOptions } from '../options';
|
|
6
|
+
import { binary } from './binary';
|
|
7
|
+
import { omap } from './omap';
|
|
8
|
+
import { pairs } from './pairs';
|
|
9
|
+
import { set } from './set';
|
|
9
10
|
import { intTime, floatTime, timestamp } from './timestamp';
|
|
10
11
|
|
|
11
12
|
var boolStringify = function boolStringify(_ref) {
|
|
@@ -13,7 +14,49 @@ var boolStringify = function boolStringify(_ref) {
|
|
|
13
14
|
return value ? boolOptions.trueStr : boolOptions.falseStr;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
var intIdentify = function intIdentify(value) {
|
|
18
|
+
return typeof value === 'bigint' || Number.isInteger(value);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function intResolve(sign, src, radix) {
|
|
22
|
+
var str = src.replace(/_/g, '');
|
|
23
|
+
|
|
24
|
+
if (intOptions.asBigInt) {
|
|
25
|
+
switch (radix) {
|
|
26
|
+
case 2:
|
|
27
|
+
str = "0b".concat(str);
|
|
28
|
+
break;
|
|
29
|
+
|
|
30
|
+
case 8:
|
|
31
|
+
str = "0o".concat(str);
|
|
32
|
+
break;
|
|
33
|
+
|
|
34
|
+
case 16:
|
|
35
|
+
str = "0x".concat(str);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var _n = BigInt(str);
|
|
40
|
+
|
|
41
|
+
return sign === '-' ? BigInt(-1) * _n : _n;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var n = parseInt(str, radix);
|
|
45
|
+
return sign === '-' ? -1 * n : n;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function intStringify(node, radix, prefix) {
|
|
49
|
+
var value = node.value;
|
|
50
|
+
|
|
51
|
+
if (intIdentify(value)) {
|
|
52
|
+
var str = value.toString(radix);
|
|
53
|
+
return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return stringifyNumber(node);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export var yaml11 = failsafe.concat([{
|
|
17
60
|
identify: function identify(value) {
|
|
18
61
|
return value == null;
|
|
19
62
|
},
|
|
@@ -55,60 +98,49 @@ export default failsafe.concat([{
|
|
|
55
98
|
options: boolOptions,
|
|
56
99
|
stringify: boolStringify
|
|
57
100
|
}, {
|
|
58
|
-
identify:
|
|
59
|
-
return typeof value === 'number';
|
|
60
|
-
},
|
|
101
|
+
identify: intIdentify,
|
|
61
102
|
default: true,
|
|
62
103
|
tag: 'tag:yaml.org,2002:int',
|
|
63
104
|
format: 'BIN',
|
|
64
|
-
test: /^0b([0-1_]+)$/,
|
|
65
|
-
resolve: function resolve(str, bin) {
|
|
66
|
-
return
|
|
105
|
+
test: /^([-+]?)0b([0-1_]+)$/,
|
|
106
|
+
resolve: function resolve(str, sign, bin) {
|
|
107
|
+
return intResolve(sign, bin, 2);
|
|
67
108
|
},
|
|
68
|
-
stringify: function stringify(
|
|
69
|
-
|
|
70
|
-
return '0b' + value.toString(2);
|
|
109
|
+
stringify: function stringify(node) {
|
|
110
|
+
return intStringify(node, 2, '0b');
|
|
71
111
|
}
|
|
72
112
|
}, {
|
|
73
|
-
identify:
|
|
74
|
-
return typeof value === 'number';
|
|
75
|
-
},
|
|
113
|
+
identify: intIdentify,
|
|
76
114
|
default: true,
|
|
77
115
|
tag: 'tag:yaml.org,2002:int',
|
|
78
116
|
format: 'OCT',
|
|
79
|
-
test: /^[-+]?0([0-7_]+)$/,
|
|
80
|
-
resolve: function resolve(str, oct) {
|
|
81
|
-
return
|
|
117
|
+
test: /^([-+]?)0([0-7_]+)$/,
|
|
118
|
+
resolve: function resolve(str, sign, oct) {
|
|
119
|
+
return intResolve(sign, oct, 8);
|
|
82
120
|
},
|
|
83
|
-
stringify: function stringify(
|
|
84
|
-
|
|
85
|
-
return (value < 0 ? '-0' : '0') + value.toString(8);
|
|
121
|
+
stringify: function stringify(node) {
|
|
122
|
+
return intStringify(node, 8, '0');
|
|
86
123
|
}
|
|
87
124
|
}, {
|
|
88
|
-
identify:
|
|
89
|
-
return typeof value === 'number';
|
|
90
|
-
},
|
|
125
|
+
identify: intIdentify,
|
|
91
126
|
default: true,
|
|
92
127
|
tag: 'tag:yaml.org,2002:int',
|
|
93
|
-
test: /^[-+]?[0-9][0-9_]
|
|
94
|
-
resolve: function resolve(str) {
|
|
95
|
-
return
|
|
128
|
+
test: /^([-+]?)([0-9][0-9_]*)$/,
|
|
129
|
+
resolve: function resolve(str, sign, abs) {
|
|
130
|
+
return intResolve(sign, abs, 10);
|
|
96
131
|
},
|
|
97
132
|
stringify: stringifyNumber
|
|
98
133
|
}, {
|
|
99
|
-
identify:
|
|
100
|
-
return typeof value === 'number';
|
|
101
|
-
},
|
|
134
|
+
identify: intIdentify,
|
|
102
135
|
default: true,
|
|
103
136
|
tag: 'tag:yaml.org,2002:int',
|
|
104
137
|
format: 'HEX',
|
|
105
|
-
test: /^0x([0-9a-fA-F_]+)$/,
|
|
106
|
-
resolve: function resolve(str, hex) {
|
|
107
|
-
return
|
|
138
|
+
test: /^([-+]?)0x([0-9a-fA-F_]+)$/,
|
|
139
|
+
resolve: function resolve(str, sign, hex) {
|
|
140
|
+
return intResolve(sign, hex, 16);
|
|
108
141
|
},
|
|
109
|
-
stringify: function stringify(
|
|
110
|
-
|
|
111
|
-
return (value < 0 ? '-0x' : '0x') + value.toString(16);
|
|
142
|
+
stringify: function stringify(node) {
|
|
143
|
+
return intStringify(node, 16, '0x');
|
|
112
144
|
}
|
|
113
145
|
}, {
|
|
114
146
|
identify: function identify(value) {
|
|
@@ -132,8 +164,8 @@ export default failsafe.concat([{
|
|
|
132
164
|
resolve: function resolve(str) {
|
|
133
165
|
return parseFloat(str.replace(/_/g, ''));
|
|
134
166
|
},
|
|
135
|
-
stringify: function stringify(
|
|
136
|
-
var value =
|
|
167
|
+
stringify: function stringify(_ref2) {
|
|
168
|
+
var value = _ref2.value;
|
|
137
169
|
return Number(value).toExponential();
|
|
138
170
|
}
|
|
139
171
|
}, {
|
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
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
3
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
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
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
|
|
9
|
+
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
+
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
+
|
|
15
|
+
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
+
|
|
17
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
+
|
|
8
19
|
import { YAMLSemanticError } from '../../errors';
|
|
9
|
-
import _toJSON from '../../toJSON';
|
|
10
|
-
import YAMLMap from '../../schema/Map';
|
|
11
|
-
import Pair from '../../schema/Pair';
|
|
12
|
-
import Scalar from '../../schema/Scalar';
|
|
13
|
-
import YAMLSeq from '../../schema/Seq';
|
|
20
|
+
import { toJSON as _toJSON } from '../../toJSON';
|
|
21
|
+
import { YAMLMap } from '../../schema/Map';
|
|
22
|
+
import { Pair } from '../../schema/Pair';
|
|
23
|
+
import { Scalar } from '../../schema/Scalar';
|
|
24
|
+
import { YAMLSeq } from '../../schema/Seq';
|
|
14
25
|
import { createPairs, parsePairs } from './pairs';
|
|
15
26
|
export var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
|
|
16
27
|
_inherits(YAMLOMap, _YAMLSeq);
|
|
17
28
|
|
|
29
|
+
var _super = _createSuper(YAMLOMap);
|
|
30
|
+
|
|
18
31
|
function YAMLOMap() {
|
|
19
32
|
var _this;
|
|
20
33
|
|
|
21
34
|
_classCallCheck(this, YAMLOMap);
|
|
22
35
|
|
|
23
|
-
_this =
|
|
36
|
+
_this = _super.call(this);
|
|
24
37
|
|
|
25
38
|
_defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this)));
|
|
26
39
|
|
|
@@ -41,12 +54,12 @@ export var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
|
|
|
41
54
|
value: function toJSON(_, ctx) {
|
|
42
55
|
var map = new Map();
|
|
43
56
|
if (ctx && ctx.onCreate) ctx.onCreate(map);
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
57
|
+
|
|
58
|
+
var _iterator = _createForOfIteratorHelper(this.items),
|
|
59
|
+
_step;
|
|
47
60
|
|
|
48
61
|
try {
|
|
49
|
-
for (
|
|
62
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
50
63
|
var pair = _step.value;
|
|
51
64
|
var key = void 0,
|
|
52
65
|
value = void 0;
|
|
@@ -62,18 +75,9 @@ export var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
|
|
|
62
75
|
map.set(key, value);
|
|
63
76
|
}
|
|
64
77
|
} catch (err) {
|
|
65
|
-
|
|
66
|
-
_iteratorError = err;
|
|
78
|
+
_iterator.e(err);
|
|
67
79
|
} finally {
|
|
68
|
-
|
|
69
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
70
|
-
_iterator.return();
|
|
71
|
-
}
|
|
72
|
-
} finally {
|
|
73
|
-
if (_didIteratorError) {
|
|
74
|
-
throw _iteratorError;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
80
|
+
_iterator.f();
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
return map;
|
|
@@ -88,12 +92,12 @@ _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
|
|
|
88
92
|
function parseOMap(doc, cst) {
|
|
89
93
|
var pairs = parsePairs(doc, cst);
|
|
90
94
|
var seenKeys = [];
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
|
|
95
|
+
|
|
96
|
+
var _iterator2 = _createForOfIteratorHelper(pairs.items),
|
|
97
|
+
_step2;
|
|
94
98
|
|
|
95
99
|
try {
|
|
96
|
-
for (
|
|
100
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
97
101
|
var key = _step2.value.key;
|
|
98
102
|
|
|
99
103
|
if (key instanceof Scalar) {
|
|
@@ -106,18 +110,9 @@ function parseOMap(doc, cst) {
|
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
} catch (err) {
|
|
109
|
-
|
|
110
|
-
_iteratorError2 = err;
|
|
113
|
+
_iterator2.e(err);
|
|
111
114
|
} finally {
|
|
112
|
-
|
|
113
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
114
|
-
_iterator2.return();
|
|
115
|
-
}
|
|
116
|
-
} finally {
|
|
117
|
-
if (_didIteratorError2) {
|
|
118
|
-
throw _iteratorError2;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
115
|
+
_iterator2.f();
|
|
121
116
|
}
|
|
122
117
|
|
|
123
118
|
return Object.assign(new YAMLOMap(), pairs);
|
|
@@ -130,7 +125,7 @@ function createOMap(schema, iterable, ctx) {
|
|
|
130
125
|
return omap;
|
|
131
126
|
}
|
|
132
127
|
|
|
133
|
-
export
|
|
128
|
+
export var omap = {
|
|
134
129
|
identify: function identify(value) {
|
|
135
130
|
return value instanceof Map;
|
|
136
131
|
},
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
1
7
|
import { YAMLSemanticError } from '../../errors';
|
|
2
|
-
import YAMLMap from '../../schema/Map';
|
|
3
|
-
import Pair from '../../schema/Pair';
|
|
4
|
-
import parseSeq from '../../schema/parseSeq';
|
|
5
|
-
import YAMLSeq from '../../schema/Seq';
|
|
8
|
+
import { YAMLMap } from '../../schema/Map';
|
|
9
|
+
import { Pair } from '../../schema/Pair';
|
|
10
|
+
import { parseSeq } from '../../schema/parseSeq';
|
|
11
|
+
import { YAMLSeq } from '../../schema/Seq';
|
|
6
12
|
export function parsePairs(doc, cst) {
|
|
7
13
|
var seq = parseSeq(doc, cst);
|
|
8
14
|
|
|
@@ -27,12 +33,12 @@ export function parsePairs(doc, cst) {
|
|
|
27
33
|
export function createPairs(schema, iterable, ctx) {
|
|
28
34
|
var pairs = new YAMLSeq(schema);
|
|
29
35
|
pairs.tag = 'tag:yaml.org,2002:pairs';
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
36
|
+
|
|
37
|
+
var _iterator = _createForOfIteratorHelper(iterable),
|
|
38
|
+
_step;
|
|
33
39
|
|
|
34
40
|
try {
|
|
35
|
-
for (
|
|
41
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
36
42
|
var it = _step.value;
|
|
37
43
|
var key = void 0,
|
|
38
44
|
value = void 0;
|
|
@@ -57,23 +63,14 @@ export function createPairs(schema, iterable, ctx) {
|
|
|
57
63
|
pairs.items.push(pair);
|
|
58
64
|
}
|
|
59
65
|
} catch (err) {
|
|
60
|
-
|
|
61
|
-
_iteratorError = err;
|
|
66
|
+
_iterator.e(err);
|
|
62
67
|
} finally {
|
|
63
|
-
|
|
64
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
65
|
-
_iterator.return();
|
|
66
|
-
}
|
|
67
|
-
} finally {
|
|
68
|
-
if (_didIteratorError) {
|
|
69
|
-
throw _iteratorError;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
68
|
+
_iterator.f();
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
return pairs;
|
|
75
72
|
}
|
|
76
|
-
export
|
|
73
|
+
export var pairs = {
|
|
77
74
|
default: false,
|
|
78
75
|
tag: 'tag:yaml.org,2002:pairs',
|
|
79
76
|
resolve: parsePairs,
|