yaml 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -23
- package/browser/dist/Anchors.js +12 -10
- package/browser/dist/Document.js +122 -60
- package/browser/dist/constants.js +34 -0
- package/browser/dist/cst/Alias.js +1 -3
- package/browser/dist/cst/BlankLine.js +5 -7
- package/browser/dist/cst/BlockValue.js +4 -4
- package/browser/dist/cst/Collection.js +8 -8
- package/browser/dist/cst/CollectionItem.js +6 -8
- package/browser/dist/cst/Comment.js +5 -7
- package/browser/dist/cst/Directive.js +5 -7
- package/browser/dist/cst/Document.js +8 -10
- package/browser/dist/cst/FlowCollection.js +5 -7
- package/browser/dist/cst/Node.js +12 -40
- package/browser/dist/cst/ParseContext.js +32 -34
- package/browser/dist/cst/PlainValue.js +1 -3
- package/browser/dist/cst/QuoteDouble.js +1 -3
- package/browser/dist/cst/QuoteSingle.js +1 -3
- package/browser/dist/cst/Range.js +1 -3
- package/browser/dist/cst/getLinePos.js +8 -13
- package/browser/dist/cst/parse.js +1 -4
- package/browser/dist/deprecation.js +34 -0
- package/browser/dist/errors.js +50 -59
- package/browser/dist/index.js +7 -4
- package/browser/dist/listTagNames.js +1 -3
- package/browser/dist/schema/Alias.js +90 -10
- package/browser/dist/schema/Collection.js +3 -3
- package/browser/dist/schema/Map.js +22 -105
- package/browser/dist/schema/Merge.js +74 -1
- package/browser/dist/schema/Node.js +1 -3
- package/browser/dist/schema/Pair.js +52 -26
- package/browser/dist/schema/Scalar.js +3 -5
- package/browser/dist/schema/Seq.js +30 -7
- package/browser/dist/schema/index.js +158 -82
- package/browser/dist/schema/parseMap.js +18 -21
- package/browser/dist/schema/parseSeq.js +9 -12
- package/browser/dist/{schema/_string.js → stringify.js} +65 -73
- package/browser/dist/tags/core.js +132 -0
- package/browser/dist/tags/failsafe/index.js +17 -0
- package/browser/dist/tags/failsafe/map.js +65 -0
- package/browser/dist/tags/failsafe/seq.js +54 -0
- package/browser/dist/tags/failsafe/string.js +40 -0
- package/browser/dist/tags/index.js +50 -0
- package/browser/dist/tags/json.js +103 -0
- package/browser/dist/tags/options.js +35 -0
- package/browser/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +20 -20
- package/browser/dist/tags/yaml-1.1/index.js +177 -0
- package/browser/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +25 -25
- package/browser/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +9 -13
- package/browser/dist/tags/yaml-1.1/set.js +140 -0
- package/browser/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +13 -10
- package/browser/dist/test-events.js +1 -4
- package/browser/dist/toJSON.js +20 -8
- package/browser/index.js +1 -0
- package/browser/map.js +2 -1
- package/browser/pair.js +2 -1
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +2 -1
- package/browser/schema.js +7 -3
- package/browser/seq.js +2 -1
- package/browser/types/binary.js +7 -1
- package/browser/types/omap.js +2 -1
- package/browser/types/pairs.js +2 -1
- package/browser/types/set.js +2 -1
- package/browser/types/timestamp.js +10 -1
- package/browser/types.js +11 -0
- package/browser/util.js +15 -0
- package/dist/Anchors.js +9 -8
- package/dist/Document.js +55 -39
- package/dist/constants.js +34 -0
- package/dist/cst/Alias.js +1 -3
- package/dist/cst/BlankLine.js +5 -7
- package/dist/cst/BlockValue.js +4 -4
- package/dist/cst/Collection.js +8 -8
- package/dist/cst/CollectionItem.js +6 -8
- package/dist/cst/Comment.js +5 -7
- package/dist/cst/Directive.js +5 -7
- package/dist/cst/Document.js +8 -10
- package/dist/cst/FlowCollection.js +5 -7
- package/dist/cst/Node.js +12 -40
- package/dist/cst/ParseContext.js +32 -34
- package/dist/cst/PlainValue.js +1 -3
- package/dist/cst/QuoteDouble.js +1 -3
- package/dist/cst/QuoteSingle.js +1 -3
- package/dist/cst/Range.js +1 -3
- package/dist/cst/getLinePos.js +8 -12
- package/dist/cst/parse.js +1 -4
- package/dist/deprecation.js +34 -0
- package/dist/errors.js +29 -35
- package/dist/index.js +7 -4
- package/dist/listTagNames.js +1 -3
- package/dist/schema/Alias.js +67 -12
- package/dist/schema/Map.js +10 -74
- package/dist/schema/Merge.js +31 -0
- package/dist/schema/Node.js +1 -3
- package/dist/schema/Pair.js +46 -20
- package/dist/schema/Scalar.js +3 -5
- package/dist/schema/Seq.js +9 -5
- package/dist/schema/index.js +109 -74
- package/dist/schema/parseMap.js +18 -21
- package/dist/schema/parseSeq.js +9 -12
- package/dist/{schema/_string.js → stringify.js} +56 -65
- package/dist/tags/core.js +96 -0
- package/dist/tags/failsafe/index.js +17 -0
- package/dist/tags/failsafe/map.js +33 -0
- package/dist/tags/failsafe/seq.js +34 -0
- package/dist/tags/failsafe/string.js +40 -0
- package/dist/tags/index.js +50 -0
- package/dist/tags/json.js +67 -0
- package/dist/tags/options.js +35 -0
- package/dist/{schema/_binary.js → tags/yaml-1.1/binary.js} +18 -20
- package/dist/tags/yaml-1.1/index.js +131 -0
- package/dist/{schema/_omap.js → tags/yaml-1.1/omap.js} +16 -16
- package/dist/{schema/_pairs.js → tags/yaml-1.1/pairs.js} +9 -11
- package/dist/{schema/_set.js → tags/yaml-1.1/set.js} +12 -44
- package/dist/{schema/_timestamp.js → tags/yaml-1.1/timestamp.js} +7 -10
- package/dist/test-events.js +1 -4
- package/dist/toJSON.js +15 -5
- package/index.js +1 -0
- package/map.js +2 -1
- package/package.json +22 -17
- package/pair.js +2 -1
- package/parse-cst.js +1 -1
- package/scalar.js +2 -1
- package/schema.js +7 -3
- package/seq.js +2 -1
- package/types/binary.js +7 -1
- package/types/omap.js +2 -1
- package/types/pairs.js +2 -1
- package/types/set.js +2 -1
- package/types/timestamp.js +10 -1
- package/types.js +11 -0
- package/util.js +15 -0
- package/browser/dist/polyfill.js +0 -251
- package/browser/dist/schema/_set.js +0 -212
- package/browser/dist/schema/core.js +0 -98
- package/browser/dist/schema/failsafe.js +0 -125
- package/browser/dist/schema/json.js +0 -66
- package/browser/dist/schema/yaml-1.1.js +0 -140
- package/dist/linePos.js +0 -58
- package/dist/polyfill.js +0 -27
- package/dist/schema/core.js +0 -79
- package/dist/schema/failsafe.js +0 -74
- package/dist/schema/json.js +0 -56
- package/dist/schema/yaml-1.1.js +0 -115
|
@@ -3,18 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _constants = require("../../constants");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _errors = require("../../errors");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _stringify = require("../../stringify");
|
|
13
|
+
|
|
14
|
+
var _string = require("../failsafe/string");
|
|
15
|
+
|
|
16
|
+
var _options = require("../options");
|
|
13
17
|
|
|
14
18
|
/* global atob, btoa, Buffer */
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class: Uint8Array,
|
|
19
|
+
var _default = {
|
|
20
|
+
identify: value => value instanceof Uint8Array,
|
|
18
21
|
// Buffer inherits from Uint8Array
|
|
19
22
|
default: false,
|
|
20
23
|
tag: 'tag:yaml.org,2002:binary',
|
|
@@ -29,10 +32,10 @@ const binary = {
|
|
|
29
32
|
*/
|
|
30
33
|
resolve: (doc, node) => {
|
|
31
34
|
if (typeof Buffer === 'function') {
|
|
32
|
-
const src = (0, _string.
|
|
35
|
+
const src = (0, _string.resolveString)(doc, node);
|
|
33
36
|
return Buffer.from(src, 'base64');
|
|
34
37
|
} else if (typeof atob === 'function') {
|
|
35
|
-
const src = atob((0, _string.
|
|
38
|
+
const src = atob((0, _string.resolveString)(doc, node));
|
|
36
39
|
const buffer = new Uint8Array(src.length);
|
|
37
40
|
|
|
38
41
|
for (let i = 0; i < src.length; ++i) buffer[i] = src.charCodeAt(i);
|
|
@@ -43,10 +46,7 @@ const binary = {
|
|
|
43
46
|
return null;
|
|
44
47
|
}
|
|
45
48
|
},
|
|
46
|
-
options:
|
|
47
|
-
defaultType: _Node.Type.BLOCK_LITERAL,
|
|
48
|
-
lineWidth: 76
|
|
49
|
-
},
|
|
49
|
+
options: _options.binaryOptions,
|
|
50
50
|
stringify: ({
|
|
51
51
|
comment,
|
|
52
52
|
type,
|
|
@@ -66,14 +66,14 @@ const binary = {
|
|
|
66
66
|
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
if (!type) type =
|
|
69
|
+
if (!type) type = _options.binaryOptions.defaultType;
|
|
70
70
|
|
|
71
|
-
if (type ===
|
|
71
|
+
if (type === _constants.Type.QUOTE_DOUBLE) {
|
|
72
72
|
value = src;
|
|
73
73
|
} else {
|
|
74
74
|
const {
|
|
75
75
|
lineWidth
|
|
76
|
-
} =
|
|
76
|
+
} = _options.binaryOptions;
|
|
77
77
|
const n = Math.ceil(src.length / lineWidth);
|
|
78
78
|
const lines = new Array(n);
|
|
79
79
|
|
|
@@ -81,16 +81,14 @@ const binary = {
|
|
|
81
81
|
lines[i] = src.substr(o, lineWidth);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
value = lines.join(type ===
|
|
84
|
+
value = lines.join(type === _constants.Type.BLOCK_LITERAL ? '\n' : ' ');
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
return (0,
|
|
87
|
+
return (0, _stringify.stringifyString)({
|
|
88
88
|
comment,
|
|
89
89
|
type,
|
|
90
90
|
value
|
|
91
91
|
}, ctx, onComment, onChompKeep);
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
exports.binary = binary;
|
|
95
|
-
var _default = [binary];
|
|
96
94
|
exports.default = _default;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = 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
|
+
var _binary = _interopRequireDefault(require("./binary"));
|
|
17
|
+
|
|
18
|
+
var _omap = _interopRequireDefault(require("./omap"));
|
|
19
|
+
|
|
20
|
+
var _pairs = _interopRequireDefault(require("./pairs"));
|
|
21
|
+
|
|
22
|
+
var _set = _interopRequireDefault(require("./set"));
|
|
23
|
+
|
|
24
|
+
var _timestamp = require("./timestamp");
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
var _default = _failsafe.default.concat([{
|
|
29
|
+
identify: value => value == null,
|
|
30
|
+
createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
|
|
31
|
+
default: true,
|
|
32
|
+
tag: 'tag:yaml.org,2002:null',
|
|
33
|
+
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
34
|
+
resolve: () => null,
|
|
35
|
+
options: _options.nullOptions,
|
|
36
|
+
stringify: () => _options.nullOptions.nullStr
|
|
37
|
+
}, {
|
|
38
|
+
identify: value => typeof value === 'boolean',
|
|
39
|
+
default: true,
|
|
40
|
+
tag: 'tag:yaml.org,2002:bool',
|
|
41
|
+
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
42
|
+
resolve: () => true,
|
|
43
|
+
options: _options.boolOptions,
|
|
44
|
+
stringify: ({
|
|
45
|
+
value
|
|
46
|
+
}) => value ? _options.boolOptions.trueStr : _options.boolOptions.falseStr
|
|
47
|
+
}, {
|
|
48
|
+
identify: value => typeof value === 'boolean',
|
|
49
|
+
default: true,
|
|
50
|
+
tag: 'tag:yaml.org,2002:bool',
|
|
51
|
+
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
|
|
52
|
+
resolve: () => false,
|
|
53
|
+
options: _options.boolOptions,
|
|
54
|
+
stringify: ({
|
|
55
|
+
value
|
|
56
|
+
}) => value ? _options.boolOptions.trueStr : _options.boolOptions.falseStr
|
|
57
|
+
}, {
|
|
58
|
+
identify: value => typeof value === 'number',
|
|
59
|
+
default: true,
|
|
60
|
+
tag: 'tag:yaml.org,2002:int',
|
|
61
|
+
format: 'BIN',
|
|
62
|
+
test: /^0b([0-1_]+)$/,
|
|
63
|
+
resolve: (str, bin) => parseInt(bin.replace(/_/g, ''), 2),
|
|
64
|
+
stringify: ({
|
|
65
|
+
value
|
|
66
|
+
}) => '0b' + value.toString(2)
|
|
67
|
+
}, {
|
|
68
|
+
identify: value => typeof value === 'number',
|
|
69
|
+
default: true,
|
|
70
|
+
tag: 'tag:yaml.org,2002:int',
|
|
71
|
+
format: 'OCT',
|
|
72
|
+
test: /^[-+]?0([0-7_]+)$/,
|
|
73
|
+
resolve: (str, oct) => parseInt(oct.replace(/_/g, ''), 8),
|
|
74
|
+
stringify: ({
|
|
75
|
+
value
|
|
76
|
+
}) => (value < 0 ? '-0' : '0') + value.toString(8)
|
|
77
|
+
}, {
|
|
78
|
+
identify: value => typeof value === 'number',
|
|
79
|
+
default: true,
|
|
80
|
+
tag: 'tag:yaml.org,2002:int',
|
|
81
|
+
test: /^[-+]?[0-9][0-9_]*$/,
|
|
82
|
+
resolve: str => parseInt(str.replace(/_/g, ''), 10),
|
|
83
|
+
stringify: _stringify.stringifyNumber
|
|
84
|
+
}, {
|
|
85
|
+
identify: value => typeof value === 'number',
|
|
86
|
+
default: true,
|
|
87
|
+
tag: 'tag:yaml.org,2002:int',
|
|
88
|
+
format: 'HEX',
|
|
89
|
+
test: /^0x([0-9a-fA-F_]+)$/,
|
|
90
|
+
resolve: (str, hex) => parseInt(hex.replace(/_/g, ''), 16),
|
|
91
|
+
stringify: ({
|
|
92
|
+
value
|
|
93
|
+
}) => (value < 0 ? '-0x' : '0x') + value.toString(16)
|
|
94
|
+
}, {
|
|
95
|
+
identify: value => typeof value === 'number',
|
|
96
|
+
default: true,
|
|
97
|
+
tag: 'tag:yaml.org,2002:float',
|
|
98
|
+
test: /^(?:[-+]?\.inf|(\.nan))$/i,
|
|
99
|
+
resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
100
|
+
stringify: _stringify.stringifyNumber
|
|
101
|
+
}, {
|
|
102
|
+
identify: value => typeof value === 'number',
|
|
103
|
+
default: true,
|
|
104
|
+
tag: 'tag:yaml.org,2002:float',
|
|
105
|
+
format: 'EXP',
|
|
106
|
+
test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
107
|
+
resolve: str => parseFloat(str.replace(/_/g, '')),
|
|
108
|
+
stringify: ({
|
|
109
|
+
value
|
|
110
|
+
}) => Number(value).toExponential()
|
|
111
|
+
}, {
|
|
112
|
+
identify: value => typeof value === 'number',
|
|
113
|
+
default: true,
|
|
114
|
+
tag: 'tag:yaml.org,2002:float',
|
|
115
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
|
|
116
|
+
|
|
117
|
+
resolve(str, frac) {
|
|
118
|
+
const node = new _Scalar.default(parseFloat(str.replace(/_/g, '')));
|
|
119
|
+
|
|
120
|
+
if (frac) {
|
|
121
|
+
const f = frac.replace(/_/g, '');
|
|
122
|
+
if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return node;
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
stringify: _stringify.stringifyNumber
|
|
129
|
+
}], _binary.default, _omap.default, _pairs.default, _set.default, _timestamp.intTime, _timestamp.floatTime, _timestamp.timestamp);
|
|
130
|
+
|
|
131
|
+
exports.default = _default;
|
|
@@ -5,19 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.YAMLOMap = void 0;
|
|
7
7
|
|
|
8
|
-
var _errors = require("
|
|
8
|
+
var _errors = require("../../errors");
|
|
9
9
|
|
|
10
|
-
var _toJSON = _interopRequireDefault(require("
|
|
10
|
+
var _toJSON = _interopRequireDefault(require("../../toJSON"));
|
|
11
11
|
|
|
12
|
-
var _Map = _interopRequireDefault(require("
|
|
12
|
+
var _Map = _interopRequireDefault(require("../../schema/Map"));
|
|
13
13
|
|
|
14
|
-
var _Pair = _interopRequireDefault(require("
|
|
14
|
+
var _Pair = _interopRequireDefault(require("../../schema/Pair"));
|
|
15
15
|
|
|
16
|
-
var _Scalar = _interopRequireDefault(require("
|
|
16
|
+
var _Scalar = _interopRequireDefault(require("../../schema/Scalar"));
|
|
17
17
|
|
|
18
|
-
var _Seq = _interopRequireDefault(require("
|
|
18
|
+
var _Seq = _interopRequireDefault(require("../../schema/Seq"));
|
|
19
19
|
|
|
20
|
-
var _pairs = require("./
|
|
20
|
+
var _pairs = require("./pairs");
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
|
|
@@ -40,17 +40,18 @@ class YAMLOMap extends _Seq.default {
|
|
|
40
40
|
this.tag = YAMLOMap.tag;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
toJSON(_,
|
|
43
|
+
toJSON(_, ctx) {
|
|
44
44
|
const map = new Map();
|
|
45
|
+
if (ctx && ctx.onCreate) ctx.onCreate(map);
|
|
45
46
|
|
|
46
47
|
for (const pair of this.items) {
|
|
47
48
|
let key, value;
|
|
48
49
|
|
|
49
50
|
if (pair instanceof _Pair.default) {
|
|
50
|
-
key = (0, _toJSON.default)(pair.key, '',
|
|
51
|
-
value = (0, _toJSON.default)(pair.value, key,
|
|
51
|
+
key = (0, _toJSON.default)(pair.key, '', ctx);
|
|
52
|
+
value = (0, _toJSON.default)(pair.value, key, ctx);
|
|
52
53
|
} else {
|
|
53
|
-
key = (0, _toJSON.default)(pair, '',
|
|
54
|
+
key = (0, _toJSON.default)(pair, '', ctx);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
|
|
@@ -88,20 +89,19 @@ function parseOMap(doc, cst) {
|
|
|
88
89
|
return Object.assign(new YAMLOMap(), pairs);
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
function createOMap(schema, iterable,
|
|
92
|
-
const pairs = (0, _pairs.createPairs)(schema, iterable,
|
|
92
|
+
function createOMap(schema, iterable, ctx) {
|
|
93
|
+
const pairs = (0, _pairs.createPairs)(schema, iterable, ctx);
|
|
93
94
|
const omap = new YAMLOMap();
|
|
94
95
|
omap.items = pairs.items;
|
|
95
96
|
return omap;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
var _default = {
|
|
99
|
-
|
|
100
|
+
identify: value => value instanceof Map,
|
|
100
101
|
nodeClass: YAMLOMap,
|
|
101
102
|
default: false,
|
|
102
103
|
tag: 'tag:yaml.org,2002:omap',
|
|
103
104
|
resolve: parseOMap,
|
|
104
|
-
createNode: createOMap
|
|
105
|
-
stringify: (value, ctx, onComment, onChompKeep) => value.toString(ctx, onComment, onChompKeep)
|
|
105
|
+
createNode: createOMap
|
|
106
106
|
};
|
|
107
107
|
exports.default = _default;
|
|
@@ -7,15 +7,15 @@ exports.parsePairs = parsePairs;
|
|
|
7
7
|
exports.createPairs = createPairs;
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _errors = require("
|
|
10
|
+
var _errors = require("../../errors");
|
|
11
11
|
|
|
12
|
-
var _Map = _interopRequireDefault(require("
|
|
12
|
+
var _Map = _interopRequireDefault(require("../../schema/Map"));
|
|
13
13
|
|
|
14
|
-
var _Pair = _interopRequireDefault(require("
|
|
14
|
+
var _Pair = _interopRequireDefault(require("../../schema/Pair"));
|
|
15
15
|
|
|
16
|
-
var _parseSeq = _interopRequireDefault(require("
|
|
16
|
+
var _parseSeq = _interopRequireDefault(require("../../schema/parseSeq"));
|
|
17
17
|
|
|
18
|
-
var _Seq = _interopRequireDefault(require("
|
|
18
|
+
var _Seq = _interopRequireDefault(require("../../schema/Seq"));
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
@@ -41,7 +41,7 @@ function parsePairs(doc, cst) {
|
|
|
41
41
|
return seq;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function createPairs(schema, iterable,
|
|
44
|
+
function createPairs(schema, iterable, ctx) {
|
|
45
45
|
const pairs = new _Seq.default();
|
|
46
46
|
pairs.tag = 'tag:yaml.org,2002:pairs';
|
|
47
47
|
|
|
@@ -64,9 +64,8 @@ function createPairs(schema, iterable, wrapScalars) {
|
|
|
64
64
|
key = it;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
pairs.items.push(new _Pair.default(k, v));
|
|
67
|
+
const pair = schema.createPair(key, value, ctx);
|
|
68
|
+
pairs.items.push(pair);
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
return pairs;
|
|
@@ -76,7 +75,6 @@ var _default = {
|
|
|
76
75
|
default: false,
|
|
77
76
|
tag: 'tag:yaml.org,2002:pairs',
|
|
78
77
|
resolve: parsePairs,
|
|
79
|
-
createNode: createPairs
|
|
80
|
-
stringify: (value, ctx, onComment, onChompKeep) => value.toString(ctx, onComment, onChompKeep)
|
|
78
|
+
createNode: createPairs
|
|
81
79
|
};
|
|
82
80
|
exports.default = _default;
|
|
@@ -5,24 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.YAMLSet = void 0;
|
|
7
7
|
|
|
8
|
-
var _errors = require("
|
|
8
|
+
var _errors = require("../../errors");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _Map = _interopRequireWildcard(require("../../schema/Map"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _Pair = _interopRequireDefault(require("../../schema/Pair"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _parseMap = _interopRequireDefault(require("../../schema/parseMap"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _Scalar = _interopRequireDefault(require("../../schema/Scalar"));
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _Scalar = _interopRequireDefault(require("./Scalar"));
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
19
|
|
|
22
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
23
21
|
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
22
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
23
|
|
|
28
24
|
class YAMLSet extends _Map.default {
|
|
@@ -53,32 +49,8 @@ class YAMLSet extends _Map.default {
|
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
toJSON(_,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
for (const item of this.items) {
|
|
60
|
-
if (item instanceof _Merge.default) {
|
|
61
|
-
const {
|
|
62
|
-
items
|
|
63
|
-
} = item.value;
|
|
64
|
-
|
|
65
|
-
for (let i = items.length - 1; i >= 0; --i) {
|
|
66
|
-
const {
|
|
67
|
-
source
|
|
68
|
-
} = items[i];
|
|
69
|
-
|
|
70
|
-
if (source instanceof _Map.default) {
|
|
71
|
-
for (const [key] of source.toJSMap(opt)) set.add(key);
|
|
72
|
-
} else {
|
|
73
|
-
throw new Error('Merge sources must be maps');
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
set.add((0, _toJSON.default)(item.key, '', opt));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return set;
|
|
52
|
+
toJSON(_, ctx) {
|
|
53
|
+
return super.toJSON(_, ctx, Set);
|
|
82
54
|
}
|
|
83
55
|
|
|
84
56
|
toString(ctx, onComment, onChompKeep) {
|
|
@@ -98,24 +70,20 @@ function parseSet(doc, cst) {
|
|
|
98
70
|
return Object.assign(new YAMLSet(), map);
|
|
99
71
|
}
|
|
100
72
|
|
|
101
|
-
function createSet(schema, iterable,
|
|
73
|
+
function createSet(schema, iterable, ctx) {
|
|
102
74
|
const set = new YAMLSet();
|
|
103
75
|
|
|
104
|
-
for (const value of iterable)
|
|
105
|
-
const v = schema.createNode(value, wrapScalars);
|
|
106
|
-
set.items.push(new _Pair.default(v));
|
|
107
|
-
}
|
|
76
|
+
for (const value of iterable) set.items.push(schema.createPair(value, null, ctx));
|
|
108
77
|
|
|
109
78
|
return set;
|
|
110
79
|
}
|
|
111
80
|
|
|
112
81
|
var _default = {
|
|
113
|
-
|
|
82
|
+
identify: value => value instanceof Set,
|
|
114
83
|
nodeClass: YAMLSet,
|
|
115
84
|
default: false,
|
|
116
85
|
tag: 'tag:yaml.org,2002:set',
|
|
117
86
|
resolve: parseSet,
|
|
118
|
-
createNode: createSet
|
|
119
|
-
stringify: (value, ctx, onComment, onChompKeep) => value.toString(ctx, onComment, onChompKeep)
|
|
87
|
+
createNode: createSet
|
|
120
88
|
};
|
|
121
89
|
exports.default = _default;
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.timestamp = exports.floatTime = exports.intTime = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _stringify = require("../../stringify");
|
|
9
9
|
|
|
10
|
-
// Published as 'yaml/types/timestamp'
|
|
11
10
|
const parseSexagesimal = (sign, parts) => {
|
|
12
11
|
const n = parts.split(':').reduce((n, p) => n * 60 + Number(p), 0);
|
|
13
12
|
return sign === '-' ? -n : n;
|
|
@@ -17,7 +16,7 @@ const parseSexagesimal = (sign, parts) => {
|
|
|
17
16
|
const stringifySexagesimal = ({
|
|
18
17
|
value
|
|
19
18
|
}) => {
|
|
20
|
-
if (isNaN(value) || !isFinite(value)) return (0,
|
|
19
|
+
if (isNaN(value) || !isFinite(value)) return (0, _stringify.stringifyNumber)(value);
|
|
21
20
|
let sign = '';
|
|
22
21
|
|
|
23
22
|
if (value < 0) {
|
|
@@ -44,7 +43,7 @@ const stringifySexagesimal = ({
|
|
|
44
43
|
};
|
|
45
44
|
|
|
46
45
|
const intTime = {
|
|
47
|
-
|
|
46
|
+
identify: value => typeof value === 'number',
|
|
48
47
|
default: true,
|
|
49
48
|
tag: 'tag:yaml.org,2002:int',
|
|
50
49
|
format: 'TIME',
|
|
@@ -54,7 +53,7 @@ const intTime = {
|
|
|
54
53
|
};
|
|
55
54
|
exports.intTime = intTime;
|
|
56
55
|
const floatTime = {
|
|
57
|
-
|
|
56
|
+
identify: value => typeof value === 'number',
|
|
58
57
|
default: true,
|
|
59
58
|
tag: 'tag:yaml.org,2002:float',
|
|
60
59
|
format: 'TIME',
|
|
@@ -64,7 +63,7 @@ const floatTime = {
|
|
|
64
63
|
};
|
|
65
64
|
exports.floatTime = floatTime;
|
|
66
65
|
const timestamp = {
|
|
67
|
-
|
|
66
|
+
identify: value => value instanceof Date,
|
|
68
67
|
default: true,
|
|
69
68
|
tag: 'tag:yaml.org,2002:timestamp',
|
|
70
69
|
// If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
|
|
@@ -91,6 +90,4 @@ const timestamp = {
|
|
|
91
90
|
value
|
|
92
91
|
}) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
|
|
93
92
|
};
|
|
94
|
-
exports.timestamp = timestamp;
|
|
95
|
-
var _default = [intTime, floatTime, timestamp];
|
|
96
|
-
exports.default = _default;
|
|
93
|
+
exports.timestamp = timestamp;
|
package/dist/test-events.js
CHANGED
|
@@ -162,7 +162,4 @@ function addEvents(events, doc, e, node) {
|
|
|
162
162
|
const value = node.cstNode.strValue.replace(/\\/g, '\\\\').replace(/\0/g, '\\0').replace(/\x07/g, '\\a').replace(/\x08/g, '\\b').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\v/g, '\\v').replace(/\f/g, '\\f').replace(/\r/g, '\\r').replace(/\x1b/g, '\\e');
|
|
163
163
|
events.push(`=VAL${props} ${scalar}${value}`);
|
|
164
164
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
module.exports = exports.default;
|
|
168
|
-
module.exports.default = exports.default;
|
|
165
|
+
}
|
package/dist/toJSON.js
CHANGED
|
@@ -5,9 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = toJSON;
|
|
7
7
|
|
|
8
|
-
function toJSON(value, arg,
|
|
9
|
-
|
|
10
|
-
}
|
|
8
|
+
function toJSON(value, arg, ctx) {
|
|
9
|
+
if (Array.isArray(value)) return value.map((v, i) => toJSON(v, String(i), ctx));
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (value && typeof value.toJSON === 'function') {
|
|
12
|
+
const anchor = ctx && ctx.anchors && ctx.anchors.find(a => a.node === value);
|
|
13
|
+
if (anchor) ctx.onCreate = res => {
|
|
14
|
+
anchor.res = res;
|
|
15
|
+
delete ctx.onCreate;
|
|
16
|
+
};
|
|
17
|
+
const res = value.toJSON(arg, ctx);
|
|
18
|
+
if (anchor && ctx.onCreate) ctx.onCreate(res);
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return value;
|
|
23
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist').default
|
package/map.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/schema/Map')
|
|
1
|
+
module.exports = require('./dist/schema/Map').default
|
|
2
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Eemeli Aro <eemeli@gmail.com>",
|
|
6
6
|
"repository": "github:eemeli/yaml",
|
|
@@ -18,20 +18,22 @@
|
|
|
18
18
|
"*.js",
|
|
19
19
|
"!.*.js"
|
|
20
20
|
],
|
|
21
|
-
"main": "./
|
|
21
|
+
"main": "./index.js",
|
|
22
22
|
"browser": {
|
|
23
|
-
"./
|
|
23
|
+
"./index.js": "./browser/index.js",
|
|
24
24
|
"./map.js": "./browser/map.js",
|
|
25
25
|
"./pair.js": "./browser/pair.js",
|
|
26
26
|
"./parse-cst.js": "./browser/parse-cst.js",
|
|
27
27
|
"./scalar.js": "./browser/scalar.js",
|
|
28
28
|
"./schema.js": "./browser/schema.js",
|
|
29
29
|
"./seq.js": "./browser/seq.js",
|
|
30
|
+
"./types.js": "./browser/types.js",
|
|
30
31
|
"./types/binary.js": "./browser/types/binary.js",
|
|
31
32
|
"./types/omap.js": "./browser/types/omap.js",
|
|
32
33
|
"./types/pairs.js": "./browser/types/pairs.js",
|
|
33
34
|
"./types/set.js": "./browser/types/set.js",
|
|
34
|
-
"./types/timestamp.js": "./browser/types/timestamp.js"
|
|
35
|
+
"./types/timestamp.js": "./browser/types/timestamp.js",
|
|
36
|
+
"./util.js": "./browser/util.js"
|
|
35
37
|
},
|
|
36
38
|
"scripts": {
|
|
37
39
|
"browser:build": "BABEL_ENV=browser babel src/ --out-dir browser/dist/",
|
|
@@ -40,6 +42,7 @@
|
|
|
40
42
|
"build": "npm run dist:build && npm run browser:build && npm run browser:copy",
|
|
41
43
|
"prettier": "prettier --write \"{src,tests}/**/*.js\"",
|
|
42
44
|
"lint": "eslint src/",
|
|
45
|
+
"start": "npm run dist:build && node -i -e 'YAML=require(\".\")'",
|
|
43
46
|
"test": "TRACE_LEVEL=log jest",
|
|
44
47
|
"test:trace": "TRACE_LEVEL=trace,log jest --no-cache",
|
|
45
48
|
"docs:install": "cd docs/ && bundle install",
|
|
@@ -63,23 +66,25 @@
|
|
|
63
66
|
"singleQuote": true
|
|
64
67
|
},
|
|
65
68
|
"devDependencies": {
|
|
66
|
-
"@babel/cli": "^7.
|
|
67
|
-
"@babel/core": "^7.
|
|
68
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
69
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
70
|
-
"@babel/preset-env": "^7.3
|
|
69
|
+
"@babel/cli": "^7.4.3",
|
|
70
|
+
"@babel/core": "^7.4.3",
|
|
71
|
+
"@babel/plugin-proposal-class-properties": "^7.4.0",
|
|
72
|
+
"@babel/plugin-transform-runtime": "^7.4.3",
|
|
73
|
+
"@babel/preset-env": "^7.4.3",
|
|
71
74
|
"babel-eslint": "^10.0.1",
|
|
72
|
-
"babel-jest": "^24.
|
|
73
|
-
"babel-plugin-add-module-exports": "^1.0.0",
|
|
75
|
+
"babel-jest": "^24.7.1",
|
|
74
76
|
"babel-plugin-trace": "^1.1.0",
|
|
75
77
|
"cpy-cli": "^2.0.0",
|
|
76
|
-
"eslint": "^5.
|
|
77
|
-
"eslint-config-prettier": "^4.
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
78
|
+
"eslint": "^5.16.0",
|
|
79
|
+
"eslint-config-prettier": "^4.1.0",
|
|
80
|
+
"eslint-plugin-prettier": "^3.0.1",
|
|
81
|
+
"fast-check": "^1.13.0",
|
|
82
|
+
"jest": "^24.7.1",
|
|
83
|
+
"prettier": "^1.16.4"
|
|
84
|
+
},
|
|
85
|
+
"dependencies": {
|
|
86
|
+
"@babel/runtime": "^7.4.3"
|
|
81
87
|
},
|
|
82
|
-
"dependencies": {},
|
|
83
88
|
"engines": {
|
|
84
89
|
"node": ">= 6"
|
|
85
90
|
}
|
package/pair.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/schema/Pair')
|
|
1
|
+
module.exports = require('./dist/schema/Pair').default
|
|
2
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/parse-cst.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./dist/cst/parse')
|
|
1
|
+
module.exports = require('./dist/cst/parse').default
|
package/scalar.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/schema/Scalar')
|
|
1
|
+
module.exports = require('./dist/schema/Scalar').default
|
|
2
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/schema.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
module.exports = require('./dist/schema')
|
|
2
|
-
|
|
3
|
-
module.exports.
|
|
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
|
|
6
|
+
|
|
7
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/seq.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/schema/Seq')
|
|
1
|
+
module.exports = require('./dist/schema/Seq').default
|
|
2
|
+
require('./dist/deprecation').warnFileDeprecation(__filename)
|
package/types/binary.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
|
|
4
|
+
exports.binary = require('../dist/tags/yaml-1.1/binary').default
|
|
5
|
+
exports.default = [exports.binary]
|
|
6
|
+
|
|
7
|
+
require('../dist/deprecation').warnFileDeprecation(__filename)
|