@digipair/skill-yaml 0.113.1 → 0.114.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/README.md +7 -0
- package/{index.cjs.js → dist/index.cjs.js} +432 -445
- package/{index.esm.js → dist/index.esm.js} +432 -443
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/{libs/skill-yaml → dist}/src/lib/skill-yaml.d.ts +1 -0
- package/dist/src/lib/skill-yaml.d.ts.map +1 -0
- package/package.json +26 -5
- package/index.d.ts +0 -1
- package/libs/skill-yaml/src/index.d.ts +0 -1
- /package/{index.cjs.d.ts → dist/index.d.ts} +0 -0
- /package/{schema.fr.json → dist/schema.fr.json} +0 -0
- /package/{schema.json → dist/schema.json} +0 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ function _instanceof(left, right) {
|
|
6
4
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
7
5
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -9,11 +7,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
9
7
|
return left instanceof right;
|
|
10
8
|
}
|
|
11
9
|
}
|
|
10
|
+
function _type_of(obj) {
|
|
11
|
+
"@swc/helpers - typeof";
|
|
12
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
13
|
+
}
|
|
12
14
|
function isNothing(subject) {
|
|
13
|
-
return typeof subject ===
|
|
15
|
+
return typeof subject === 'undefined' || subject === null;
|
|
14
16
|
}
|
|
15
17
|
function isObject(subject) {
|
|
16
|
-
return typeof subject === "
|
|
18
|
+
return (typeof subject === "undefined" ? "undefined" : _type_of(subject)) === 'object' && subject !== null;
|
|
17
19
|
}
|
|
18
20
|
function toArray(sequence) {
|
|
19
21
|
if (Array.isArray(sequence)) return sequence;
|
|
@@ -34,7 +36,7 @@ function extend(target, source) {
|
|
|
34
36
|
return target;
|
|
35
37
|
}
|
|
36
38
|
function repeat(string, count) {
|
|
37
|
-
var result =
|
|
39
|
+
var result = '', cycle;
|
|
38
40
|
for(cycle = 0; cycle < count; cycle += 1){
|
|
39
41
|
result += string;
|
|
40
42
|
}
|
|
@@ -59,21 +61,21 @@ var common = {
|
|
|
59
61
|
};
|
|
60
62
|
// YAML error class. http://stackoverflow.com/questions/8458984
|
|
61
63
|
function formatError(exception, compact) {
|
|
62
|
-
var where =
|
|
64
|
+
var where = '', message = exception.reason || '(unknown reason)';
|
|
63
65
|
if (!exception.mark) return message;
|
|
64
66
|
if (exception.mark.name) {
|
|
65
67
|
where += 'in "' + exception.mark.name + '" ';
|
|
66
68
|
}
|
|
67
|
-
where +=
|
|
69
|
+
where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')';
|
|
68
70
|
if (!compact && exception.mark.snippet) {
|
|
69
|
-
where +=
|
|
71
|
+
where += '\n\n' + exception.mark.snippet;
|
|
70
72
|
}
|
|
71
|
-
return message +
|
|
73
|
+
return message + ' ' + where;
|
|
72
74
|
}
|
|
73
75
|
function YAMLException$1(reason, mark) {
|
|
74
76
|
// Super constructor
|
|
75
77
|
Error.call(this);
|
|
76
|
-
this.name =
|
|
78
|
+
this.name = 'YAMLException';
|
|
77
79
|
this.reason = reason;
|
|
78
80
|
this.mark = mark;
|
|
79
81
|
this.message = formatError(this, false);
|
|
@@ -83,44 +85,44 @@ function YAMLException$1(reason, mark) {
|
|
|
83
85
|
Error.captureStackTrace(this, this.constructor);
|
|
84
86
|
} else {
|
|
85
87
|
// FF, IE 10+ and Safari 6+. Fallback for others
|
|
86
|
-
this.stack = new Error().stack ||
|
|
88
|
+
this.stack = new Error().stack || '';
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
// Inherit from Error
|
|
90
92
|
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
91
93
|
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
92
94
|
YAMLException$1.prototype.toString = function toString(compact) {
|
|
93
|
-
return this.name +
|
|
95
|
+
return this.name + ': ' + formatError(this, compact);
|
|
94
96
|
};
|
|
95
97
|
var exception = YAMLException$1;
|
|
96
98
|
// get snippet for a single line, respecting maxLength
|
|
97
99
|
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
98
|
-
var head =
|
|
99
|
-
var tail =
|
|
100
|
+
var head = '';
|
|
101
|
+
var tail = '';
|
|
100
102
|
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
101
103
|
if (position - lineStart > maxHalfLength) {
|
|
102
|
-
head =
|
|
104
|
+
head = ' ... ';
|
|
103
105
|
lineStart = position - maxHalfLength + head.length;
|
|
104
106
|
}
|
|
105
107
|
if (lineEnd - position > maxHalfLength) {
|
|
106
|
-
tail =
|
|
108
|
+
tail = ' ...';
|
|
107
109
|
lineEnd = position + maxHalfLength - tail.length;
|
|
108
110
|
}
|
|
109
111
|
return {
|
|
110
|
-
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g,
|
|
112
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail,
|
|
111
113
|
pos: position - lineStart + head.length // relative position
|
|
112
114
|
};
|
|
113
115
|
}
|
|
114
116
|
function padStart(string, max) {
|
|
115
|
-
return common.repeat(
|
|
117
|
+
return common.repeat(' ', max - string.length) + string;
|
|
116
118
|
}
|
|
117
119
|
function makeSnippet(mark, options) {
|
|
118
120
|
options = Object.create(options || null);
|
|
119
121
|
if (!mark.buffer) return null;
|
|
120
122
|
if (!options.maxLength) options.maxLength = 79;
|
|
121
|
-
if (typeof options.indent !==
|
|
122
|
-
if (typeof options.linesBefore !==
|
|
123
|
-
if (typeof options.linesAfter !==
|
|
123
|
+
if (typeof options.indent !== 'number') options.indent = 1;
|
|
124
|
+
if (typeof options.linesBefore !== 'number') options.linesBefore = 3;
|
|
125
|
+
if (typeof options.linesAfter !== 'number') options.linesAfter = 2;
|
|
124
126
|
var re = /\r?\n|\r|\0/g;
|
|
125
127
|
var lineStarts = [
|
|
126
128
|
0
|
|
@@ -136,41 +138,41 @@ function makeSnippet(mark, options) {
|
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
139
|
-
var result =
|
|
141
|
+
var result = '', i, line;
|
|
140
142
|
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
141
143
|
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
142
144
|
for(i = 1; i <= options.linesBefore; i++){
|
|
143
145
|
if (foundLineNo - i < 0) break;
|
|
144
146
|
line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
145
|
-
result = common.repeat(
|
|
147
|
+
result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + ' | ' + line.str + '\n' + result;
|
|
146
148
|
}
|
|
147
149
|
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
148
|
-
result += common.repeat(
|
|
149
|
-
result += common.repeat(
|
|
150
|
+
result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + ' | ' + line.str + '\n';
|
|
151
|
+
result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n';
|
|
150
152
|
for(i = 1; i <= options.linesAfter; i++){
|
|
151
153
|
if (foundLineNo + i >= lineEnds.length) break;
|
|
152
154
|
line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
153
|
-
result += common.repeat(
|
|
155
|
+
result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + ' | ' + line.str + '\n';
|
|
154
156
|
}
|
|
155
|
-
return result.replace(/\n$/,
|
|
157
|
+
return result.replace(/\n$/, '');
|
|
156
158
|
}
|
|
157
159
|
var snippet = makeSnippet;
|
|
158
160
|
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
'kind',
|
|
162
|
+
'multi',
|
|
163
|
+
'resolve',
|
|
164
|
+
'construct',
|
|
165
|
+
'instanceOf',
|
|
166
|
+
'predicate',
|
|
167
|
+
'represent',
|
|
168
|
+
'representName',
|
|
169
|
+
'defaultStyle',
|
|
170
|
+
'styleAliases'
|
|
169
171
|
];
|
|
170
172
|
var YAML_NODE_KINDS = [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
'scalar',
|
|
174
|
+
'sequence',
|
|
175
|
+
'mapping'
|
|
174
176
|
];
|
|
175
177
|
function compileStyleAliases(map) {
|
|
176
178
|
var result = {};
|
|
@@ -193,20 +195,20 @@ function Type$1(tag, options) {
|
|
|
193
195
|
// TODO: Add tag format check.
|
|
194
196
|
this.options = options; // keep original options in case user wants to extend this type later
|
|
195
197
|
this.tag = tag;
|
|
196
|
-
this.kind = options[
|
|
197
|
-
this.resolve = options[
|
|
198
|
+
this.kind = options['kind'] || null;
|
|
199
|
+
this.resolve = options['resolve'] || function() {
|
|
198
200
|
return true;
|
|
199
201
|
};
|
|
200
|
-
this.construct = options[
|
|
202
|
+
this.construct = options['construct'] || function(data) {
|
|
201
203
|
return data;
|
|
202
204
|
};
|
|
203
|
-
this.instanceOf = options[
|
|
204
|
-
this.predicate = options[
|
|
205
|
-
this.represent = options[
|
|
206
|
-
this.representName = options[
|
|
207
|
-
this.defaultStyle = options[
|
|
208
|
-
this.multi = options[
|
|
209
|
-
this.styleAliases = compileStyleAliases(options[
|
|
205
|
+
this.instanceOf = options['instanceOf'] || null;
|
|
206
|
+
this.predicate = options['predicate'] || null;
|
|
207
|
+
this.represent = options['represent'] || null;
|
|
208
|
+
this.representName = options['representName'] || null;
|
|
209
|
+
this.defaultStyle = options['defaultStyle'] || null;
|
|
210
|
+
this.multi = options['multi'] || false;
|
|
211
|
+
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
|
|
210
212
|
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
211
213
|
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
212
214
|
}
|
|
@@ -241,9 +243,9 @@ function compileMap() {
|
|
|
241
243
|
function collectType(type) {
|
|
242
244
|
if (type.multi) {
|
|
243
245
|
result.multi[type.kind].push(type);
|
|
244
|
-
result.multi[
|
|
246
|
+
result.multi['fallback'].push(type);
|
|
245
247
|
} else {
|
|
246
|
-
result[type.kind][type.tag] = result[
|
|
248
|
+
result[type.kind][type.tag] = result['fallback'][type.tag] = type;
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
for(index = 0, length = arguments.length; index < length; index += 1){
|
|
@@ -268,47 +270,47 @@ Schema$1.prototype.extend = function extend(definition) {
|
|
|
268
270
|
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
269
271
|
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
270
272
|
} else {
|
|
271
|
-
throw new exception(
|
|
273
|
+
throw new exception('Schema.extend argument should be a Type, [ Type ], ' + 'or a schema definition ({ implicit: [...], explicit: [...] })');
|
|
272
274
|
}
|
|
273
275
|
implicit.forEach(function(type$1) {
|
|
274
276
|
if (!_instanceof(type$1, type)) {
|
|
275
|
-
throw new exception(
|
|
277
|
+
throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
|
276
278
|
}
|
|
277
|
-
if (type$1.loadKind && type$1.loadKind !==
|
|
278
|
-
throw new exception(
|
|
279
|
+
if (type$1.loadKind && type$1.loadKind !== 'scalar') {
|
|
280
|
+
throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
|
|
279
281
|
}
|
|
280
282
|
if (type$1.multi) {
|
|
281
|
-
throw new exception(
|
|
283
|
+
throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.');
|
|
282
284
|
}
|
|
283
285
|
});
|
|
284
286
|
explicit.forEach(function(type$1) {
|
|
285
287
|
if (!_instanceof(type$1, type)) {
|
|
286
|
-
throw new exception(
|
|
288
|
+
throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
|
287
289
|
}
|
|
288
290
|
});
|
|
289
291
|
var result = Object.create(Schema$1.prototype);
|
|
290
292
|
result.implicit = (this.implicit || []).concat(implicit);
|
|
291
293
|
result.explicit = (this.explicit || []).concat(explicit);
|
|
292
|
-
result.compiledImplicit = compileList(result,
|
|
293
|
-
result.compiledExplicit = compileList(result,
|
|
294
|
+
result.compiledImplicit = compileList(result, 'implicit');
|
|
295
|
+
result.compiledExplicit = compileList(result, 'explicit');
|
|
294
296
|
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
295
297
|
return result;
|
|
296
298
|
};
|
|
297
299
|
var schema = Schema$1;
|
|
298
|
-
var str = new type(
|
|
299
|
-
kind:
|
|
300
|
+
var str = new type('tag:yaml.org,2002:str', {
|
|
301
|
+
kind: 'scalar',
|
|
300
302
|
construct: function construct(data) {
|
|
301
|
-
return data !== null ? data :
|
|
303
|
+
return data !== null ? data : '';
|
|
302
304
|
}
|
|
303
305
|
});
|
|
304
|
-
var seq = new type(
|
|
305
|
-
kind:
|
|
306
|
+
var seq = new type('tag:yaml.org,2002:seq', {
|
|
307
|
+
kind: 'sequence',
|
|
306
308
|
construct: function construct(data) {
|
|
307
309
|
return data !== null ? data : [];
|
|
308
310
|
}
|
|
309
311
|
});
|
|
310
|
-
var map = new type(
|
|
311
|
-
kind:
|
|
312
|
+
var map = new type('tag:yaml.org,2002:map', {
|
|
313
|
+
kind: 'mapping',
|
|
312
314
|
construct: function construct(data) {
|
|
313
315
|
return data !== null ? data : {};
|
|
314
316
|
}
|
|
@@ -323,7 +325,7 @@ var failsafe = new schema({
|
|
|
323
325
|
function resolveYamlNull(data) {
|
|
324
326
|
if (data === null) return true;
|
|
325
327
|
var max = data.length;
|
|
326
|
-
return max === 1 && data ===
|
|
328
|
+
return max === 1 && data === '~' || max === 4 && (data === 'null' || data === 'Null' || data === 'NULL');
|
|
327
329
|
}
|
|
328
330
|
function constructYamlNull() {
|
|
329
331
|
return null;
|
|
@@ -331,58 +333,58 @@ function constructYamlNull() {
|
|
|
331
333
|
function isNull(object) {
|
|
332
334
|
return object === null;
|
|
333
335
|
}
|
|
334
|
-
var _null = new type(
|
|
335
|
-
kind:
|
|
336
|
+
var _null = new type('tag:yaml.org,2002:null', {
|
|
337
|
+
kind: 'scalar',
|
|
336
338
|
resolve: resolveYamlNull,
|
|
337
339
|
construct: constructYamlNull,
|
|
338
340
|
predicate: isNull,
|
|
339
341
|
represent: {
|
|
340
342
|
canonical: function canonical() {
|
|
341
|
-
return
|
|
343
|
+
return '~';
|
|
342
344
|
},
|
|
343
345
|
lowercase: function lowercase() {
|
|
344
|
-
return
|
|
346
|
+
return 'null';
|
|
345
347
|
},
|
|
346
348
|
uppercase: function uppercase() {
|
|
347
|
-
return
|
|
349
|
+
return 'NULL';
|
|
348
350
|
},
|
|
349
351
|
camelcase: function camelcase() {
|
|
350
|
-
return
|
|
352
|
+
return 'Null';
|
|
351
353
|
},
|
|
352
354
|
empty: function empty() {
|
|
353
|
-
return
|
|
355
|
+
return '';
|
|
354
356
|
}
|
|
355
357
|
},
|
|
356
|
-
defaultStyle:
|
|
358
|
+
defaultStyle: 'lowercase'
|
|
357
359
|
});
|
|
358
360
|
function resolveYamlBoolean(data) {
|
|
359
361
|
if (data === null) return false;
|
|
360
362
|
var max = data.length;
|
|
361
|
-
return max === 4 && (data ===
|
|
363
|
+
return max === 4 && (data === 'true' || data === 'True' || data === 'TRUE') || max === 5 && (data === 'false' || data === 'False' || data === 'FALSE');
|
|
362
364
|
}
|
|
363
365
|
function constructYamlBoolean(data) {
|
|
364
|
-
return data ===
|
|
366
|
+
return data === 'true' || data === 'True' || data === 'TRUE';
|
|
365
367
|
}
|
|
366
368
|
function isBoolean(object) {
|
|
367
|
-
return Object.prototype.toString.call(object) ===
|
|
369
|
+
return Object.prototype.toString.call(object) === '[object Boolean]';
|
|
368
370
|
}
|
|
369
|
-
var bool = new type(
|
|
370
|
-
kind:
|
|
371
|
+
var bool = new type('tag:yaml.org,2002:bool', {
|
|
372
|
+
kind: 'scalar',
|
|
371
373
|
resolve: resolveYamlBoolean,
|
|
372
374
|
construct: constructYamlBoolean,
|
|
373
375
|
predicate: isBoolean,
|
|
374
376
|
represent: {
|
|
375
377
|
lowercase: function lowercase(object) {
|
|
376
|
-
return object ?
|
|
378
|
+
return object ? 'true' : 'false';
|
|
377
379
|
},
|
|
378
380
|
uppercase: function uppercase(object) {
|
|
379
|
-
return object ?
|
|
381
|
+
return object ? 'TRUE' : 'FALSE';
|
|
380
382
|
},
|
|
381
383
|
camelcase: function camelcase(object) {
|
|
382
|
-
return object ?
|
|
384
|
+
return object ? 'True' : 'False';
|
|
383
385
|
}
|
|
384
386
|
},
|
|
385
|
-
defaultStyle:
|
|
387
|
+
defaultStyle: 'lowercase'
|
|
386
388
|
});
|
|
387
389
|
function isHexCode(c) {
|
|
388
390
|
return 0x30 /* 0 */ <= c && c <= 0x39 /* 9 */ || 0x41 /* A */ <= c && c <= 0x46 /* F */ || 0x61 /* a */ <= c && c <= 0x66 /* f */ ;
|
|
@@ -399,149 +401,149 @@ function resolveYamlInteger(data) {
|
|
|
399
401
|
if (!max) return false;
|
|
400
402
|
ch = data[index];
|
|
401
403
|
// sign
|
|
402
|
-
if (ch ===
|
|
404
|
+
if (ch === '-' || ch === '+') {
|
|
403
405
|
ch = data[++index];
|
|
404
406
|
}
|
|
405
|
-
if (ch ===
|
|
407
|
+
if (ch === '0') {
|
|
406
408
|
// 0
|
|
407
409
|
if (index + 1 === max) return true;
|
|
408
410
|
ch = data[++index];
|
|
409
411
|
// base 2, base 8, base 16
|
|
410
|
-
if (ch ===
|
|
412
|
+
if (ch === 'b') {
|
|
411
413
|
// base 2
|
|
412
414
|
index++;
|
|
413
415
|
for(; index < max; index++){
|
|
414
416
|
ch = data[index];
|
|
415
|
-
if (ch ===
|
|
416
|
-
if (ch !==
|
|
417
|
+
if (ch === '_') continue;
|
|
418
|
+
if (ch !== '0' && ch !== '1') return false;
|
|
417
419
|
hasDigits = true;
|
|
418
420
|
}
|
|
419
|
-
return hasDigits && ch !==
|
|
421
|
+
return hasDigits && ch !== '_';
|
|
420
422
|
}
|
|
421
|
-
if (ch ===
|
|
423
|
+
if (ch === 'x') {
|
|
422
424
|
// base 16
|
|
423
425
|
index++;
|
|
424
426
|
for(; index < max; index++){
|
|
425
427
|
ch = data[index];
|
|
426
|
-
if (ch ===
|
|
428
|
+
if (ch === '_') continue;
|
|
427
429
|
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
428
430
|
hasDigits = true;
|
|
429
431
|
}
|
|
430
|
-
return hasDigits && ch !==
|
|
432
|
+
return hasDigits && ch !== '_';
|
|
431
433
|
}
|
|
432
|
-
if (ch ===
|
|
434
|
+
if (ch === 'o') {
|
|
433
435
|
// base 8
|
|
434
436
|
index++;
|
|
435
437
|
for(; index < max; index++){
|
|
436
438
|
ch = data[index];
|
|
437
|
-
if (ch ===
|
|
439
|
+
if (ch === '_') continue;
|
|
438
440
|
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
439
441
|
hasDigits = true;
|
|
440
442
|
}
|
|
441
|
-
return hasDigits && ch !==
|
|
443
|
+
return hasDigits && ch !== '_';
|
|
442
444
|
}
|
|
443
445
|
}
|
|
444
446
|
// base 10 (except 0)
|
|
445
447
|
// value should not start with `_`;
|
|
446
|
-
if (ch ===
|
|
448
|
+
if (ch === '_') return false;
|
|
447
449
|
for(; index < max; index++){
|
|
448
450
|
ch = data[index];
|
|
449
|
-
if (ch ===
|
|
451
|
+
if (ch === '_') continue;
|
|
450
452
|
if (!isDecCode(data.charCodeAt(index))) {
|
|
451
453
|
return false;
|
|
452
454
|
}
|
|
453
455
|
hasDigits = true;
|
|
454
456
|
}
|
|
455
457
|
// Should have digits and should not end with `_`
|
|
456
|
-
if (!hasDigits || ch ===
|
|
458
|
+
if (!hasDigits || ch === '_') return false;
|
|
457
459
|
return true;
|
|
458
460
|
}
|
|
459
461
|
function constructYamlInteger(data) {
|
|
460
462
|
var value = data, sign = 1, ch;
|
|
461
|
-
if (value.indexOf(
|
|
462
|
-
value = value.replace(/_/g,
|
|
463
|
+
if (value.indexOf('_') !== -1) {
|
|
464
|
+
value = value.replace(/_/g, '');
|
|
463
465
|
}
|
|
464
466
|
ch = value[0];
|
|
465
|
-
if (ch ===
|
|
466
|
-
if (ch ===
|
|
467
|
+
if (ch === '-' || ch === '+') {
|
|
468
|
+
if (ch === '-') sign = -1;
|
|
467
469
|
value = value.slice(1);
|
|
468
470
|
ch = value[0];
|
|
469
471
|
}
|
|
470
|
-
if (value ===
|
|
471
|
-
if (ch ===
|
|
472
|
-
if (value[1] ===
|
|
473
|
-
if (value[1] ===
|
|
474
|
-
if (value[1] ===
|
|
472
|
+
if (value === '0') return 0;
|
|
473
|
+
if (ch === '0') {
|
|
474
|
+
if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
|
|
475
|
+
if (value[1] === 'x') return sign * parseInt(value.slice(2), 16);
|
|
476
|
+
if (value[1] === 'o') return sign * parseInt(value.slice(2), 8);
|
|
475
477
|
}
|
|
476
478
|
return sign * parseInt(value, 10);
|
|
477
479
|
}
|
|
478
480
|
function isInteger(object) {
|
|
479
|
-
return Object.prototype.toString.call(object) ===
|
|
481
|
+
return Object.prototype.toString.call(object) === '[object Number]' && object % 1 === 0 && !common.isNegativeZero(object);
|
|
480
482
|
}
|
|
481
|
-
var int = new type(
|
|
482
|
-
kind:
|
|
483
|
+
var int = new type('tag:yaml.org,2002:int', {
|
|
484
|
+
kind: 'scalar',
|
|
483
485
|
resolve: resolveYamlInteger,
|
|
484
486
|
construct: constructYamlInteger,
|
|
485
487
|
predicate: isInteger,
|
|
486
488
|
represent: {
|
|
487
489
|
binary: function binary(obj) {
|
|
488
|
-
return obj >= 0 ?
|
|
490
|
+
return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1);
|
|
489
491
|
},
|
|
490
492
|
octal: function octal(obj) {
|
|
491
|
-
return obj >= 0 ?
|
|
493
|
+
return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1);
|
|
492
494
|
},
|
|
493
495
|
decimal: function decimal(obj) {
|
|
494
496
|
return obj.toString(10);
|
|
495
497
|
},
|
|
496
498
|
/* eslint-disable max-len */ hexadecimal: function hexadecimal(obj) {
|
|
497
|
-
return obj >= 0 ?
|
|
499
|
+
return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1);
|
|
498
500
|
}
|
|
499
501
|
},
|
|
500
|
-
defaultStyle:
|
|
502
|
+
defaultStyle: 'decimal',
|
|
501
503
|
styleAliases: {
|
|
502
504
|
binary: [
|
|
503
505
|
2,
|
|
504
|
-
|
|
506
|
+
'bin'
|
|
505
507
|
],
|
|
506
508
|
octal: [
|
|
507
509
|
8,
|
|
508
|
-
|
|
510
|
+
'oct'
|
|
509
511
|
],
|
|
510
512
|
decimal: [
|
|
511
513
|
10,
|
|
512
|
-
|
|
514
|
+
'dec'
|
|
513
515
|
],
|
|
514
516
|
hexadecimal: [
|
|
515
517
|
16,
|
|
516
|
-
|
|
518
|
+
'hex'
|
|
517
519
|
]
|
|
518
520
|
}
|
|
519
521
|
});
|
|
520
522
|
var YAML_FLOAT_PATTERN = new RegExp(// 2.5e4, 2.5 and integers
|
|
521
|
-
|
|
523
|
+
'^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + // .2e4, .2
|
|
522
524
|
// special case, seems not from spec
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
525
|
+
'|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + // .inf
|
|
526
|
+
'|[-+]?\\.(?:inf|Inf|INF)' + // .nan
|
|
527
|
+
'|\\.(?:nan|NaN|NAN))$');
|
|
526
528
|
function resolveYamlFloat(data) {
|
|
527
529
|
if (data === null) return false;
|
|
528
530
|
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
529
531
|
// Probably should update regexp & check speed
|
|
530
|
-
data[data.length - 1] ===
|
|
532
|
+
data[data.length - 1] === '_') {
|
|
531
533
|
return false;
|
|
532
534
|
}
|
|
533
535
|
return true;
|
|
534
536
|
}
|
|
535
537
|
function constructYamlFloat(data) {
|
|
536
538
|
var value, sign;
|
|
537
|
-
value = data.replace(/_/g,
|
|
538
|
-
sign = value[0] ===
|
|
539
|
-
if (
|
|
539
|
+
value = data.replace(/_/g, '').toLowerCase();
|
|
540
|
+
sign = value[0] === '-' ? -1 : 1;
|
|
541
|
+
if ('+-'.indexOf(value[0]) >= 0) {
|
|
540
542
|
value = value.slice(1);
|
|
541
543
|
}
|
|
542
|
-
if (value ===
|
|
544
|
+
if (value === '.inf') {
|
|
543
545
|
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
544
|
-
} else if (value ===
|
|
546
|
+
} else if (value === '.nan') {
|
|
545
547
|
return NaN;
|
|
546
548
|
}
|
|
547
549
|
return sign * parseFloat(value, 10);
|
|
@@ -551,49 +553,49 @@ function representYamlFloat(object, style) {
|
|
|
551
553
|
var res;
|
|
552
554
|
if (isNaN(object)) {
|
|
553
555
|
switch(style){
|
|
554
|
-
case
|
|
555
|
-
return
|
|
556
|
-
case
|
|
557
|
-
return
|
|
558
|
-
case
|
|
559
|
-
return
|
|
556
|
+
case 'lowercase':
|
|
557
|
+
return '.nan';
|
|
558
|
+
case 'uppercase':
|
|
559
|
+
return '.NAN';
|
|
560
|
+
case 'camelcase':
|
|
561
|
+
return '.NaN';
|
|
560
562
|
}
|
|
561
563
|
} else if (Number.POSITIVE_INFINITY === object) {
|
|
562
564
|
switch(style){
|
|
563
|
-
case
|
|
564
|
-
return
|
|
565
|
-
case
|
|
566
|
-
return
|
|
567
|
-
case
|
|
568
|
-
return
|
|
565
|
+
case 'lowercase':
|
|
566
|
+
return '.inf';
|
|
567
|
+
case 'uppercase':
|
|
568
|
+
return '.INF';
|
|
569
|
+
case 'camelcase':
|
|
570
|
+
return '.Inf';
|
|
569
571
|
}
|
|
570
572
|
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
571
573
|
switch(style){
|
|
572
|
-
case
|
|
573
|
-
return
|
|
574
|
-
case
|
|
575
|
-
return
|
|
576
|
-
case
|
|
577
|
-
return
|
|
574
|
+
case 'lowercase':
|
|
575
|
+
return '-.inf';
|
|
576
|
+
case 'uppercase':
|
|
577
|
+
return '-.INF';
|
|
578
|
+
case 'camelcase':
|
|
579
|
+
return '-.Inf';
|
|
578
580
|
}
|
|
579
581
|
} else if (common.isNegativeZero(object)) {
|
|
580
|
-
return
|
|
582
|
+
return '-0.0';
|
|
581
583
|
}
|
|
582
584
|
res = object.toString(10);
|
|
583
585
|
// JS stringifier can build scientific format without dots: 5e-100,
|
|
584
586
|
// while YAML requres dot: 5.e-100. Fix it with simple hack
|
|
585
|
-
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace(
|
|
587
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
|
|
586
588
|
}
|
|
587
589
|
function isFloat(object) {
|
|
588
|
-
return Object.prototype.toString.call(object) ===
|
|
590
|
+
return Object.prototype.toString.call(object) === '[object Number]' && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
589
591
|
}
|
|
590
|
-
var float = new type(
|
|
591
|
-
kind:
|
|
592
|
+
var float = new type('tag:yaml.org,2002:float', {
|
|
593
|
+
kind: 'scalar',
|
|
592
594
|
resolve: resolveYamlFloat,
|
|
593
595
|
construct: constructYamlFloat,
|
|
594
596
|
predicate: isFloat,
|
|
595
597
|
represent: representYamlFloat,
|
|
596
|
-
defaultStyle:
|
|
598
|
+
defaultStyle: 'lowercase'
|
|
597
599
|
});
|
|
598
600
|
var json = failsafe.extend({
|
|
599
601
|
implicit: [
|
|
@@ -604,19 +606,19 @@ var json = failsafe.extend({
|
|
|
604
606
|
]
|
|
605
607
|
});
|
|
606
608
|
var core = json;
|
|
607
|
-
var YAML_DATE_REGEXP = new RegExp(
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
609
|
+
var YAML_DATE_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
610
|
+
'-([0-9][0-9])' + // [2] month
|
|
611
|
+
'-([0-9][0-9])$'); // [3] day
|
|
612
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
613
|
+
'-([0-9][0-9]?)' + // [2] month
|
|
614
|
+
'-([0-9][0-9]?)' + // [3] day
|
|
615
|
+
'(?:[Tt]|[ \\t]+)' + // ...
|
|
616
|
+
'([0-9][0-9]?)' + // [4] hour
|
|
617
|
+
':([0-9][0-9])' + // [5] minute
|
|
618
|
+
':([0-9][0-9])' + // [6] second
|
|
619
|
+
'(?:\\.([0-9]*))?' + // [7] fraction
|
|
620
|
+
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
|
|
621
|
+
'(?::([0-9][0-9]))?))?$'); // [11] tz_minute
|
|
620
622
|
function resolveYamlTimestamp(data) {
|
|
621
623
|
if (data === null) return false;
|
|
622
624
|
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
@@ -627,7 +629,7 @@ function constructYamlTimestamp(data) {
|
|
|
627
629
|
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
628
630
|
match = YAML_DATE_REGEXP.exec(data);
|
|
629
631
|
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
630
|
-
if (match === null) throw new Error(
|
|
632
|
+
if (match === null) throw new Error('Date resolve error');
|
|
631
633
|
// match: [1] year [2] month [3] day
|
|
632
634
|
year = +match[1];
|
|
633
635
|
month = +match[2] - 1; // JS month starts with 0
|
|
@@ -642,7 +644,7 @@ function constructYamlTimestamp(data) {
|
|
|
642
644
|
if (match[7]) {
|
|
643
645
|
fraction = match[7].slice(0, 3);
|
|
644
646
|
while(fraction.length < 3){
|
|
645
|
-
fraction +=
|
|
647
|
+
fraction += '0';
|
|
646
648
|
}
|
|
647
649
|
fraction = +fraction;
|
|
648
650
|
}
|
|
@@ -651,7 +653,7 @@ function constructYamlTimestamp(data) {
|
|
|
651
653
|
tz_hour = +match[10];
|
|
652
654
|
tz_minute = +(match[11] || 0);
|
|
653
655
|
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
|
|
654
|
-
if (match[9] ===
|
|
656
|
+
if (match[9] === '-') delta = -delta;
|
|
655
657
|
}
|
|
656
658
|
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
657
659
|
if (delta) date.setTime(date.getTime() - delta);
|
|
@@ -660,22 +662,22 @@ function constructYamlTimestamp(data) {
|
|
|
660
662
|
function representYamlTimestamp(object /*, style*/ ) {
|
|
661
663
|
return object.toISOString();
|
|
662
664
|
}
|
|
663
|
-
var timestamp = new type(
|
|
664
|
-
kind:
|
|
665
|
+
var timestamp = new type('tag:yaml.org,2002:timestamp', {
|
|
666
|
+
kind: 'scalar',
|
|
665
667
|
resolve: resolveYamlTimestamp,
|
|
666
668
|
construct: constructYamlTimestamp,
|
|
667
669
|
instanceOf: Date,
|
|
668
670
|
represent: representYamlTimestamp
|
|
669
671
|
});
|
|
670
672
|
function resolveYamlMerge(data) {
|
|
671
|
-
return data ===
|
|
673
|
+
return data === '<<' || data === null;
|
|
672
674
|
}
|
|
673
|
-
var merge = new type(
|
|
674
|
-
kind:
|
|
675
|
+
var merge = new type('tag:yaml.org,2002:merge', {
|
|
676
|
+
kind: 'scalar',
|
|
675
677
|
resolve: resolveYamlMerge
|
|
676
678
|
});
|
|
677
679
|
/*eslint-disable no-bitwise*/ // [ 64, 65, 66 ] -> [ padding, CR, LF ]
|
|
678
|
-
var BASE64_MAP =
|
|
680
|
+
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
|
679
681
|
function resolveYamlBinary(data) {
|
|
680
682
|
if (data === null) return false;
|
|
681
683
|
var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
|
|
@@ -692,7 +694,7 @@ function resolveYamlBinary(data) {
|
|
|
692
694
|
return bitlen % 8 === 0;
|
|
693
695
|
}
|
|
694
696
|
function constructYamlBinary(data) {
|
|
695
|
-
var idx, tailbits, input = data.replace(/[\r\n=]/g,
|
|
697
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ''), max = input.length, map = BASE64_MAP, bits = 0, result = [];
|
|
696
698
|
// Collect by 6*4 bits (3 bytes)
|
|
697
699
|
for(idx = 0; idx < max; idx++){
|
|
698
700
|
if (idx % 4 === 0 && idx) {
|
|
@@ -717,7 +719,7 @@ function constructYamlBinary(data) {
|
|
|
717
719
|
return new Uint8Array(result);
|
|
718
720
|
}
|
|
719
721
|
function representYamlBinary(object /*, style*/ ) {
|
|
720
|
-
var result =
|
|
722
|
+
var result = '', bits = 0, idx, tail, max = object.length, map = BASE64_MAP;
|
|
721
723
|
// Convert every three bytes to 4 ASCII characters.
|
|
722
724
|
for(idx = 0; idx < max; idx++){
|
|
723
725
|
if (idx % 3 === 0 && idx) {
|
|
@@ -749,10 +751,10 @@ function representYamlBinary(object /*, style*/ ) {
|
|
|
749
751
|
return result;
|
|
750
752
|
}
|
|
751
753
|
function isBinary(obj) {
|
|
752
|
-
return Object.prototype.toString.call(obj) ===
|
|
754
|
+
return Object.prototype.toString.call(obj) === '[object Uint8Array]';
|
|
753
755
|
}
|
|
754
|
-
var binary = new type(
|
|
755
|
-
kind:
|
|
756
|
+
var binary = new type('tag:yaml.org,2002:binary', {
|
|
757
|
+
kind: 'scalar',
|
|
756
758
|
resolve: resolveYamlBinary,
|
|
757
759
|
construct: constructYamlBinary,
|
|
758
760
|
predicate: isBinary,
|
|
@@ -766,7 +768,7 @@ function resolveYamlOmap(data) {
|
|
|
766
768
|
for(index = 0, length = object.length; index < length; index += 1){
|
|
767
769
|
pair = object[index];
|
|
768
770
|
pairHasKey = false;
|
|
769
|
-
if (_toString$2.call(pair) !==
|
|
771
|
+
if (_toString$2.call(pair) !== '[object Object]') return false;
|
|
770
772
|
for(pairKey in pair){
|
|
771
773
|
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
772
774
|
if (!pairHasKey) pairHasKey = true;
|
|
@@ -782,8 +784,8 @@ function resolveYamlOmap(data) {
|
|
|
782
784
|
function constructYamlOmap(data) {
|
|
783
785
|
return data !== null ? data : [];
|
|
784
786
|
}
|
|
785
|
-
var omap = new type(
|
|
786
|
-
kind:
|
|
787
|
+
var omap = new type('tag:yaml.org,2002:omap', {
|
|
788
|
+
kind: 'sequence',
|
|
787
789
|
resolve: resolveYamlOmap,
|
|
788
790
|
construct: constructYamlOmap
|
|
789
791
|
});
|
|
@@ -794,7 +796,7 @@ function resolveYamlPairs(data) {
|
|
|
794
796
|
result = new Array(object.length);
|
|
795
797
|
for(index = 0, length = object.length; index < length; index += 1){
|
|
796
798
|
pair = object[index];
|
|
797
|
-
if (_toString$1.call(pair) !==
|
|
799
|
+
if (_toString$1.call(pair) !== '[object Object]') return false;
|
|
798
800
|
keys = Object.keys(pair);
|
|
799
801
|
if (keys.length !== 1) return false;
|
|
800
802
|
result[index] = [
|
|
@@ -818,8 +820,8 @@ function constructYamlPairs(data) {
|
|
|
818
820
|
}
|
|
819
821
|
return result;
|
|
820
822
|
}
|
|
821
|
-
var pairs = new type(
|
|
822
|
-
kind:
|
|
823
|
+
var pairs = new type('tag:yaml.org,2002:pairs', {
|
|
824
|
+
kind: 'sequence',
|
|
823
825
|
resolve: resolveYamlPairs,
|
|
824
826
|
construct: constructYamlPairs
|
|
825
827
|
});
|
|
@@ -837,8 +839,8 @@ function resolveYamlSet(data) {
|
|
|
837
839
|
function constructYamlSet(data) {
|
|
838
840
|
return data !== null ? data : {};
|
|
839
841
|
}
|
|
840
|
-
var set = new type(
|
|
841
|
-
kind:
|
|
842
|
+
var set = new type('tag:yaml.org,2002:set', {
|
|
843
|
+
kind: 'mapping',
|
|
842
844
|
resolve: resolveYamlSet,
|
|
843
845
|
construct: constructYamlSet
|
|
844
846
|
});
|
|
@@ -912,7 +914,7 @@ function fromDecimalCode(c) {
|
|
|
912
914
|
return -1;
|
|
913
915
|
}
|
|
914
916
|
function simpleEscapeSequence(c) {
|
|
915
|
-
/* eslint-disable indent */ return c === 0x30 /* 0 */ ?
|
|
917
|
+
/* eslint-disable indent */ return c === 0x30 /* 0 */ ? '\x00' : c === 0x61 /* a */ ? '\x07' : c === 0x62 /* b */ ? '\x08' : c === 0x74 /* t */ ? '\x09' : c === 0x09 /* Tab */ ? '\x09' : c === 0x6E /* n */ ? '\x0A' : c === 0x76 /* v */ ? '\x0B' : c === 0x66 /* f */ ? '\x0C' : c === 0x72 /* r */ ? '\x0D' : c === 0x65 /* e */ ? '\x1B' : c === 0x20 /* Space */ ? ' ' : c === 0x22 /* " */ ? '\x22' : c === 0x2F /* / */ ? '/' : c === 0x5C /* \ */ ? '\x5C' : c === 0x4E /* N */ ? '\x85' : c === 0x5F /* _ */ ? '\xA0' : c === 0x4C /* L */ ? '\u2028' : c === 0x50 /* P */ ? '\u2029' : '';
|
|
916
918
|
}
|
|
917
919
|
function charFromCodepoint(c) {
|
|
918
920
|
if (c <= 0xFFFF) {
|
|
@@ -930,14 +932,14 @@ for(var i = 0; i < 256; i++){
|
|
|
930
932
|
}
|
|
931
933
|
function State$1(input, options) {
|
|
932
934
|
this.input = input;
|
|
933
|
-
this.filename = options[
|
|
934
|
-
this.schema = options[
|
|
935
|
-
this.onWarning = options[
|
|
935
|
+
this.filename = options['filename'] || null;
|
|
936
|
+
this.schema = options['schema'] || _default;
|
|
937
|
+
this.onWarning = options['onWarning'] || null;
|
|
936
938
|
// (Hidden) Remove? makes the loader to expect YAML 1.1 documents
|
|
937
939
|
// if such documents have no explicit %YAML directive
|
|
938
|
-
this.legacy = options[
|
|
939
|
-
this.json = options[
|
|
940
|
-
this.listener = options[
|
|
940
|
+
this.legacy = options['legacy'] || false;
|
|
941
|
+
this.json = options['json'] || false;
|
|
942
|
+
this.listener = options['listener'] || null;
|
|
941
943
|
this.implicitTypes = this.schema.compiledImplicit;
|
|
942
944
|
this.typeMap = this.schema.compiledTypeMap;
|
|
943
945
|
this.length = input.length;
|
|
@@ -981,46 +983,46 @@ var directiveHandlers = {
|
|
|
981
983
|
YAML: function handleYamlDirective(state, name, args) {
|
|
982
984
|
var match, major, minor;
|
|
983
985
|
if (state.version !== null) {
|
|
984
|
-
throwError(state,
|
|
986
|
+
throwError(state, 'duplication of %YAML directive');
|
|
985
987
|
}
|
|
986
988
|
if (args.length !== 1) {
|
|
987
|
-
throwError(state,
|
|
989
|
+
throwError(state, 'YAML directive accepts exactly one argument');
|
|
988
990
|
}
|
|
989
991
|
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
990
992
|
if (match === null) {
|
|
991
|
-
throwError(state,
|
|
993
|
+
throwError(state, 'ill-formed argument of the YAML directive');
|
|
992
994
|
}
|
|
993
995
|
major = parseInt(match[1], 10);
|
|
994
996
|
minor = parseInt(match[2], 10);
|
|
995
997
|
if (major !== 1) {
|
|
996
|
-
throwError(state,
|
|
998
|
+
throwError(state, 'unacceptable YAML version of the document');
|
|
997
999
|
}
|
|
998
1000
|
state.version = args[0];
|
|
999
1001
|
state.checkLineBreaks = minor < 2;
|
|
1000
1002
|
if (minor !== 1 && minor !== 2) {
|
|
1001
|
-
throwWarning(state,
|
|
1003
|
+
throwWarning(state, 'unsupported YAML version of the document');
|
|
1002
1004
|
}
|
|
1003
1005
|
},
|
|
1004
1006
|
TAG: function handleTagDirective(state, name, args) {
|
|
1005
1007
|
var handle, prefix;
|
|
1006
1008
|
if (args.length !== 2) {
|
|
1007
|
-
throwError(state,
|
|
1009
|
+
throwError(state, 'TAG directive accepts exactly two arguments');
|
|
1008
1010
|
}
|
|
1009
1011
|
handle = args[0];
|
|
1010
1012
|
prefix = args[1];
|
|
1011
1013
|
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1012
|
-
throwError(state,
|
|
1014
|
+
throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
|
|
1013
1015
|
}
|
|
1014
1016
|
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
1015
1017
|
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1016
1018
|
}
|
|
1017
1019
|
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1018
|
-
throwError(state,
|
|
1020
|
+
throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
|
|
1019
1021
|
}
|
|
1020
1022
|
try {
|
|
1021
1023
|
prefix = decodeURIComponent(prefix);
|
|
1022
1024
|
} catch (err) {
|
|
1023
|
-
throwError(state,
|
|
1025
|
+
throwError(state, 'tag prefix is malformed: ' + prefix);
|
|
1024
1026
|
}
|
|
1025
1027
|
state.tagMap[handle] = prefix;
|
|
1026
1028
|
}
|
|
@@ -1033,11 +1035,11 @@ function captureSegment(state, start, end, checkJson) {
|
|
|
1033
1035
|
for(_position = 0, _length = _result.length; _position < _length; _position += 1){
|
|
1034
1036
|
_character = _result.charCodeAt(_position);
|
|
1035
1037
|
if (!(_character === 0x09 || 0x20 <= _character && _character <= 0x10FFFF)) {
|
|
1036
|
-
throwError(state,
|
|
1038
|
+
throwError(state, 'expected valid JSON character');
|
|
1037
1039
|
}
|
|
1038
1040
|
}
|
|
1039
1041
|
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1040
|
-
throwError(state,
|
|
1042
|
+
throwError(state, 'the stream contains non-printable characters');
|
|
1041
1043
|
}
|
|
1042
1044
|
state.result += _result;
|
|
1043
1045
|
}
|
|
@@ -1045,7 +1047,7 @@ function captureSegment(state, start, end, checkJson) {
|
|
|
1045
1047
|
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1046
1048
|
var sourceKeys, key, index, quantity;
|
|
1047
1049
|
if (!common.isObject(source)) {
|
|
1048
|
-
throwError(state,
|
|
1050
|
+
throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
|
|
1049
1051
|
}
|
|
1050
1052
|
sourceKeys = Object.keys(source);
|
|
1051
1053
|
for(index = 0, quantity = sourceKeys.length; index < quantity; index += 1){
|
|
@@ -1065,24 +1067,24 @@ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valu
|
|
|
1065
1067
|
keyNode = Array.prototype.slice.call(keyNode);
|
|
1066
1068
|
for(index = 0, quantity = keyNode.length; index < quantity; index += 1){
|
|
1067
1069
|
if (Array.isArray(keyNode[index])) {
|
|
1068
|
-
throwError(state,
|
|
1070
|
+
throwError(state, 'nested arrays are not supported inside keys');
|
|
1069
1071
|
}
|
|
1070
|
-
if (typeof keyNode === "
|
|
1071
|
-
keyNode[index] =
|
|
1072
|
+
if ((typeof keyNode === "undefined" ? "undefined" : _type_of(keyNode)) === 'object' && _class(keyNode[index]) === '[object Object]') {
|
|
1073
|
+
keyNode[index] = '[object Object]';
|
|
1072
1074
|
}
|
|
1073
1075
|
}
|
|
1074
1076
|
}
|
|
1075
1077
|
// Avoid code execution in load() via toString property
|
|
1076
1078
|
// (still use its own toString for arrays, timestamps,
|
|
1077
1079
|
// and whatever user schema extensions happen to have @@toStringTag)
|
|
1078
|
-
if (typeof keyNode === "
|
|
1079
|
-
keyNode =
|
|
1080
|
+
if ((typeof keyNode === "undefined" ? "undefined" : _type_of(keyNode)) === 'object' && _class(keyNode) === '[object Object]') {
|
|
1081
|
+
keyNode = '[object Object]';
|
|
1080
1082
|
}
|
|
1081
1083
|
keyNode = String(keyNode);
|
|
1082
1084
|
if (_result === null) {
|
|
1083
1085
|
_result = {};
|
|
1084
1086
|
}
|
|
1085
|
-
if (keyTag ===
|
|
1087
|
+
if (keyTag === 'tag:yaml.org,2002:merge') {
|
|
1086
1088
|
if (Array.isArray(valueNode)) {
|
|
1087
1089
|
for(index = 0, quantity = valueNode.length; index < quantity; index += 1){
|
|
1088
1090
|
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
@@ -1095,10 +1097,10 @@ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valu
|
|
|
1095
1097
|
state.line = startLine || state.line;
|
|
1096
1098
|
state.lineStart = startLineStart || state.lineStart;
|
|
1097
1099
|
state.position = startPos || state.position;
|
|
1098
|
-
throwError(state,
|
|
1100
|
+
throwError(state, 'duplicated mapping key');
|
|
1099
1101
|
}
|
|
1100
1102
|
// used for this specific key only because Object.defineProperty is slow
|
|
1101
|
-
if (keyNode ===
|
|
1103
|
+
if (keyNode === '__proto__') {
|
|
1102
1104
|
Object.defineProperty(_result, keyNode, {
|
|
1103
1105
|
configurable: true,
|
|
1104
1106
|
enumerable: true,
|
|
@@ -1123,7 +1125,7 @@ function readLineBreak(state) {
|
|
|
1123
1125
|
state.position++;
|
|
1124
1126
|
}
|
|
1125
1127
|
} else {
|
|
1126
|
-
throwError(state,
|
|
1128
|
+
throwError(state, 'a line break is expected');
|
|
1127
1129
|
}
|
|
1128
1130
|
state.line += 1;
|
|
1129
1131
|
state.lineStart = state.position;
|
|
@@ -1157,7 +1159,7 @@ function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
|
1157
1159
|
}
|
|
1158
1160
|
}
|
|
1159
1161
|
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1160
|
-
throwWarning(state,
|
|
1162
|
+
throwWarning(state, 'deficient indentation');
|
|
1161
1163
|
}
|
|
1162
1164
|
return lineBreaks;
|
|
1163
1165
|
}
|
|
@@ -1177,9 +1179,9 @@ function testDocumentSeparator(state) {
|
|
|
1177
1179
|
}
|
|
1178
1180
|
function writeFoldedLines(state, count) {
|
|
1179
1181
|
if (count === 1) {
|
|
1180
|
-
state.result +=
|
|
1182
|
+
state.result += ' ';
|
|
1181
1183
|
} else if (count > 1) {
|
|
1182
|
-
state.result += common.repeat(
|
|
1184
|
+
state.result += common.repeat('\n', count - 1);
|
|
1183
1185
|
}
|
|
1184
1186
|
}
|
|
1185
1187
|
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
@@ -1194,8 +1196,8 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
|
1194
1196
|
return false;
|
|
1195
1197
|
}
|
|
1196
1198
|
}
|
|
1197
|
-
state.kind =
|
|
1198
|
-
state.result =
|
|
1199
|
+
state.kind = 'scalar';
|
|
1200
|
+
state.result = '';
|
|
1199
1201
|
captureStart = captureEnd = state.position;
|
|
1200
1202
|
hasPendingContent = false;
|
|
1201
1203
|
while(ch !== 0){
|
|
@@ -1253,8 +1255,8 @@ function readSingleQuotedScalar(state, nodeIndent) {
|
|
|
1253
1255
|
if (ch !== 0x27 /* ' */ ) {
|
|
1254
1256
|
return false;
|
|
1255
1257
|
}
|
|
1256
|
-
state.kind =
|
|
1257
|
-
state.result =
|
|
1258
|
+
state.kind = 'scalar';
|
|
1259
|
+
state.result = '';
|
|
1258
1260
|
state.position++;
|
|
1259
1261
|
captureStart = captureEnd = state.position;
|
|
1260
1262
|
while((ch = state.input.charCodeAt(state.position)) !== 0){
|
|
@@ -1273,13 +1275,13 @@ function readSingleQuotedScalar(state, nodeIndent) {
|
|
|
1273
1275
|
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1274
1276
|
captureStart = captureEnd = state.position;
|
|
1275
1277
|
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1276
|
-
throwError(state,
|
|
1278
|
+
throwError(state, 'unexpected end of the document within a single quoted scalar');
|
|
1277
1279
|
} else {
|
|
1278
1280
|
state.position++;
|
|
1279
1281
|
captureEnd = state.position;
|
|
1280
1282
|
}
|
|
1281
1283
|
}
|
|
1282
|
-
throwError(state,
|
|
1284
|
+
throwError(state, 'unexpected end of the stream within a single quoted scalar');
|
|
1283
1285
|
}
|
|
1284
1286
|
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1285
1287
|
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
@@ -1287,8 +1289,8 @@ function readDoubleQuotedScalar(state, nodeIndent) {
|
|
|
1287
1289
|
if (ch !== 0x22 /* " */ ) {
|
|
1288
1290
|
return false;
|
|
1289
1291
|
}
|
|
1290
|
-
state.kind =
|
|
1291
|
-
state.result =
|
|
1292
|
+
state.kind = 'scalar';
|
|
1293
|
+
state.result = '';
|
|
1292
1294
|
state.position++;
|
|
1293
1295
|
captureStart = captureEnd = state.position;
|
|
1294
1296
|
while((ch = state.input.charCodeAt(state.position)) !== 0){
|
|
@@ -1313,13 +1315,13 @@ function readDoubleQuotedScalar(state, nodeIndent) {
|
|
|
1313
1315
|
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1314
1316
|
hexResult = (hexResult << 4) + tmp;
|
|
1315
1317
|
} else {
|
|
1316
|
-
throwError(state,
|
|
1318
|
+
throwError(state, 'expected hexadecimal character');
|
|
1317
1319
|
}
|
|
1318
1320
|
}
|
|
1319
1321
|
state.result += charFromCodepoint(hexResult);
|
|
1320
1322
|
state.position++;
|
|
1321
1323
|
} else {
|
|
1322
|
-
throwError(state,
|
|
1324
|
+
throwError(state, 'unknown escape sequence');
|
|
1323
1325
|
}
|
|
1324
1326
|
captureStart = captureEnd = state.position;
|
|
1325
1327
|
} else if (is_EOL(ch)) {
|
|
@@ -1327,13 +1329,13 @@ function readDoubleQuotedScalar(state, nodeIndent) {
|
|
|
1327
1329
|
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1328
1330
|
captureStart = captureEnd = state.position;
|
|
1329
1331
|
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1330
|
-
throwError(state,
|
|
1332
|
+
throwError(state, 'unexpected end of the document within a double quoted scalar');
|
|
1331
1333
|
} else {
|
|
1332
1334
|
state.position++;
|
|
1333
1335
|
captureEnd = state.position;
|
|
1334
1336
|
}
|
|
1335
1337
|
}
|
|
1336
|
-
throwError(state,
|
|
1338
|
+
throwError(state, 'unexpected end of the stream within a double quoted scalar');
|
|
1337
1339
|
}
|
|
1338
1340
|
function readFlowCollection(state, nodeIndent) {
|
|
1339
1341
|
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
@@ -1360,11 +1362,11 @@ function readFlowCollection(state, nodeIndent) {
|
|
|
1360
1362
|
state.position++;
|
|
1361
1363
|
state.tag = _tag;
|
|
1362
1364
|
state.anchor = _anchor;
|
|
1363
|
-
state.kind = isMapping ?
|
|
1365
|
+
state.kind = isMapping ? 'mapping' : 'sequence';
|
|
1364
1366
|
state.result = _result;
|
|
1365
1367
|
return true;
|
|
1366
1368
|
} else if (!readNext) {
|
|
1367
|
-
throwError(state,
|
|
1369
|
+
throwError(state, 'missed comma between flow collection entries');
|
|
1368
1370
|
} else if (ch === 0x2C /* , */ ) {
|
|
1369
1371
|
// "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4
|
|
1370
1372
|
throwError(state, "expected the node content, but found ','");
|
|
@@ -1410,7 +1412,7 @@ function readFlowCollection(state, nodeIndent) {
|
|
|
1410
1412
|
readNext = false;
|
|
1411
1413
|
}
|
|
1412
1414
|
}
|
|
1413
|
-
throwError(state,
|
|
1415
|
+
throwError(state, 'unexpected end of the stream within a flow collection');
|
|
1414
1416
|
}
|
|
1415
1417
|
function readBlockScalar(state, nodeIndent) {
|
|
1416
1418
|
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
@@ -1422,24 +1424,24 @@ function readBlockScalar(state, nodeIndent) {
|
|
|
1422
1424
|
} else {
|
|
1423
1425
|
return false;
|
|
1424
1426
|
}
|
|
1425
|
-
state.kind =
|
|
1426
|
-
state.result =
|
|
1427
|
+
state.kind = 'scalar';
|
|
1428
|
+
state.result = '';
|
|
1427
1429
|
while(ch !== 0){
|
|
1428
1430
|
ch = state.input.charCodeAt(++state.position);
|
|
1429
1431
|
if (ch === 0x2B /* + */ || ch === 0x2D /* - */ ) {
|
|
1430
1432
|
if (CHOMPING_CLIP === chomping) {
|
|
1431
1433
|
chomping = ch === 0x2B /* + */ ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1432
1434
|
} else {
|
|
1433
|
-
throwError(state,
|
|
1435
|
+
throwError(state, 'repeat of a chomping mode identifier');
|
|
1434
1436
|
}
|
|
1435
1437
|
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1436
1438
|
if (tmp === 0) {
|
|
1437
|
-
throwError(state,
|
|
1439
|
+
throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
|
|
1438
1440
|
} else if (!detectedIndent) {
|
|
1439
1441
|
textIndent = nodeIndent + tmp - 1;
|
|
1440
1442
|
detectedIndent = true;
|
|
1441
1443
|
} else {
|
|
1442
|
-
throwError(state,
|
|
1444
|
+
throwError(state, 'repeat of an indentation width identifier');
|
|
1443
1445
|
}
|
|
1444
1446
|
} else {
|
|
1445
1447
|
break;
|
|
@@ -1474,10 +1476,10 @@ function readBlockScalar(state, nodeIndent) {
|
|
|
1474
1476
|
if (state.lineIndent < textIndent) {
|
|
1475
1477
|
// Perform the chomping.
|
|
1476
1478
|
if (chomping === CHOMPING_KEEP) {
|
|
1477
|
-
state.result += common.repeat(
|
|
1479
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
|
1478
1480
|
} else if (chomping === CHOMPING_CLIP) {
|
|
1479
1481
|
if (didReadContent) {
|
|
1480
|
-
state.result +=
|
|
1482
|
+
state.result += '\n';
|
|
1481
1483
|
}
|
|
1482
1484
|
}
|
|
1483
1485
|
break;
|
|
@@ -1488,24 +1490,24 @@ function readBlockScalar(state, nodeIndent) {
|
|
|
1488
1490
|
if (is_WHITE_SPACE(ch)) {
|
|
1489
1491
|
atMoreIndented = true;
|
|
1490
1492
|
// except for the first content line (cf. Example 8.1)
|
|
1491
|
-
state.result += common.repeat(
|
|
1493
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
|
1492
1494
|
// End of more-indented block.
|
|
1493
1495
|
} else if (atMoreIndented) {
|
|
1494
1496
|
atMoreIndented = false;
|
|
1495
|
-
state.result += common.repeat(
|
|
1497
|
+
state.result += common.repeat('\n', emptyLines + 1);
|
|
1496
1498
|
// Just one line break - perceive as the same line.
|
|
1497
1499
|
} else if (emptyLines === 0) {
|
|
1498
1500
|
if (didReadContent) {
|
|
1499
|
-
state.result +=
|
|
1501
|
+
state.result += ' ';
|
|
1500
1502
|
}
|
|
1501
1503
|
// Several line breaks - perceive as different lines.
|
|
1502
1504
|
} else {
|
|
1503
|
-
state.result += common.repeat(
|
|
1505
|
+
state.result += common.repeat('\n', emptyLines);
|
|
1504
1506
|
}
|
|
1505
1507
|
// Literal style: just add exact number of line breaks between content lines.
|
|
1506
1508
|
} else {
|
|
1507
1509
|
// Keep all line breaks except the header line break.
|
|
1508
|
-
state.result += common.repeat(
|
|
1510
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
|
1509
1511
|
}
|
|
1510
1512
|
didReadContent = true;
|
|
1511
1513
|
detectedIndent = true;
|
|
@@ -1530,7 +1532,7 @@ function readBlockSequence(state, nodeIndent) {
|
|
|
1530
1532
|
while(ch !== 0){
|
|
1531
1533
|
if (state.firstTabInLine !== -1) {
|
|
1532
1534
|
state.position = state.firstTabInLine;
|
|
1533
|
-
throwError(state,
|
|
1535
|
+
throwError(state, 'tab characters must not be used in indentation');
|
|
1534
1536
|
}
|
|
1535
1537
|
if (ch !== 0x2D /* - */ ) {
|
|
1536
1538
|
break;
|
|
@@ -1554,7 +1556,7 @@ function readBlockSequence(state, nodeIndent) {
|
|
|
1554
1556
|
skipSeparationSpace(state, true, -1);
|
|
1555
1557
|
ch = state.input.charCodeAt(state.position);
|
|
1556
1558
|
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1557
|
-
throwError(state,
|
|
1559
|
+
throwError(state, 'bad indentation of a sequence entry');
|
|
1558
1560
|
} else if (state.lineIndent < nodeIndent) {
|
|
1559
1561
|
break;
|
|
1560
1562
|
}
|
|
@@ -1562,7 +1564,7 @@ function readBlockSequence(state, nodeIndent) {
|
|
|
1562
1564
|
if (detected) {
|
|
1563
1565
|
state.tag = _tag;
|
|
1564
1566
|
state.anchor = _anchor;
|
|
1565
|
-
state.kind =
|
|
1567
|
+
state.kind = 'sequence';
|
|
1566
1568
|
state.result = _result;
|
|
1567
1569
|
return true;
|
|
1568
1570
|
}
|
|
@@ -1580,7 +1582,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
|
1580
1582
|
while(ch !== 0){
|
|
1581
1583
|
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1582
1584
|
state.position = state.firstTabInLine;
|
|
1583
|
-
throwError(state,
|
|
1585
|
+
throwError(state, 'tab characters must not be used in indentation');
|
|
1584
1586
|
}
|
|
1585
1587
|
following = state.input.charCodeAt(state.position + 1);
|
|
1586
1588
|
_line = state.line; // Save the current line.
|
|
@@ -1602,7 +1604,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
|
1602
1604
|
atExplicitKey = false;
|
|
1603
1605
|
allowCompact = true;
|
|
1604
1606
|
} else {
|
|
1605
|
-
throwError(state,
|
|
1607
|
+
throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
|
|
1606
1608
|
}
|
|
1607
1609
|
state.position += 1;
|
|
1608
1610
|
ch = following;
|
|
@@ -1624,7 +1626,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
|
1624
1626
|
if (ch === 0x3A /* : */ ) {
|
|
1625
1627
|
ch = state.input.charCodeAt(++state.position);
|
|
1626
1628
|
if (!is_WS_OR_EOL(ch)) {
|
|
1627
|
-
throwError(state,
|
|
1629
|
+
throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
|
|
1628
1630
|
}
|
|
1629
1631
|
if (atExplicitKey) {
|
|
1630
1632
|
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
@@ -1636,14 +1638,14 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
|
1636
1638
|
keyTag = state.tag;
|
|
1637
1639
|
keyNode = state.result;
|
|
1638
1640
|
} else if (detected) {
|
|
1639
|
-
throwError(state,
|
|
1641
|
+
throwError(state, 'can not read an implicit mapping pair; a colon is missed');
|
|
1640
1642
|
} else {
|
|
1641
1643
|
state.tag = _tag;
|
|
1642
1644
|
state.anchor = _anchor;
|
|
1643
1645
|
return true; // Keep the result of `composeNode`.
|
|
1644
1646
|
}
|
|
1645
1647
|
} else if (detected) {
|
|
1646
|
-
throwError(state,
|
|
1648
|
+
throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
|
|
1647
1649
|
} else {
|
|
1648
1650
|
state.tag = _tag;
|
|
1649
1651
|
state.anchor = _anchor;
|
|
@@ -1674,7 +1676,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
|
1674
1676
|
ch = state.input.charCodeAt(state.position);
|
|
1675
1677
|
}
|
|
1676
1678
|
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1677
|
-
throwError(state,
|
|
1679
|
+
throwError(state, 'bad indentation of a mapping entry');
|
|
1678
1680
|
} else if (state.lineIndent < nodeIndent) {
|
|
1679
1681
|
break;
|
|
1680
1682
|
}
|
|
@@ -1690,7 +1692,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
|
1690
1692
|
if (detected) {
|
|
1691
1693
|
state.tag = _tag;
|
|
1692
1694
|
state.anchor = _anchor;
|
|
1693
|
-
state.kind =
|
|
1695
|
+
state.kind = 'mapping';
|
|
1694
1696
|
state.result = _result;
|
|
1695
1697
|
}
|
|
1696
1698
|
return detected;
|
|
@@ -1700,7 +1702,7 @@ function readTagProperty(state) {
|
|
|
1700
1702
|
ch = state.input.charCodeAt(state.position);
|
|
1701
1703
|
if (ch !== 0x21 /* ! */ ) return false;
|
|
1702
1704
|
if (state.tag !== null) {
|
|
1703
|
-
throwError(state,
|
|
1705
|
+
throwError(state, 'duplication of a tag property');
|
|
1704
1706
|
}
|
|
1705
1707
|
ch = state.input.charCodeAt(++state.position);
|
|
1706
1708
|
if (ch === 0x3C /* < */ ) {
|
|
@@ -1708,10 +1710,10 @@ function readTagProperty(state) {
|
|
|
1708
1710
|
ch = state.input.charCodeAt(++state.position);
|
|
1709
1711
|
} else if (ch === 0x21 /* ! */ ) {
|
|
1710
1712
|
isNamed = true;
|
|
1711
|
-
tagHandle =
|
|
1713
|
+
tagHandle = '!!';
|
|
1712
1714
|
ch = state.input.charCodeAt(++state.position);
|
|
1713
1715
|
} else {
|
|
1714
|
-
tagHandle =
|
|
1716
|
+
tagHandle = '!';
|
|
1715
1717
|
}
|
|
1716
1718
|
_position = state.position;
|
|
1717
1719
|
if (isVerbatim) {
|
|
@@ -1722,7 +1724,7 @@ function readTagProperty(state) {
|
|
|
1722
1724
|
tagName = state.input.slice(_position, state.position);
|
|
1723
1725
|
ch = state.input.charCodeAt(++state.position);
|
|
1724
1726
|
} else {
|
|
1725
|
-
throwError(state,
|
|
1727
|
+
throwError(state, 'unexpected end of the stream within a verbatim tag');
|
|
1726
1728
|
}
|
|
1727
1729
|
} else {
|
|
1728
1730
|
while(ch !== 0 && !is_WS_OR_EOL(ch)){
|
|
@@ -1730,37 +1732,37 @@ function readTagProperty(state) {
|
|
|
1730
1732
|
if (!isNamed) {
|
|
1731
1733
|
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
1732
1734
|
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1733
|
-
throwError(state,
|
|
1735
|
+
throwError(state, 'named tag handle cannot contain such characters');
|
|
1734
1736
|
}
|
|
1735
1737
|
isNamed = true;
|
|
1736
1738
|
_position = state.position + 1;
|
|
1737
1739
|
} else {
|
|
1738
|
-
throwError(state,
|
|
1740
|
+
throwError(state, 'tag suffix cannot contain exclamation marks');
|
|
1739
1741
|
}
|
|
1740
1742
|
}
|
|
1741
1743
|
ch = state.input.charCodeAt(++state.position);
|
|
1742
1744
|
}
|
|
1743
1745
|
tagName = state.input.slice(_position, state.position);
|
|
1744
1746
|
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1745
|
-
throwError(state,
|
|
1747
|
+
throwError(state, 'tag suffix cannot contain flow indicator characters');
|
|
1746
1748
|
}
|
|
1747
1749
|
}
|
|
1748
1750
|
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
1749
|
-
throwError(state,
|
|
1751
|
+
throwError(state, 'tag name cannot contain such characters: ' + tagName);
|
|
1750
1752
|
}
|
|
1751
1753
|
try {
|
|
1752
1754
|
tagName = decodeURIComponent(tagName);
|
|
1753
1755
|
} catch (err) {
|
|
1754
|
-
throwError(state,
|
|
1756
|
+
throwError(state, 'tag name is malformed: ' + tagName);
|
|
1755
1757
|
}
|
|
1756
1758
|
if (isVerbatim) {
|
|
1757
1759
|
state.tag = tagName;
|
|
1758
1760
|
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
1759
1761
|
state.tag = state.tagMap[tagHandle] + tagName;
|
|
1760
|
-
} else if (tagHandle ===
|
|
1761
|
-
state.tag =
|
|
1762
|
-
} else if (tagHandle ===
|
|
1763
|
-
state.tag =
|
|
1762
|
+
} else if (tagHandle === '!') {
|
|
1763
|
+
state.tag = '!' + tagName;
|
|
1764
|
+
} else if (tagHandle === '!!') {
|
|
1765
|
+
state.tag = 'tag:yaml.org,2002:' + tagName;
|
|
1764
1766
|
} else {
|
|
1765
1767
|
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
1766
1768
|
}
|
|
@@ -1771,7 +1773,7 @@ function readAnchorProperty(state) {
|
|
|
1771
1773
|
ch = state.input.charCodeAt(state.position);
|
|
1772
1774
|
if (ch !== 0x26 /* & */ ) return false;
|
|
1773
1775
|
if (state.anchor !== null) {
|
|
1774
|
-
throwError(state,
|
|
1776
|
+
throwError(state, 'duplication of an anchor property');
|
|
1775
1777
|
}
|
|
1776
1778
|
ch = state.input.charCodeAt(++state.position);
|
|
1777
1779
|
_position = state.position;
|
|
@@ -1779,7 +1781,7 @@ function readAnchorProperty(state) {
|
|
|
1779
1781
|
ch = state.input.charCodeAt(++state.position);
|
|
1780
1782
|
}
|
|
1781
1783
|
if (state.position === _position) {
|
|
1782
|
-
throwError(state,
|
|
1784
|
+
throwError(state, 'name of an anchor node must contain at least one character');
|
|
1783
1785
|
}
|
|
1784
1786
|
state.anchor = state.input.slice(_position, state.position);
|
|
1785
1787
|
return true;
|
|
@@ -1794,7 +1796,7 @@ function readAlias(state) {
|
|
|
1794
1796
|
ch = state.input.charCodeAt(++state.position);
|
|
1795
1797
|
}
|
|
1796
1798
|
if (state.position === _position) {
|
|
1797
|
-
throwError(state,
|
|
1799
|
+
throwError(state, 'name of an alias node must contain at least one character');
|
|
1798
1800
|
}
|
|
1799
1801
|
alias = state.input.slice(_position, state.position);
|
|
1800
1802
|
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
@@ -1807,7 +1809,7 @@ function readAlias(state) {
|
|
|
1807
1809
|
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
1808
1810
|
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type, flowIndent, blockIndent;
|
|
1809
1811
|
if (state.listener !== null) {
|
|
1810
|
-
state.listener(
|
|
1812
|
+
state.listener('open', state);
|
|
1811
1813
|
}
|
|
1812
1814
|
state.tag = null;
|
|
1813
1815
|
state.anchor = null;
|
|
@@ -1862,12 +1864,12 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
|
|
|
1862
1864
|
} else if (readAlias(state)) {
|
|
1863
1865
|
hasContent = true;
|
|
1864
1866
|
if (state.tag !== null || state.anchor !== null) {
|
|
1865
|
-
throwError(state,
|
|
1867
|
+
throwError(state, 'alias node should not have any properties');
|
|
1866
1868
|
}
|
|
1867
1869
|
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
1868
1870
|
hasContent = true;
|
|
1869
1871
|
if (state.tag === null) {
|
|
1870
|
-
state.tag =
|
|
1872
|
+
state.tag = '?';
|
|
1871
1873
|
}
|
|
1872
1874
|
}
|
|
1873
1875
|
if (state.anchor !== null) {
|
|
@@ -1884,14 +1886,14 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
|
|
|
1884
1886
|
if (state.anchor !== null) {
|
|
1885
1887
|
state.anchorMap[state.anchor] = state.result;
|
|
1886
1888
|
}
|
|
1887
|
-
} else if (state.tag ===
|
|
1889
|
+
} else if (state.tag === '?') {
|
|
1888
1890
|
// Implicit resolving is not allowed for non-scalar types, and '?'
|
|
1889
1891
|
// non-specific tag is only automatically assigned to plain scalars.
|
|
1890
1892
|
//
|
|
1891
1893
|
// We only need to check kind conformity in case user explicitly assigns '?'
|
|
1892
1894
|
// tag, for example like this: "!<?> [0]"
|
|
1893
1895
|
//
|
|
1894
|
-
if (state.result !== null && state.kind !==
|
|
1896
|
+
if (state.result !== null && state.kind !== 'scalar') {
|
|
1895
1897
|
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
1896
1898
|
}
|
|
1897
1899
|
for(typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1){
|
|
@@ -1905,13 +1907,13 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
|
|
|
1905
1907
|
break;
|
|
1906
1908
|
}
|
|
1907
1909
|
}
|
|
1908
|
-
} else if (state.tag !==
|
|
1909
|
-
if (_hasOwnProperty$1.call(state.typeMap[state.kind ||
|
|
1910
|
-
type = state.typeMap[state.kind ||
|
|
1910
|
+
} else if (state.tag !== '!') {
|
|
1911
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
|
|
1912
|
+
type = state.typeMap[state.kind || 'fallback'][state.tag];
|
|
1911
1913
|
} else {
|
|
1912
1914
|
// looking for multi type
|
|
1913
1915
|
type = null;
|
|
1914
|
-
typeList = state.typeMap.multi[state.kind ||
|
|
1916
|
+
typeList = state.typeMap.multi[state.kind || 'fallback'];
|
|
1915
1917
|
for(typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1){
|
|
1916
1918
|
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
1917
1919
|
type = typeList[typeIndex];
|
|
@@ -1920,13 +1922,13 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
|
|
|
1920
1922
|
}
|
|
1921
1923
|
}
|
|
1922
1924
|
if (!type) {
|
|
1923
|
-
throwError(state,
|
|
1925
|
+
throwError(state, 'unknown tag !<' + state.tag + '>');
|
|
1924
1926
|
}
|
|
1925
1927
|
if (state.result !== null && type.kind !== state.kind) {
|
|
1926
|
-
throwError(state,
|
|
1928
|
+
throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
|
1927
1929
|
}
|
|
1928
1930
|
if (!type.resolve(state.result, state.tag)) {
|
|
1929
|
-
throwError(state,
|
|
1931
|
+
throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
|
|
1930
1932
|
} else {
|
|
1931
1933
|
state.result = type.construct(state.result, state.tag);
|
|
1932
1934
|
if (state.anchor !== null) {
|
|
@@ -1935,7 +1937,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
|
|
|
1935
1937
|
}
|
|
1936
1938
|
}
|
|
1937
1939
|
if (state.listener !== null) {
|
|
1938
|
-
state.listener(
|
|
1940
|
+
state.listener('close', state);
|
|
1939
1941
|
}
|
|
1940
1942
|
return state.tag !== null || state.anchor !== null || hasContent;
|
|
1941
1943
|
}
|
|
@@ -1960,7 +1962,7 @@ function readDocument(state) {
|
|
|
1960
1962
|
directiveName = state.input.slice(_position, state.position);
|
|
1961
1963
|
directiveArgs = [];
|
|
1962
1964
|
if (directiveName.length < 1) {
|
|
1963
|
-
throwError(state,
|
|
1965
|
+
throwError(state, 'directive name must not be less than one character in length');
|
|
1964
1966
|
}
|
|
1965
1967
|
while(ch !== 0){
|
|
1966
1968
|
while(is_WHITE_SPACE(ch)){
|
|
@@ -1991,12 +1993,12 @@ function readDocument(state) {
|
|
|
1991
1993
|
state.position += 3;
|
|
1992
1994
|
skipSeparationSpace(state, true, -1);
|
|
1993
1995
|
} else if (hasDirectives) {
|
|
1994
|
-
throwError(state,
|
|
1996
|
+
throwError(state, 'directives end mark is expected');
|
|
1995
1997
|
}
|
|
1996
1998
|
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
1997
1999
|
skipSeparationSpace(state, true, -1);
|
|
1998
2000
|
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
1999
|
-
throwWarning(state,
|
|
2001
|
+
throwWarning(state, 'non-ASCII line breaks are interpreted as content');
|
|
2000
2002
|
}
|
|
2001
2003
|
state.documents.push(state.result);
|
|
2002
2004
|
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
@@ -2007,7 +2009,7 @@ function readDocument(state) {
|
|
|
2007
2009
|
return;
|
|
2008
2010
|
}
|
|
2009
2011
|
if (state.position < state.length - 1) {
|
|
2010
|
-
throwError(state,
|
|
2012
|
+
throwError(state, 'end of the stream or a document separator is expected');
|
|
2011
2013
|
} else {
|
|
2012
2014
|
return;
|
|
2013
2015
|
}
|
|
@@ -2018,7 +2020,7 @@ function loadDocuments(input, options) {
|
|
|
2018
2020
|
if (input.length !== 0) {
|
|
2019
2021
|
// Add tailing `\n` if not exists
|
|
2020
2022
|
if (input.charCodeAt(input.length - 1) !== 0x0A /* LF */ && input.charCodeAt(input.length - 1) !== 0x0D /* CR */ ) {
|
|
2021
|
-
input +=
|
|
2023
|
+
input += '\n';
|
|
2022
2024
|
}
|
|
2023
2025
|
// Strip BOM
|
|
2024
2026
|
if (input.charCodeAt(0) === 0xFEFF) {
|
|
@@ -2026,13 +2028,13 @@ function loadDocuments(input, options) {
|
|
|
2026
2028
|
}
|
|
2027
2029
|
}
|
|
2028
2030
|
var state = new State$1(input, options);
|
|
2029
|
-
var nullpos = input.indexOf(
|
|
2031
|
+
var nullpos = input.indexOf('\0');
|
|
2030
2032
|
if (nullpos !== -1) {
|
|
2031
2033
|
state.position = nullpos;
|
|
2032
|
-
throwError(state,
|
|
2034
|
+
throwError(state, 'null byte is not allowed in input');
|
|
2033
2035
|
}
|
|
2034
2036
|
// Use 0 as string terminator. That significantly simplifies bounds check.
|
|
2035
|
-
state.input +=
|
|
2037
|
+
state.input += '\0';
|
|
2036
2038
|
while(state.input.charCodeAt(state.position) === 0x20 /* Space */ ){
|
|
2037
2039
|
state.lineIndent += 1;
|
|
2038
2040
|
state.position += 1;
|
|
@@ -2042,19 +2044,6 @@ function loadDocuments(input, options) {
|
|
|
2042
2044
|
}
|
|
2043
2045
|
return state.documents;
|
|
2044
2046
|
}
|
|
2045
|
-
function loadAll$1(input, iterator, options) {
|
|
2046
|
-
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2047
|
-
options = iterator;
|
|
2048
|
-
iterator = null;
|
|
2049
|
-
}
|
|
2050
|
-
var documents = loadDocuments(input, options);
|
|
2051
|
-
if (typeof iterator !== "function") {
|
|
2052
|
-
return documents;
|
|
2053
|
-
}
|
|
2054
|
-
for(var index = 0, length = documents.length; index < length; index += 1){
|
|
2055
|
-
iterator(documents[index]);
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
2047
|
function load$1(input, options) {
|
|
2059
2048
|
var documents = loadDocuments(input, options);
|
|
2060
2049
|
if (documents.length === 0) {
|
|
@@ -2062,12 +2051,10 @@ function load$1(input, options) {
|
|
|
2062
2051
|
} else if (documents.length === 1) {
|
|
2063
2052
|
return documents[0];
|
|
2064
2053
|
}
|
|
2065
|
-
throw new exception(
|
|
2054
|
+
throw new exception('expected a single document in the stream, but found more');
|
|
2066
2055
|
}
|
|
2067
|
-
var loadAll_1 = loadAll$1;
|
|
2068
2056
|
var load_1 = load$1;
|
|
2069
2057
|
var loader = {
|
|
2070
|
-
loadAll: loadAll_1,
|
|
2071
2058
|
load: load_1
|
|
2072
2059
|
};
|
|
2073
2060
|
/*eslint-disable no-use-before-define*/ var _toString = Object.prototype.toString;
|
|
@@ -2098,38 +2085,38 @@ var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
|
|
|
2098
2085
|
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
|
2099
2086
|
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
|
2100
2087
|
var ESCAPE_SEQUENCES = {};
|
|
2101
|
-
ESCAPE_SEQUENCES[0x00] =
|
|
2102
|
-
ESCAPE_SEQUENCES[0x07] =
|
|
2103
|
-
ESCAPE_SEQUENCES[0x08] =
|
|
2104
|
-
ESCAPE_SEQUENCES[0x09] =
|
|
2105
|
-
ESCAPE_SEQUENCES[0x0A] =
|
|
2106
|
-
ESCAPE_SEQUENCES[0x0B] =
|
|
2107
|
-
ESCAPE_SEQUENCES[0x0C] =
|
|
2108
|
-
ESCAPE_SEQUENCES[0x0D] =
|
|
2109
|
-
ESCAPE_SEQUENCES[0x1B] =
|
|
2088
|
+
ESCAPE_SEQUENCES[0x00] = '\\0';
|
|
2089
|
+
ESCAPE_SEQUENCES[0x07] = '\\a';
|
|
2090
|
+
ESCAPE_SEQUENCES[0x08] = '\\b';
|
|
2091
|
+
ESCAPE_SEQUENCES[0x09] = '\\t';
|
|
2092
|
+
ESCAPE_SEQUENCES[0x0A] = '\\n';
|
|
2093
|
+
ESCAPE_SEQUENCES[0x0B] = '\\v';
|
|
2094
|
+
ESCAPE_SEQUENCES[0x0C] = '\\f';
|
|
2095
|
+
ESCAPE_SEQUENCES[0x0D] = '\\r';
|
|
2096
|
+
ESCAPE_SEQUENCES[0x1B] = '\\e';
|
|
2110
2097
|
ESCAPE_SEQUENCES[0x22] = '\\"';
|
|
2111
|
-
ESCAPE_SEQUENCES[0x5C] =
|
|
2112
|
-
ESCAPE_SEQUENCES[0x85] =
|
|
2113
|
-
ESCAPE_SEQUENCES[0xA0] =
|
|
2114
|
-
ESCAPE_SEQUENCES[0x2028] =
|
|
2115
|
-
ESCAPE_SEQUENCES[0x2029] =
|
|
2098
|
+
ESCAPE_SEQUENCES[0x5C] = '\\\\';
|
|
2099
|
+
ESCAPE_SEQUENCES[0x85] = '\\N';
|
|
2100
|
+
ESCAPE_SEQUENCES[0xA0] = '\\_';
|
|
2101
|
+
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
|
2102
|
+
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
|
2116
2103
|
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2104
|
+
'y',
|
|
2105
|
+
'Y',
|
|
2106
|
+
'yes',
|
|
2107
|
+
'Yes',
|
|
2108
|
+
'YES',
|
|
2109
|
+
'on',
|
|
2110
|
+
'On',
|
|
2111
|
+
'ON',
|
|
2112
|
+
'n',
|
|
2113
|
+
'N',
|
|
2114
|
+
'no',
|
|
2115
|
+
'No',
|
|
2116
|
+
'NO',
|
|
2117
|
+
'off',
|
|
2118
|
+
'Off',
|
|
2119
|
+
'OFF'
|
|
2133
2120
|
];
|
|
2134
2121
|
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2135
2122
|
function compileStyleMap(schema, map) {
|
|
@@ -2140,10 +2127,10 @@ function compileStyleMap(schema, map) {
|
|
|
2140
2127
|
for(index = 0, length = keys.length; index < length; index += 1){
|
|
2141
2128
|
tag = keys[index];
|
|
2142
2129
|
style = String(map[tag]);
|
|
2143
|
-
if (tag.slice(0, 2) ===
|
|
2144
|
-
tag =
|
|
2130
|
+
if (tag.slice(0, 2) === '!!') {
|
|
2131
|
+
tag = 'tag:yaml.org,2002:' + tag.slice(2);
|
|
2145
2132
|
}
|
|
2146
|
-
type = schema.compiledTypeMap[
|
|
2133
|
+
type = schema.compiledTypeMap['fallback'][tag];
|
|
2147
2134
|
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
2148
2135
|
style = type.styleAliases[style];
|
|
2149
2136
|
}
|
|
@@ -2155,47 +2142,47 @@ function encodeHex(character) {
|
|
|
2155
2142
|
var string, handle, length;
|
|
2156
2143
|
string = character.toString(16).toUpperCase();
|
|
2157
2144
|
if (character <= 0xFF) {
|
|
2158
|
-
handle =
|
|
2145
|
+
handle = 'x';
|
|
2159
2146
|
length = 2;
|
|
2160
2147
|
} else if (character <= 0xFFFF) {
|
|
2161
|
-
handle =
|
|
2148
|
+
handle = 'u';
|
|
2162
2149
|
length = 4;
|
|
2163
2150
|
} else if (character <= 0xFFFFFFFF) {
|
|
2164
|
-
handle =
|
|
2151
|
+
handle = 'U';
|
|
2165
2152
|
length = 8;
|
|
2166
2153
|
} else {
|
|
2167
|
-
throw new exception(
|
|
2154
|
+
throw new exception('code point within a string may not be greater than 0xFFFFFFFF');
|
|
2168
2155
|
}
|
|
2169
|
-
return
|
|
2156
|
+
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
|
2170
2157
|
}
|
|
2171
2158
|
var QUOTING_TYPE_SINGLE = 1, QUOTING_TYPE_DOUBLE = 2;
|
|
2172
2159
|
function State(options) {
|
|
2173
|
-
this.schema = options[
|
|
2174
|
-
this.indent = Math.max(1, options[
|
|
2175
|
-
this.noArrayIndent = options[
|
|
2176
|
-
this.skipInvalid = options[
|
|
2177
|
-
this.flowLevel = common.isNothing(options[
|
|
2178
|
-
this.styleMap = compileStyleMap(this.schema, options[
|
|
2179
|
-
this.sortKeys = options[
|
|
2180
|
-
this.lineWidth = options[
|
|
2181
|
-
this.noRefs = options[
|
|
2182
|
-
this.noCompatMode = options[
|
|
2183
|
-
this.condenseFlow = options[
|
|
2184
|
-
this.quotingType = options[
|
|
2185
|
-
this.forceQuotes = options[
|
|
2186
|
-
this.replacer = typeof options[
|
|
2160
|
+
this.schema = options['schema'] || _default;
|
|
2161
|
+
this.indent = Math.max(1, options['indent'] || 2);
|
|
2162
|
+
this.noArrayIndent = options['noArrayIndent'] || false;
|
|
2163
|
+
this.skipInvalid = options['skipInvalid'] || false;
|
|
2164
|
+
this.flowLevel = common.isNothing(options['flowLevel']) ? -1 : options['flowLevel'];
|
|
2165
|
+
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
|
2166
|
+
this.sortKeys = options['sortKeys'] || false;
|
|
2167
|
+
this.lineWidth = options['lineWidth'] || 80;
|
|
2168
|
+
this.noRefs = options['noRefs'] || false;
|
|
2169
|
+
this.noCompatMode = options['noCompatMode'] || false;
|
|
2170
|
+
this.condenseFlow = options['condenseFlow'] || false;
|
|
2171
|
+
this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2172
|
+
this.forceQuotes = options['forceQuotes'] || false;
|
|
2173
|
+
this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null;
|
|
2187
2174
|
this.implicitTypes = this.schema.compiledImplicit;
|
|
2188
2175
|
this.explicitTypes = this.schema.compiledExplicit;
|
|
2189
2176
|
this.tag = null;
|
|
2190
|
-
this.result =
|
|
2177
|
+
this.result = '';
|
|
2191
2178
|
this.duplicates = [];
|
|
2192
2179
|
this.usedDuplicates = null;
|
|
2193
2180
|
}
|
|
2194
2181
|
// Indents every line in a string. Empty lines (\n only) are not indented.
|
|
2195
2182
|
function indentString(string, spaces) {
|
|
2196
|
-
var ind = common.repeat(
|
|
2183
|
+
var ind = common.repeat(' ', spaces), position = 0, next = -1, result = '', line, length = string.length;
|
|
2197
2184
|
while(position < length){
|
|
2198
|
-
next = string.indexOf(
|
|
2185
|
+
next = string.indexOf('\n', position);
|
|
2199
2186
|
if (next === -1) {
|
|
2200
2187
|
line = string.slice(position);
|
|
2201
2188
|
position = length;
|
|
@@ -2203,13 +2190,13 @@ function indentString(string, spaces) {
|
|
|
2203
2190
|
line = string.slice(position, next + 1);
|
|
2204
2191
|
position = next + 1;
|
|
2205
2192
|
}
|
|
2206
|
-
if (line.length && line !==
|
|
2193
|
+
if (line.length && line !== '\n') result += ind;
|
|
2207
2194
|
result += line;
|
|
2208
2195
|
}
|
|
2209
2196
|
return result;
|
|
2210
2197
|
}
|
|
2211
2198
|
function generateNextLine(state, level) {
|
|
2212
|
-
return
|
|
2199
|
+
return '\n' + common.repeat(' ', state.indent * level);
|
|
2213
2200
|
}
|
|
2214
2201
|
function testImplicitResolving(state, str) {
|
|
2215
2202
|
var index, length, type;
|
|
@@ -2325,7 +2312,7 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
|
|
|
2325
2312
|
// Check if any line can be folded.
|
|
2326
2313
|
if (shouldTrackWidth) {
|
|
2327
2314
|
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2328
|
-
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !==
|
|
2315
|
+
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ';
|
|
2329
2316
|
previousLineBreak = i;
|
|
2330
2317
|
}
|
|
2331
2318
|
} else if (!isPrintable(char)) {
|
|
@@ -2335,7 +2322,7 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
|
|
|
2335
2322
|
prevChar = char;
|
|
2336
2323
|
}
|
|
2337
2324
|
// in case the end is missing a \n
|
|
2338
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !==
|
|
2325
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ';
|
|
2339
2326
|
}
|
|
2340
2327
|
// Although every style can represent \n without escaping, prefer block styles
|
|
2341
2328
|
// for multiline, since they're more readable and they don't add empty lines.
|
|
@@ -2395,28 +2382,28 @@ function writeScalar(state, string, level, iskey, inblock) {
|
|
|
2395
2382
|
case STYLE_SINGLE:
|
|
2396
2383
|
return "'" + string.replace(/'/g, "''") + "'";
|
|
2397
2384
|
case STYLE_LITERAL:
|
|
2398
|
-
return
|
|
2385
|
+
return '|' + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2399
2386
|
case STYLE_FOLDED:
|
|
2400
|
-
return
|
|
2387
|
+
return '>' + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2401
2388
|
case STYLE_DOUBLE:
|
|
2402
2389
|
return '"' + escapeString(string) + '"';
|
|
2403
2390
|
default:
|
|
2404
|
-
throw new exception(
|
|
2391
|
+
throw new exception('impossible error: invalid scalar style');
|
|
2405
2392
|
}
|
|
2406
2393
|
}();
|
|
2407
2394
|
}
|
|
2408
2395
|
// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
|
|
2409
2396
|
function blockHeader(string, indentPerLevel) {
|
|
2410
|
-
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) :
|
|
2397
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
|
|
2411
2398
|
// note the special case: the string '\n' counts as a "trailing" empty line.
|
|
2412
|
-
var clip = string[string.length - 1] ===
|
|
2413
|
-
var keep = clip && (string[string.length - 2] ===
|
|
2414
|
-
var chomp = keep ?
|
|
2415
|
-
return indentIndicator + chomp +
|
|
2399
|
+
var clip = string[string.length - 1] === '\n';
|
|
2400
|
+
var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
|
|
2401
|
+
var chomp = keep ? '+' : clip ? '' : '-';
|
|
2402
|
+
return indentIndicator + chomp + '\n';
|
|
2416
2403
|
}
|
|
2417
2404
|
// (See the note for writeScalar.)
|
|
2418
2405
|
function dropEndingNewline(string) {
|
|
2419
|
-
return string[string.length - 1] ===
|
|
2406
|
+
return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
|
|
2420
2407
|
}
|
|
2421
2408
|
// Note: a long line without a suitable break point will exceed the width limit.
|
|
2422
2409
|
// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
|
|
@@ -2428,20 +2415,20 @@ function foldString(string, width) {
|
|
|
2428
2415
|
var lineRe = /(\n+)([^\n]*)/g;
|
|
2429
2416
|
// first line (possibly an empty line)
|
|
2430
2417
|
var result = function() {
|
|
2431
|
-
var nextLF = string.indexOf(
|
|
2418
|
+
var nextLF = string.indexOf('\n');
|
|
2432
2419
|
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2433
2420
|
lineRe.lastIndex = nextLF;
|
|
2434
2421
|
return foldLine(string.slice(0, nextLF), width);
|
|
2435
2422
|
}();
|
|
2436
2423
|
// If we haven't reached the first content line yet, don't add an extra \n.
|
|
2437
|
-
var prevMoreIndented = string[0] ===
|
|
2424
|
+
var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
|
|
2438
2425
|
var moreIndented;
|
|
2439
2426
|
// rest of the lines
|
|
2440
2427
|
var match;
|
|
2441
2428
|
while(match = lineRe.exec(string)){
|
|
2442
2429
|
var prefix = match[1], line = match[2];
|
|
2443
|
-
moreIndented = line[0] ===
|
|
2444
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !==
|
|
2430
|
+
moreIndented = line[0] === ' ';
|
|
2431
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== '' ? '\n' : '') + foldLine(line, width);
|
|
2445
2432
|
prevMoreIndented = moreIndented;
|
|
2446
2433
|
}
|
|
2447
2434
|
return result;
|
|
@@ -2451,13 +2438,13 @@ function foldString(string, width) {
|
|
|
2451
2438
|
// otherwise settles for the shortest line over the limit.
|
|
2452
2439
|
// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
|
|
2453
2440
|
function foldLine(line, width) {
|
|
2454
|
-
if (line ===
|
|
2441
|
+
if (line === '' || line[0] === ' ') return line;
|
|
2455
2442
|
// Since a more-indented line adds a \n, breaks can't be followed by a space.
|
|
2456
2443
|
var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
|
|
2457
2444
|
var match;
|
|
2458
2445
|
// start is an inclusive index. end, curr, and next are exclusive.
|
|
2459
2446
|
var start = 0, end, curr = 0, next = 0;
|
|
2460
|
-
var result =
|
|
2447
|
+
var result = '';
|
|
2461
2448
|
// Invariants: 0 <= start <= length-1.
|
|
2462
2449
|
// 0 <= curr <= next <= max(0, length-2). curr - start <= width.
|
|
2463
2450
|
// Inside the loop:
|
|
@@ -2467,7 +2454,7 @@ function foldLine(line, width) {
|
|
|
2467
2454
|
// maintain invariant: curr - start <= width
|
|
2468
2455
|
if (next - start > width) {
|
|
2469
2456
|
end = curr > start ? curr : next; // derive end <= length-2
|
|
2470
|
-
result +=
|
|
2457
|
+
result += '\n' + line.slice(start, end);
|
|
2471
2458
|
// skip the space that was output as \n
|
|
2472
2459
|
start = end + 1; // derive start <= length-1
|
|
2473
2460
|
}
|
|
@@ -2475,10 +2462,10 @@ function foldLine(line, width) {
|
|
|
2475
2462
|
}
|
|
2476
2463
|
// By the invariants, start <= length-1, so there is something left over.
|
|
2477
2464
|
// It is either the whole string or a part starting from non-whitespace.
|
|
2478
|
-
result +=
|
|
2465
|
+
result += '\n';
|
|
2479
2466
|
// Insert a break if the remainder is too long and there is a break available.
|
|
2480
2467
|
if (line.length - start > width && curr > start) {
|
|
2481
|
-
result += line.slice(start, curr) +
|
|
2468
|
+
result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
|
|
2482
2469
|
} else {
|
|
2483
2470
|
result += line.slice(start);
|
|
2484
2471
|
}
|
|
@@ -2486,7 +2473,7 @@ function foldLine(line, width) {
|
|
|
2486
2473
|
}
|
|
2487
2474
|
// Escapes a double-quoted string.
|
|
2488
2475
|
function escapeString(string) {
|
|
2489
|
-
var result =
|
|
2476
|
+
var result = '';
|
|
2490
2477
|
var char = 0;
|
|
2491
2478
|
var escapeSeq;
|
|
2492
2479
|
for(var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++){
|
|
@@ -2502,49 +2489,49 @@ function escapeString(string) {
|
|
|
2502
2489
|
return result;
|
|
2503
2490
|
}
|
|
2504
2491
|
function writeFlowSequence(state, level, object) {
|
|
2505
|
-
var _result =
|
|
2492
|
+
var _result = '', _tag = state.tag, index, length, value;
|
|
2506
2493
|
for(index = 0, length = object.length; index < length; index += 1){
|
|
2507
2494
|
value = object[index];
|
|
2508
2495
|
if (state.replacer) {
|
|
2509
2496
|
value = state.replacer.call(object, String(index), value);
|
|
2510
2497
|
}
|
|
2511
2498
|
// Write only valid elements, put null instead of invalid elements.
|
|
2512
|
-
if (writeNode(state, level, value, false, false) || typeof value ===
|
|
2513
|
-
if (_result !==
|
|
2499
|
+
if (writeNode(state, level, value, false, false) || typeof value === 'undefined' && writeNode(state, level, null, false, false)) {
|
|
2500
|
+
if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : '');
|
|
2514
2501
|
_result += state.dump;
|
|
2515
2502
|
}
|
|
2516
2503
|
}
|
|
2517
2504
|
state.tag = _tag;
|
|
2518
|
-
state.dump =
|
|
2505
|
+
state.dump = '[' + _result + ']';
|
|
2519
2506
|
}
|
|
2520
2507
|
function writeBlockSequence(state, level, object, compact) {
|
|
2521
|
-
var _result =
|
|
2508
|
+
var _result = '', _tag = state.tag, index, length, value;
|
|
2522
2509
|
for(index = 0, length = object.length; index < length; index += 1){
|
|
2523
2510
|
value = object[index];
|
|
2524
2511
|
if (state.replacer) {
|
|
2525
2512
|
value = state.replacer.call(object, String(index), value);
|
|
2526
2513
|
}
|
|
2527
2514
|
// Write only valid elements, put null instead of invalid elements.
|
|
2528
|
-
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value ===
|
|
2529
|
-
if (!compact || _result !==
|
|
2515
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === 'undefined' && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2516
|
+
if (!compact || _result !== '') {
|
|
2530
2517
|
_result += generateNextLine(state, level);
|
|
2531
2518
|
}
|
|
2532
2519
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2533
|
-
_result +=
|
|
2520
|
+
_result += '-';
|
|
2534
2521
|
} else {
|
|
2535
|
-
_result +=
|
|
2522
|
+
_result += '- ';
|
|
2536
2523
|
}
|
|
2537
2524
|
_result += state.dump;
|
|
2538
2525
|
}
|
|
2539
2526
|
}
|
|
2540
2527
|
state.tag = _tag;
|
|
2541
|
-
state.dump = _result ||
|
|
2528
|
+
state.dump = _result || '[]'; // Empty sequence if no valid values.
|
|
2542
2529
|
}
|
|
2543
2530
|
function writeFlowMapping(state, level, object) {
|
|
2544
|
-
var _result =
|
|
2531
|
+
var _result = '', _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2545
2532
|
for(index = 0, length = objectKeyList.length; index < length; index += 1){
|
|
2546
|
-
pairBuffer =
|
|
2547
|
-
if (_result !==
|
|
2533
|
+
pairBuffer = '';
|
|
2534
|
+
if (_result !== '') pairBuffer += ', ';
|
|
2548
2535
|
if (state.condenseFlow) pairBuffer += '"';
|
|
2549
2536
|
objectKey = objectKeyList[index];
|
|
2550
2537
|
objectValue = object[objectKey];
|
|
@@ -2554,8 +2541,8 @@ function writeFlowMapping(state, level, object) {
|
|
|
2554
2541
|
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2555
2542
|
continue; // Skip this pair because of invalid key;
|
|
2556
2543
|
}
|
|
2557
|
-
if (state.dump.length > 1024) pairBuffer +=
|
|
2558
|
-
pairBuffer += state.dump + (state.condenseFlow ? '"' :
|
|
2544
|
+
if (state.dump.length > 1024) pairBuffer += '? ';
|
|
2545
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
|
|
2559
2546
|
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2560
2547
|
continue; // Skip this pair because of invalid value.
|
|
2561
2548
|
}
|
|
@@ -2564,24 +2551,24 @@ function writeFlowMapping(state, level, object) {
|
|
|
2564
2551
|
_result += pairBuffer;
|
|
2565
2552
|
}
|
|
2566
2553
|
state.tag = _tag;
|
|
2567
|
-
state.dump =
|
|
2554
|
+
state.dump = '{' + _result + '}';
|
|
2568
2555
|
}
|
|
2569
2556
|
function writeBlockMapping(state, level, object, compact) {
|
|
2570
|
-
var _result =
|
|
2557
|
+
var _result = '', _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2571
2558
|
// Allow sorting keys so that the output file is deterministic
|
|
2572
2559
|
if (state.sortKeys === true) {
|
|
2573
2560
|
// Default sorting
|
|
2574
2561
|
objectKeyList.sort();
|
|
2575
|
-
} else if (typeof state.sortKeys ===
|
|
2562
|
+
} else if (typeof state.sortKeys === 'function') {
|
|
2576
2563
|
// Custom sort function
|
|
2577
2564
|
objectKeyList.sort(state.sortKeys);
|
|
2578
2565
|
} else if (state.sortKeys) {
|
|
2579
2566
|
// Something is wrong
|
|
2580
|
-
throw new exception(
|
|
2567
|
+
throw new exception('sortKeys must be a boolean or a function');
|
|
2581
2568
|
}
|
|
2582
2569
|
for(index = 0, length = objectKeyList.length; index < length; index += 1){
|
|
2583
|
-
pairBuffer =
|
|
2584
|
-
if (!compact || _result !==
|
|
2570
|
+
pairBuffer = '';
|
|
2571
|
+
if (!compact || _result !== '') {
|
|
2585
2572
|
pairBuffer += generateNextLine(state, level);
|
|
2586
2573
|
}
|
|
2587
2574
|
objectKey = objectKeyList[index];
|
|
@@ -2592,12 +2579,12 @@ function writeBlockMapping(state, level, object, compact) {
|
|
|
2592
2579
|
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2593
2580
|
continue; // Skip this pair because of invalid key.
|
|
2594
2581
|
}
|
|
2595
|
-
explicitPair = state.tag !== null && state.tag !==
|
|
2582
|
+
explicitPair = state.tag !== null && state.tag !== '?' || state.dump && state.dump.length > 1024;
|
|
2596
2583
|
if (explicitPair) {
|
|
2597
2584
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2598
|
-
pairBuffer +=
|
|
2585
|
+
pairBuffer += '?';
|
|
2599
2586
|
} else {
|
|
2600
|
-
pairBuffer +=
|
|
2587
|
+
pairBuffer += '? ';
|
|
2601
2588
|
}
|
|
2602
2589
|
}
|
|
2603
2590
|
pairBuffer += state.dump;
|
|
@@ -2608,23 +2595,23 @@ function writeBlockMapping(state, level, object, compact) {
|
|
|
2608
2595
|
continue; // Skip this pair because of invalid value.
|
|
2609
2596
|
}
|
|
2610
2597
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2611
|
-
pairBuffer +=
|
|
2598
|
+
pairBuffer += ':';
|
|
2612
2599
|
} else {
|
|
2613
|
-
pairBuffer +=
|
|
2600
|
+
pairBuffer += ': ';
|
|
2614
2601
|
}
|
|
2615
2602
|
pairBuffer += state.dump;
|
|
2616
2603
|
// Both key and value are valid.
|
|
2617
2604
|
_result += pairBuffer;
|
|
2618
2605
|
}
|
|
2619
2606
|
state.tag = _tag;
|
|
2620
|
-
state.dump = _result ||
|
|
2607
|
+
state.dump = _result || '{}'; // Empty mapping if no valid pairs.
|
|
2621
2608
|
}
|
|
2622
2609
|
function detectType(state, object, explicit) {
|
|
2623
2610
|
var _result, typeList, index, length, type, style;
|
|
2624
2611
|
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2625
2612
|
for(index = 0, length = typeList.length; index < length; index += 1){
|
|
2626
2613
|
type = typeList[index];
|
|
2627
|
-
if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "
|
|
2614
|
+
if ((type.instanceOf || type.predicate) && (!type.instanceOf || (typeof object === "undefined" ? "undefined" : _type_of(object)) === 'object' && _instanceof(object, type.instanceOf)) && (!type.predicate || type.predicate(object))) {
|
|
2628
2615
|
if (explicit) {
|
|
2629
2616
|
if (type.multi && type.representName) {
|
|
2630
2617
|
state.tag = type.representName(object);
|
|
@@ -2632,16 +2619,16 @@ function detectType(state, object, explicit) {
|
|
|
2632
2619
|
state.tag = type.tag;
|
|
2633
2620
|
}
|
|
2634
2621
|
} else {
|
|
2635
|
-
state.tag =
|
|
2622
|
+
state.tag = '?';
|
|
2636
2623
|
}
|
|
2637
2624
|
if (type.represent) {
|
|
2638
2625
|
style = state.styleMap[type.tag] || type.defaultStyle;
|
|
2639
|
-
if (_toString.call(type.represent) ===
|
|
2626
|
+
if (_toString.call(type.represent) === '[object Function]') {
|
|
2640
2627
|
_result = type.represent(object, style);
|
|
2641
2628
|
} else if (_hasOwnProperty.call(type.represent, style)) {
|
|
2642
2629
|
_result = type.represent[style](object, style);
|
|
2643
2630
|
} else {
|
|
2644
|
-
throw new exception(
|
|
2631
|
+
throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2645
2632
|
}
|
|
2646
2633
|
state.dump = _result;
|
|
2647
2634
|
}
|
|
@@ -2665,33 +2652,33 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
|
2665
2652
|
if (block) {
|
|
2666
2653
|
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2667
2654
|
}
|
|
2668
|
-
var objectOrArray = type ===
|
|
2655
|
+
var objectOrArray = type === '[object Object]' || type === '[object Array]', duplicateIndex, duplicate;
|
|
2669
2656
|
if (objectOrArray) {
|
|
2670
2657
|
duplicateIndex = state.duplicates.indexOf(object);
|
|
2671
2658
|
duplicate = duplicateIndex !== -1;
|
|
2672
2659
|
}
|
|
2673
|
-
if (state.tag !== null && state.tag !==
|
|
2660
|
+
if (state.tag !== null && state.tag !== '?' || duplicate || state.indent !== 2 && level > 0) {
|
|
2674
2661
|
compact = false;
|
|
2675
2662
|
}
|
|
2676
2663
|
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2677
|
-
state.dump =
|
|
2664
|
+
state.dump = '*ref_' + duplicateIndex;
|
|
2678
2665
|
} else {
|
|
2679
2666
|
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2680
2667
|
state.usedDuplicates[duplicateIndex] = true;
|
|
2681
2668
|
}
|
|
2682
|
-
if (type ===
|
|
2669
|
+
if (type === '[object Object]') {
|
|
2683
2670
|
if (block && Object.keys(state.dump).length !== 0) {
|
|
2684
2671
|
writeBlockMapping(state, level, state.dump, compact);
|
|
2685
2672
|
if (duplicate) {
|
|
2686
|
-
state.dump =
|
|
2673
|
+
state.dump = '&ref_' + duplicateIndex + state.dump;
|
|
2687
2674
|
}
|
|
2688
2675
|
} else {
|
|
2689
2676
|
writeFlowMapping(state, level, state.dump);
|
|
2690
2677
|
if (duplicate) {
|
|
2691
|
-
state.dump =
|
|
2678
|
+
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
|
2692
2679
|
}
|
|
2693
2680
|
}
|
|
2694
|
-
} else if (type ===
|
|
2681
|
+
} else if (type === '[object Array]') {
|
|
2695
2682
|
if (block && state.dump.length !== 0) {
|
|
2696
2683
|
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2697
2684
|
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
@@ -2699,25 +2686,25 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
|
2699
2686
|
writeBlockSequence(state, level, state.dump, compact);
|
|
2700
2687
|
}
|
|
2701
2688
|
if (duplicate) {
|
|
2702
|
-
state.dump =
|
|
2689
|
+
state.dump = '&ref_' + duplicateIndex + state.dump;
|
|
2703
2690
|
}
|
|
2704
2691
|
} else {
|
|
2705
2692
|
writeFlowSequence(state, level, state.dump);
|
|
2706
2693
|
if (duplicate) {
|
|
2707
|
-
state.dump =
|
|
2694
|
+
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
|
2708
2695
|
}
|
|
2709
2696
|
}
|
|
2710
|
-
} else if (type ===
|
|
2711
|
-
if (state.tag !==
|
|
2697
|
+
} else if (type === '[object String]') {
|
|
2698
|
+
if (state.tag !== '?') {
|
|
2712
2699
|
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2713
2700
|
}
|
|
2714
|
-
} else if (type ===
|
|
2701
|
+
} else if (type === '[object Undefined]') {
|
|
2715
2702
|
return false;
|
|
2716
2703
|
} else {
|
|
2717
2704
|
if (state.skipInvalid) return false;
|
|
2718
|
-
throw new exception(
|
|
2705
|
+
throw new exception('unacceptable kind of an object to dump ' + type);
|
|
2719
2706
|
}
|
|
2720
|
-
if (state.tag !== null && state.tag !==
|
|
2707
|
+
if (state.tag !== null && state.tag !== '?') {
|
|
2721
2708
|
// Need to encode all characters except those allowed by the spec:
|
|
2722
2709
|
//
|
|
2723
2710
|
// [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */
|
|
@@ -2731,15 +2718,15 @@ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
|
2731
2718
|
//
|
|
2732
2719
|
// Also need to encode '!' because it has special meaning (end of tag prefix).
|
|
2733
2720
|
//
|
|
2734
|
-
tagStr = encodeURI(state.tag[0] ===
|
|
2735
|
-
if (state.tag[0] ===
|
|
2736
|
-
tagStr =
|
|
2737
|
-
} else if (tagStr.slice(0, 18) ===
|
|
2738
|
-
tagStr =
|
|
2721
|
+
tagStr = encodeURI(state.tag[0] === '!' ? state.tag.slice(1) : state.tag).replace(/!/g, '%21');
|
|
2722
|
+
if (state.tag[0] === '!') {
|
|
2723
|
+
tagStr = '!' + tagStr;
|
|
2724
|
+
} else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') {
|
|
2725
|
+
tagStr = '!!' + tagStr.slice(18);
|
|
2739
2726
|
} else {
|
|
2740
|
-
tagStr =
|
|
2727
|
+
tagStr = '!<' + tagStr + '>';
|
|
2741
2728
|
}
|
|
2742
|
-
state.dump = tagStr +
|
|
2729
|
+
state.dump = tagStr + ' ' + state.dump;
|
|
2743
2730
|
}
|
|
2744
2731
|
}
|
|
2745
2732
|
return true;
|
|
@@ -2754,7 +2741,7 @@ function getDuplicateReferences(object, state) {
|
|
|
2754
2741
|
}
|
|
2755
2742
|
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2756
2743
|
var objectKeyList, index, length;
|
|
2757
|
-
if (object !== null && typeof object === "object
|
|
2744
|
+
if (object !== null && (typeof object === "undefined" ? "undefined" : _type_of(object)) === 'object') {
|
|
2758
2745
|
index = objects.indexOf(object);
|
|
2759
2746
|
if (index !== -1) {
|
|
2760
2747
|
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
@@ -2782,11 +2769,11 @@ function dump$1(input, options) {
|
|
|
2782
2769
|
var value = input;
|
|
2783
2770
|
if (state.replacer) {
|
|
2784
2771
|
value = state.replacer.call({
|
|
2785
|
-
|
|
2786
|
-
},
|
|
2772
|
+
'': value
|
|
2773
|
+
}, '', value);
|
|
2787
2774
|
}
|
|
2788
|
-
if (writeNode(state, 0, value, true, true)) return state.dump +
|
|
2789
|
-
return
|
|
2775
|
+
if (writeNode(state, 0, value, true, true)) return state.dump + '\n';
|
|
2776
|
+
return '';
|
|
2790
2777
|
}
|
|
2791
2778
|
var dump_1 = dump$1;
|
|
2792
2779
|
var dumper = {
|