Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80684 views
1
/* js-yaml 3.3.1 https://github.com/nodeca/js-yaml */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
'use strict';
3
4
5
var loader = require('./js-yaml/loader');
6
var dumper = require('./js-yaml/dumper');
7
8
9
function deprecated(name) {
10
return function () {
11
throw new Error('Function ' + name + ' is deprecated and cannot be used.');
12
};
13
}
14
15
16
module.exports.Type = require('./js-yaml/type');
17
module.exports.Schema = require('./js-yaml/schema');
18
module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
19
module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
20
module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
21
module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
22
module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
23
module.exports.load = loader.load;
24
module.exports.loadAll = loader.loadAll;
25
module.exports.safeLoad = loader.safeLoad;
26
module.exports.safeLoadAll = loader.safeLoadAll;
27
module.exports.dump = dumper.dump;
28
module.exports.safeDump = dumper.safeDump;
29
module.exports.YAMLException = require('./js-yaml/exception');
30
31
// Deprecared schema names from JS-YAML 2.0.x
32
module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
33
module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
34
module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
35
36
// Deprecated functions from JS-YAML 1.x.x
37
module.exports.scan = deprecated('scan');
38
module.exports.parse = deprecated('parse');
39
module.exports.compose = deprecated('compose');
40
module.exports.addConstructor = deprecated('addConstructor');
41
42
},{"./js-yaml/dumper":3,"./js-yaml/exception":4,"./js-yaml/loader":5,"./js-yaml/schema":7,"./js-yaml/schema/core":8,"./js-yaml/schema/default_full":9,"./js-yaml/schema/default_safe":10,"./js-yaml/schema/failsafe":11,"./js-yaml/schema/json":12,"./js-yaml/type":13}],2:[function(require,module,exports){
43
'use strict';
44
45
46
function isNothing(subject) {
47
return (typeof subject === 'undefined') || (null === subject);
48
}
49
50
51
function isObject(subject) {
52
return (typeof subject === 'object') && (null !== subject);
53
}
54
55
56
function toArray(sequence) {
57
if (Array.isArray(sequence)) {
58
return sequence;
59
} else if (isNothing(sequence)) {
60
return [];
61
}
62
return [ sequence ];
63
}
64
65
66
function extend(target, source) {
67
var index, length, key, sourceKeys;
68
69
if (source) {
70
sourceKeys = Object.keys(source);
71
72
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
73
key = sourceKeys[index];
74
target[key] = source[key];
75
}
76
}
77
78
return target;
79
}
80
81
82
function repeat(string, count) {
83
var result = '', cycle;
84
85
for (cycle = 0; cycle < count; cycle += 1) {
86
result += string;
87
}
88
89
return result;
90
}
91
92
93
function isNegativeZero(number) {
94
return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
95
}
96
97
98
module.exports.isNothing = isNothing;
99
module.exports.isObject = isObject;
100
module.exports.toArray = toArray;
101
module.exports.repeat = repeat;
102
module.exports.isNegativeZero = isNegativeZero;
103
module.exports.extend = extend;
104
105
},{}],3:[function(require,module,exports){
106
'use strict';
107
108
/*eslint-disable no-use-before-define*/
109
110
var common = require('./common');
111
var YAMLException = require('./exception');
112
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
113
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
114
115
var _toString = Object.prototype.toString;
116
var _hasOwnProperty = Object.prototype.hasOwnProperty;
117
118
var CHAR_TAB = 0x09; /* Tab */
119
var CHAR_LINE_FEED = 0x0A; /* LF */
120
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
121
var CHAR_SPACE = 0x20; /* Space */
122
var CHAR_EXCLAMATION = 0x21; /* ! */
123
var CHAR_DOUBLE_QUOTE = 0x22; /* " */
124
var CHAR_SHARP = 0x23; /* # */
125
var CHAR_PERCENT = 0x25; /* % */
126
var CHAR_AMPERSAND = 0x26; /* & */
127
var CHAR_SINGLE_QUOTE = 0x27; /* ' */
128
var CHAR_ASTERISK = 0x2A; /* * */
129
var CHAR_COMMA = 0x2C; /* , */
130
var CHAR_MINUS = 0x2D; /* - */
131
var CHAR_COLON = 0x3A; /* : */
132
var CHAR_GREATER_THAN = 0x3E; /* > */
133
var CHAR_QUESTION = 0x3F; /* ? */
134
var CHAR_COMMERCIAL_AT = 0x40; /* @ */
135
var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
136
var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
137
var CHAR_GRAVE_ACCENT = 0x60; /* ` */
138
var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
139
var CHAR_VERTICAL_LINE = 0x7C; /* | */
140
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
141
142
var ESCAPE_SEQUENCES = {};
143
144
ESCAPE_SEQUENCES[0x00] = '\\0';
145
ESCAPE_SEQUENCES[0x07] = '\\a';
146
ESCAPE_SEQUENCES[0x08] = '\\b';
147
ESCAPE_SEQUENCES[0x09] = '\\t';
148
ESCAPE_SEQUENCES[0x0A] = '\\n';
149
ESCAPE_SEQUENCES[0x0B] = '\\v';
150
ESCAPE_SEQUENCES[0x0C] = '\\f';
151
ESCAPE_SEQUENCES[0x0D] = '\\r';
152
ESCAPE_SEQUENCES[0x1B] = '\\e';
153
ESCAPE_SEQUENCES[0x22] = '\\"';
154
ESCAPE_SEQUENCES[0x5C] = '\\\\';
155
ESCAPE_SEQUENCES[0x85] = '\\N';
156
ESCAPE_SEQUENCES[0xA0] = '\\_';
157
ESCAPE_SEQUENCES[0x2028] = '\\L';
158
ESCAPE_SEQUENCES[0x2029] = '\\P';
159
160
var DEPRECATED_BOOLEANS_SYNTAX = [
161
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
162
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
163
];
164
165
function compileStyleMap(schema, map) {
166
var result, keys, index, length, tag, style, type;
167
168
if (null === map) {
169
return {};
170
}
171
172
result = {};
173
keys = Object.keys(map);
174
175
for (index = 0, length = keys.length; index < length; index += 1) {
176
tag = keys[index];
177
style = String(map[tag]);
178
179
if ('!!' === tag.slice(0, 2)) {
180
tag = 'tag:yaml.org,2002:' + tag.slice(2);
181
}
182
183
type = schema.compiledTypeMap[tag];
184
185
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
186
style = type.styleAliases[style];
187
}
188
189
result[tag] = style;
190
}
191
192
return result;
193
}
194
195
function encodeHex(character) {
196
var string, handle, length;
197
198
string = character.toString(16).toUpperCase();
199
200
if (character <= 0xFF) {
201
handle = 'x';
202
length = 2;
203
} else if (character <= 0xFFFF) {
204
handle = 'u';
205
length = 4;
206
} else if (character <= 0xFFFFFFFF) {
207
handle = 'U';
208
length = 8;
209
} else {
210
throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
211
}
212
213
return '\\' + handle + common.repeat('0', length - string.length) + string;
214
}
215
216
function State(options) {
217
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
218
this.indent = Math.max(1, (options['indent'] || 2));
219
this.skipInvalid = options['skipInvalid'] || false;
220
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
221
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
222
this.sortKeys = options['sortKeys'] || false;
223
224
this.implicitTypes = this.schema.compiledImplicit;
225
this.explicitTypes = this.schema.compiledExplicit;
226
227
this.tag = null;
228
this.result = '';
229
230
this.duplicates = [];
231
this.usedDuplicates = null;
232
}
233
234
function indentString(string, spaces) {
235
var ind = common.repeat(' ', spaces),
236
position = 0,
237
next = -1,
238
result = '',
239
line,
240
length = string.length;
241
242
while (position < length) {
243
next = string.indexOf('\n', position);
244
if (next === -1) {
245
line = string.slice(position);
246
position = length;
247
} else {
248
line = string.slice(position, next + 1);
249
position = next + 1;
250
}
251
if (line.length && line !== '\n') {
252
result += ind;
253
}
254
result += line;
255
}
256
257
return result;
258
}
259
260
function generateNextLine(state, level) {
261
return '\n' + common.repeat(' ', state.indent * level);
262
}
263
264
function testImplicitResolving(state, str) {
265
var index, length, type;
266
267
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
268
type = state.implicitTypes[index];
269
270
if (type.resolve(str)) {
271
return true;
272
}
273
}
274
275
return false;
276
}
277
278
function StringBuilder(source) {
279
this.source = source;
280
this.result = '';
281
this.checkpoint = 0;
282
}
283
284
StringBuilder.prototype.takeUpTo = function (position) {
285
var er;
286
287
if (position < this.checkpoint) {
288
er = new Error('position should be > checkpoint');
289
er.position = position;
290
er.checkpoint = this.checkpoint;
291
throw er;
292
}
293
294
this.result += this.source.slice(this.checkpoint, position);
295
this.checkpoint = position;
296
return this;
297
};
298
299
StringBuilder.prototype.escapeChar = function () {
300
var character, esc;
301
302
character = this.source.charCodeAt(this.checkpoint);
303
esc = ESCAPE_SEQUENCES[character] || encodeHex(character);
304
this.result += esc;
305
this.checkpoint += 1;
306
307
return this;
308
};
309
310
StringBuilder.prototype.finish = function () {
311
if (this.source.length > this.checkpoint) {
312
this.takeUpTo(this.source.length);
313
}
314
};
315
316
function writeScalar(state, object, level) {
317
var simple, first, spaceWrap, folded, literal, single, double,
318
sawLineFeed, linePosition, longestLine, indent, max, character,
319
position, escapeSeq, hexEsc, previous, lineLength, modifier,
320
trailingLineBreaks, result;
321
322
if (0 === object.length) {
323
state.dump = "''";
324
return;
325
}
326
327
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
328
state.dump = "'" + object + "'";
329
return;
330
}
331
332
simple = true;
333
first = object.length ? object.charCodeAt(0) : 0;
334
spaceWrap = (CHAR_SPACE === first ||
335
CHAR_SPACE === object.charCodeAt(object.length - 1));
336
337
// Simplified check for restricted first characters
338
// http://www.yaml.org/spec/1.2/spec.html#ns-plain-first%28c%29
339
if (CHAR_MINUS === first ||
340
CHAR_QUESTION === first ||
341
CHAR_COMMERCIAL_AT === first ||
342
CHAR_GRAVE_ACCENT === first) {
343
simple = false;
344
}
345
346
// can only use > and | if not wrapped in spaces.
347
if (spaceWrap) {
348
simple = false;
349
folded = false;
350
literal = false;
351
} else {
352
folded = true;
353
literal = true;
354
}
355
356
single = true;
357
double = new StringBuilder(object);
358
359
sawLineFeed = false;
360
linePosition = 0;
361
longestLine = 0;
362
363
indent = state.indent * level;
364
max = 80;
365
if (indent < 40) {
366
max -= indent;
367
} else {
368
max = 40;
369
}
370
371
for (position = 0; position < object.length; position++) {
372
character = object.charCodeAt(position);
373
if (simple) {
374
// Characters that can never appear in the simple scalar
375
if (!simpleChar(character)) {
376
simple = false;
377
} else {
378
// Still simple. If we make it all the way through like
379
// this, then we can just dump the string as-is.
380
continue;
381
}
382
}
383
384
if (single && character === CHAR_SINGLE_QUOTE) {
385
single = false;
386
}
387
388
escapeSeq = ESCAPE_SEQUENCES[character];
389
hexEsc = needsHexEscape(character);
390
391
if (!escapeSeq && !hexEsc) {
392
continue;
393
}
394
395
if (character !== CHAR_LINE_FEED &&
396
character !== CHAR_DOUBLE_QUOTE &&
397
character !== CHAR_SINGLE_QUOTE) {
398
folded = false;
399
literal = false;
400
} else if (character === CHAR_LINE_FEED) {
401
sawLineFeed = true;
402
single = false;
403
if (position > 0) {
404
previous = object.charCodeAt(position - 1);
405
if (previous === CHAR_SPACE) {
406
literal = false;
407
folded = false;
408
}
409
}
410
if (folded) {
411
lineLength = position - linePosition;
412
linePosition = position;
413
if (lineLength > longestLine) {
414
longestLine = lineLength;
415
}
416
}
417
}
418
419
if (character !== CHAR_DOUBLE_QUOTE) {
420
single = false;
421
}
422
423
double.takeUpTo(position);
424
double.escapeChar();
425
}
426
427
if (simple && testImplicitResolving(state, object)) {
428
simple = false;
429
}
430
431
modifier = '';
432
if (folded || literal) {
433
trailingLineBreaks = 0;
434
if (object.charCodeAt(object.length - 1) === CHAR_LINE_FEED) {
435
trailingLineBreaks += 1;
436
if (object.charCodeAt(object.length - 2) === CHAR_LINE_FEED) {
437
trailingLineBreaks += 1;
438
}
439
}
440
441
if (trailingLineBreaks === 0) {
442
modifier = '-';
443
} else if (trailingLineBreaks === 2) {
444
modifier = '+';
445
}
446
}
447
448
if (literal && longestLine < max) {
449
folded = false;
450
}
451
452
// If it's literally one line, then don't bother with the literal.
453
// We may still want to do a fold, though, if it's a super long line.
454
if (!sawLineFeed) {
455
literal = false;
456
}
457
458
if (simple) {
459
state.dump = object;
460
} else if (single) {
461
state.dump = '\'' + object + '\'';
462
} else if (folded) {
463
result = fold(object, max);
464
state.dump = '>' + modifier + '\n' + indentString(result, indent);
465
} else if (literal) {
466
if (!modifier) {
467
object = object.replace(/\n$/, '');
468
}
469
state.dump = '|' + modifier + '\n' + indentString(object, indent);
470
} else if (double) {
471
double.finish();
472
state.dump = '"' + double.result + '"';
473
} else {
474
throw new Error('Failed to dump scalar value');
475
}
476
477
return;
478
}
479
480
// The `trailing` var is a regexp match of any trailing `\n` characters.
481
//
482
// There are three cases we care about:
483
//
484
// 1. One trailing `\n` on the string. Just use `|` or `>`.
485
// This is the assumed default. (trailing = null)
486
// 2. No trailing `\n` on the string. Use `|-` or `>-` to "chomp" the end.
487
// 3. More than one trailing `\n` on the string. Use `|+` or `>+`.
488
//
489
// In the case of `>+`, these line breaks are *not* doubled (like the line
490
// breaks within the string), so it's important to only end with the exact
491
// same number as we started.
492
function fold(object, max) {
493
var result = '',
494
position = 0,
495
length = object.length,
496
trailing = /\n+$/.exec(object),
497
newLine;
498
499
if (trailing) {
500
length = trailing.index + 1;
501
}
502
503
while (position < length) {
504
newLine = object.indexOf('\n', position);
505
if (newLine > length || newLine === -1) {
506
if (result) {
507
result += '\n\n';
508
}
509
result += foldLine(object.slice(position, length), max);
510
position = length;
511
} else {
512
if (result) {
513
result += '\n\n';
514
}
515
result += foldLine(object.slice(position, newLine), max);
516
position = newLine + 1;
517
}
518
}
519
if (trailing && trailing[0] !== '\n') {
520
result += trailing[0];
521
}
522
523
return result;
524
}
525
526
function foldLine(line, max) {
527
if (line === '') {
528
return line;
529
}
530
531
var foldRe = /[^\s] [^\s]/g,
532
result = '',
533
prevMatch = 0,
534
foldStart = 0,
535
match = foldRe.exec(line),
536
index,
537
foldEnd,
538
folded;
539
540
while (match) {
541
index = match.index;
542
543
// when we cross the max len, if the previous match would've
544
// been ok, use that one, and carry on. If there was no previous
545
// match on this fold section, then just have a long line.
546
if (index - foldStart > max) {
547
if (prevMatch !== foldStart) {
548
foldEnd = prevMatch;
549
} else {
550
foldEnd = index;
551
}
552
553
if (result) {
554
result += '\n';
555
}
556
folded = line.slice(foldStart, foldEnd);
557
result += folded;
558
foldStart = foldEnd + 1;
559
}
560
prevMatch = index + 1;
561
match = foldRe.exec(line);
562
}
563
564
if (result) {
565
result += '\n';
566
}
567
568
// if we end up with one last word at the end, then the last bit might
569
// be slightly bigger than we wanted, because we exited out of the loop.
570
if (foldStart !== prevMatch && line.length - foldStart > max) {
571
result += line.slice(foldStart, prevMatch) + '\n' +
572
line.slice(prevMatch + 1);
573
} else {
574
result += line.slice(foldStart);
575
}
576
577
return result;
578
}
579
580
// Returns true if character can be found in a simple scalar
581
function simpleChar(character) {
582
return CHAR_TAB !== character &&
583
CHAR_LINE_FEED !== character &&
584
CHAR_CARRIAGE_RETURN !== character &&
585
CHAR_COMMA !== character &&
586
CHAR_LEFT_SQUARE_BRACKET !== character &&
587
CHAR_RIGHT_SQUARE_BRACKET !== character &&
588
CHAR_LEFT_CURLY_BRACKET !== character &&
589
CHAR_RIGHT_CURLY_BRACKET !== character &&
590
CHAR_SHARP !== character &&
591
CHAR_AMPERSAND !== character &&
592
CHAR_ASTERISK !== character &&
593
CHAR_EXCLAMATION !== character &&
594
CHAR_VERTICAL_LINE !== character &&
595
CHAR_GREATER_THAN !== character &&
596
CHAR_SINGLE_QUOTE !== character &&
597
CHAR_DOUBLE_QUOTE !== character &&
598
CHAR_PERCENT !== character &&
599
CHAR_COLON !== character &&
600
!ESCAPE_SEQUENCES[character] &&
601
!needsHexEscape(character);
602
}
603
604
// Returns true if the character code needs to be escaped.
605
function needsHexEscape(character) {
606
return !((0x00020 <= character && character <= 0x00007E) ||
607
(0x00085 === character) ||
608
(0x000A0 <= character && character <= 0x00D7FF) ||
609
(0x0E000 <= character && character <= 0x00FFFD) ||
610
(0x10000 <= character && character <= 0x10FFFF));
611
}
612
613
function writeFlowSequence(state, level, object) {
614
var _result = '',
615
_tag = state.tag,
616
index,
617
length;
618
619
for (index = 0, length = object.length; index < length; index += 1) {
620
// Write only valid elements.
621
if (writeNode(state, level, object[index], false, false)) {
622
if (0 !== index) {
623
_result += ', ';
624
}
625
_result += state.dump;
626
}
627
}
628
629
state.tag = _tag;
630
state.dump = '[' + _result + ']';
631
}
632
633
function writeBlockSequence(state, level, object, compact) {
634
var _result = '',
635
_tag = state.tag,
636
index,
637
length;
638
639
for (index = 0, length = object.length; index < length; index += 1) {
640
// Write only valid elements.
641
if (writeNode(state, level + 1, object[index], true, true)) {
642
if (!compact || 0 !== index) {
643
_result += generateNextLine(state, level);
644
}
645
_result += '- ' + state.dump;
646
}
647
}
648
649
state.tag = _tag;
650
state.dump = _result || '[]'; // Empty sequence if no valid values.
651
}
652
653
function writeFlowMapping(state, level, object) {
654
var _result = '',
655
_tag = state.tag,
656
objectKeyList = Object.keys(object),
657
index,
658
length,
659
objectKey,
660
objectValue,
661
pairBuffer;
662
663
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
664
pairBuffer = '';
665
666
if (0 !== index) {
667
pairBuffer += ', ';
668
}
669
670
objectKey = objectKeyList[index];
671
objectValue = object[objectKey];
672
673
if (!writeNode(state, level, objectKey, false, false)) {
674
continue; // Skip this pair because of invalid key;
675
}
676
677
if (state.dump.length > 1024) {
678
pairBuffer += '? ';
679
}
680
681
pairBuffer += state.dump + ': ';
682
683
if (!writeNode(state, level, objectValue, false, false)) {
684
continue; // Skip this pair because of invalid value.
685
}
686
687
pairBuffer += state.dump;
688
689
// Both key and value are valid.
690
_result += pairBuffer;
691
}
692
693
state.tag = _tag;
694
state.dump = '{' + _result + '}';
695
}
696
697
function writeBlockMapping(state, level, object, compact) {
698
var _result = '',
699
_tag = state.tag,
700
objectKeyList = Object.keys(object),
701
index,
702
length,
703
objectKey,
704
objectValue,
705
explicitPair,
706
pairBuffer;
707
708
// Allow sorting keys so that the output file is deterministic
709
if (state.sortKeys === true) {
710
// Default sorting
711
objectKeyList.sort();
712
} else if (typeof state.sortKeys === 'function') {
713
// Custom sort function
714
objectKeyList.sort(state.sortKeys);
715
} else if (state.sortKeys) {
716
// Something is wrong
717
throw new YAMLException('sortKeys must be a boolean or a function');
718
}
719
720
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
721
pairBuffer = '';
722
723
if (!compact || 0 !== index) {
724
pairBuffer += generateNextLine(state, level);
725
}
726
727
objectKey = objectKeyList[index];
728
objectValue = object[objectKey];
729
730
if (!writeNode(state, level + 1, objectKey, true, true)) {
731
continue; // Skip this pair because of invalid key.
732
}
733
734
explicitPair = (null !== state.tag && '?' !== state.tag) ||
735
(state.dump && state.dump.length > 1024);
736
737
if (explicitPair) {
738
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
739
pairBuffer += '?';
740
} else {
741
pairBuffer += '? ';
742
}
743
}
744
745
pairBuffer += state.dump;
746
747
if (explicitPair) {
748
pairBuffer += generateNextLine(state, level);
749
}
750
751
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
752
continue; // Skip this pair because of invalid value.
753
}
754
755
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
756
pairBuffer += ':';
757
} else {
758
pairBuffer += ': ';
759
}
760
761
pairBuffer += state.dump;
762
763
// Both key and value are valid.
764
_result += pairBuffer;
765
}
766
767
state.tag = _tag;
768
state.dump = _result || '{}'; // Empty mapping if no valid pairs.
769
}
770
771
function detectType(state, object, explicit) {
772
var _result, typeList, index, length, type, style;
773
774
typeList = explicit ? state.explicitTypes : state.implicitTypes;
775
776
for (index = 0, length = typeList.length; index < length; index += 1) {
777
type = typeList[index];
778
779
if ((type.instanceOf || type.predicate) &&
780
(!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) &&
781
(!type.predicate || type.predicate(object))) {
782
783
state.tag = explicit ? type.tag : '?';
784
785
if (type.represent) {
786
style = state.styleMap[type.tag] || type.defaultStyle;
787
788
if ('[object Function]' === _toString.call(type.represent)) {
789
_result = type.represent(object, style);
790
} else if (_hasOwnProperty.call(type.represent, style)) {
791
_result = type.represent[style](object, style);
792
} else {
793
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
794
}
795
796
state.dump = _result;
797
}
798
799
return true;
800
}
801
}
802
803
return false;
804
}
805
806
// Serializes `object` and writes it to global `result`.
807
// Returns true on success, or false on invalid object.
808
//
809
function writeNode(state, level, object, block, compact) {
810
state.tag = null;
811
state.dump = object;
812
813
if (!detectType(state, object, false)) {
814
detectType(state, object, true);
815
}
816
817
var type = _toString.call(state.dump);
818
819
if (block) {
820
block = (0 > state.flowLevel || state.flowLevel > level);
821
}
822
823
if ((null !== state.tag && '?' !== state.tag) || (2 !== state.indent && level > 0)) {
824
compact = false;
825
}
826
827
var objectOrArray = '[object Object]' === type || '[object Array]' === type,
828
duplicateIndex,
829
duplicate;
830
831
if (objectOrArray) {
832
duplicateIndex = state.duplicates.indexOf(object);
833
duplicate = duplicateIndex !== -1;
834
}
835
836
if (duplicate && state.usedDuplicates[duplicateIndex]) {
837
state.dump = '*ref_' + duplicateIndex;
838
} else {
839
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
840
state.usedDuplicates[duplicateIndex] = true;
841
}
842
if ('[object Object]' === type) {
843
if (block && (0 !== Object.keys(state.dump).length)) {
844
writeBlockMapping(state, level, state.dump, compact);
845
if (duplicate) {
846
state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
847
}
848
} else {
849
writeFlowMapping(state, level, state.dump);
850
if (duplicate) {
851
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
852
}
853
}
854
} else if ('[object Array]' === type) {
855
if (block && (0 !== state.dump.length)) {
856
writeBlockSequence(state, level, state.dump, compact);
857
if (duplicate) {
858
state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
859
}
860
} else {
861
writeFlowSequence(state, level, state.dump);
862
if (duplicate) {
863
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
864
}
865
}
866
} else if ('[object String]' === type) {
867
if ('?' !== state.tag) {
868
writeScalar(state, state.dump, level);
869
}
870
} else {
871
if (state.skipInvalid) {
872
return false;
873
}
874
throw new YAMLException('unacceptable kind of an object to dump ' + type);
875
}
876
877
if (null !== state.tag && '?' !== state.tag) {
878
state.dump = '!<' + state.tag + '> ' + state.dump;
879
}
880
}
881
882
return true;
883
}
884
885
function getDuplicateReferences(object, state) {
886
var objects = [],
887
duplicatesIndexes = [],
888
index,
889
length;
890
891
inspectNode(object, objects, duplicatesIndexes);
892
893
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
894
state.duplicates.push(objects[duplicatesIndexes[index]]);
895
}
896
state.usedDuplicates = new Array(length);
897
}
898
899
function inspectNode(object, objects, duplicatesIndexes) {
900
var type = _toString.call(object),
901
objectKeyList,
902
index,
903
length;
904
905
if (null !== object && 'object' === typeof object) {
906
index = objects.indexOf(object);
907
if (-1 !== index) {
908
if (-1 === duplicatesIndexes.indexOf(index)) {
909
duplicatesIndexes.push(index);
910
}
911
} else {
912
objects.push(object);
913
914
if (Array.isArray(object)) {
915
for (index = 0, length = object.length; index < length; index += 1) {
916
inspectNode(object[index], objects, duplicatesIndexes);
917
}
918
} else {
919
objectKeyList = Object.keys(object);
920
921
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
922
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
923
}
924
}
925
}
926
}
927
}
928
929
function dump(input, options) {
930
options = options || {};
931
932
var state = new State(options);
933
934
getDuplicateReferences(input, state);
935
936
if (writeNode(state, 0, input, true, true)) {
937
return state.dump + '\n';
938
}
939
return '';
940
}
941
942
function safeDump(input, options) {
943
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
944
}
945
946
module.exports.dump = dump;
947
module.exports.safeDump = safeDump;
948
949
},{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){
950
'use strict';
951
952
953
function YAMLException(reason, mark) {
954
this.name = 'YAMLException';
955
this.reason = reason;
956
this.mark = mark;
957
this.message = this.toString(false);
958
}
959
960
961
YAMLException.prototype.toString = function toString(compact) {
962
var result;
963
964
result = 'JS-YAML: ' + (this.reason || '(unknown reason)');
965
966
if (!compact && this.mark) {
967
result += ' ' + this.mark.toString();
968
}
969
970
return result;
971
};
972
973
974
module.exports = YAMLException;
975
976
},{}],5:[function(require,module,exports){
977
'use strict';
978
979
/*eslint-disable max-len,no-use-before-define*/
980
981
var common = require('./common');
982
var YAMLException = require('./exception');
983
var Mark = require('./mark');
984
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
985
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
986
987
988
var _hasOwnProperty = Object.prototype.hasOwnProperty;
989
990
991
var CONTEXT_FLOW_IN = 1;
992
var CONTEXT_FLOW_OUT = 2;
993
var CONTEXT_BLOCK_IN = 3;
994
var CONTEXT_BLOCK_OUT = 4;
995
996
997
var CHOMPING_CLIP = 1;
998
var CHOMPING_STRIP = 2;
999
var CHOMPING_KEEP = 3;
1000
1001
1002
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1003
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1004
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
1005
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
1006
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1007
1008
1009
function is_EOL(c) {
1010
return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
1011
}
1012
1013
function is_WHITE_SPACE(c) {
1014
return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
1015
}
1016
1017
function is_WS_OR_EOL(c) {
1018
return (c === 0x09/* Tab */) ||
1019
(c === 0x20/* Space */) ||
1020
(c === 0x0A/* LF */) ||
1021
(c === 0x0D/* CR */);
1022
}
1023
1024
function is_FLOW_INDICATOR(c) {
1025
return 0x2C/* , */ === c ||
1026
0x5B/* [ */ === c ||
1027
0x5D/* ] */ === c ||
1028
0x7B/* { */ === c ||
1029
0x7D/* } */ === c;
1030
}
1031
1032
function fromHexCode(c) {
1033
var lc;
1034
1035
if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1036
return c - 0x30;
1037
}
1038
1039
/*eslint-disable no-bitwise*/
1040
lc = c | 0x20;
1041
1042
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
1043
return lc - 0x61 + 10;
1044
}
1045
1046
return -1;
1047
}
1048
1049
function escapedHexLen(c) {
1050
if (c === 0x78/* x */) { return 2; }
1051
if (c === 0x75/* u */) { return 4; }
1052
if (c === 0x55/* U */) { return 8; }
1053
return 0;
1054
}
1055
1056
function fromDecimalCode(c) {
1057
if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1058
return c - 0x30;
1059
}
1060
1061
return -1;
1062
}
1063
1064
function simpleEscapeSequence(c) {
1065
return (c === 0x30/* 0 */) ? '\x00' :
1066
(c === 0x61/* a */) ? '\x07' :
1067
(c === 0x62/* b */) ? '\x08' :
1068
(c === 0x74/* t */) ? '\x09' :
1069
(c === 0x09/* Tab */) ? '\x09' :
1070
(c === 0x6E/* n */) ? '\x0A' :
1071
(c === 0x76/* v */) ? '\x0B' :
1072
(c === 0x66/* f */) ? '\x0C' :
1073
(c === 0x72/* r */) ? '\x0D' :
1074
(c === 0x65/* e */) ? '\x1B' :
1075
(c === 0x20/* Space */) ? ' ' :
1076
(c === 0x22/* " */) ? '\x22' :
1077
(c === 0x2F/* / */) ? '/' :
1078
(c === 0x5C/* \ */) ? '\x5C' :
1079
(c === 0x4E/* N */) ? '\x85' :
1080
(c === 0x5F/* _ */) ? '\xA0' :
1081
(c === 0x4C/* L */) ? '\u2028' :
1082
(c === 0x50/* P */) ? '\u2029' : '';
1083
}
1084
1085
function charFromCodepoint(c) {
1086
if (c <= 0xFFFF) {
1087
return String.fromCharCode(c);
1088
}
1089
// Encode UTF-16 surrogate pair
1090
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
1091
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
1092
((c - 0x010000) & 0x03FF) + 0xDC00);
1093
}
1094
1095
var simpleEscapeCheck = new Array(256); // integer, for fast access
1096
var simpleEscapeMap = new Array(256);
1097
for (var i = 0; i < 256; i++) {
1098
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1099
simpleEscapeMap[i] = simpleEscapeSequence(i);
1100
}
1101
1102
1103
function State(input, options) {
1104
this.input = input;
1105
1106
this.filename = options['filename'] || null;
1107
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
1108
this.onWarning = options['onWarning'] || null;
1109
this.legacy = options['legacy'] || false;
1110
1111
this.implicitTypes = this.schema.compiledImplicit;
1112
this.typeMap = this.schema.compiledTypeMap;
1113
1114
this.length = input.length;
1115
this.position = 0;
1116
this.line = 0;
1117
this.lineStart = 0;
1118
this.lineIndent = 0;
1119
1120
this.documents = [];
1121
1122
/*
1123
this.version;
1124
this.checkLineBreaks;
1125
this.tagMap;
1126
this.anchorMap;
1127
this.tag;
1128
this.anchor;
1129
this.kind;
1130
this.result;*/
1131
1132
}
1133
1134
1135
function generateError(state, message) {
1136
return new YAMLException(
1137
message,
1138
new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
1139
}
1140
1141
function throwError(state, message) {
1142
throw generateError(state, message);
1143
}
1144
1145
function throwWarning(state, message) {
1146
var error = generateError(state, message);
1147
1148
if (state.onWarning) {
1149
state.onWarning.call(null, error);
1150
} else {
1151
throw error;
1152
}
1153
}
1154
1155
1156
var directiveHandlers = {
1157
1158
YAML: function handleYamlDirective(state, name, args) {
1159
1160
var match, major, minor;
1161
1162
if (null !== state.version) {
1163
throwError(state, 'duplication of %YAML directive');
1164
}
1165
1166
if (1 !== args.length) {
1167
throwError(state, 'YAML directive accepts exactly one argument');
1168
}
1169
1170
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1171
1172
if (null === match) {
1173
throwError(state, 'ill-formed argument of the YAML directive');
1174
}
1175
1176
major = parseInt(match[1], 10);
1177
minor = parseInt(match[2], 10);
1178
1179
if (1 !== major) {
1180
throwError(state, 'unacceptable YAML version of the document');
1181
}
1182
1183
state.version = args[0];
1184
state.checkLineBreaks = (minor < 2);
1185
1186
if (1 !== minor && 2 !== minor) {
1187
throwWarning(state, 'unsupported YAML version of the document');
1188
}
1189
},
1190
1191
TAG: function handleTagDirective(state, name, args) {
1192
1193
var handle, prefix;
1194
1195
if (2 !== args.length) {
1196
throwError(state, 'TAG directive accepts exactly two arguments');
1197
}
1198
1199
handle = args[0];
1200
prefix = args[1];
1201
1202
if (!PATTERN_TAG_HANDLE.test(handle)) {
1203
throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
1204
}
1205
1206
if (_hasOwnProperty.call(state.tagMap, handle)) {
1207
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1208
}
1209
1210
if (!PATTERN_TAG_URI.test(prefix)) {
1211
throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
1212
}
1213
1214
state.tagMap[handle] = prefix;
1215
}
1216
};
1217
1218
1219
function captureSegment(state, start, end, checkJson) {
1220
var _position, _length, _character, _result;
1221
1222
if (start < end) {
1223
_result = state.input.slice(start, end);
1224
1225
if (checkJson) {
1226
for (_position = 0, _length = _result.length;
1227
_position < _length;
1228
_position += 1) {
1229
_character = _result.charCodeAt(_position);
1230
if (!(0x09 === _character ||
1231
0x20 <= _character && _character <= 0x10FFFF)) {
1232
throwError(state, 'expected valid JSON character');
1233
}
1234
}
1235
}
1236
1237
state.result += _result;
1238
}
1239
}
1240
1241
function mergeMappings(state, destination, source) {
1242
var sourceKeys, key, index, quantity;
1243
1244
if (!common.isObject(source)) {
1245
throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
1246
}
1247
1248
sourceKeys = Object.keys(source);
1249
1250
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1251
key = sourceKeys[index];
1252
1253
if (!_hasOwnProperty.call(destination, key)) {
1254
destination[key] = source[key];
1255
}
1256
}
1257
}
1258
1259
function storeMappingPair(state, _result, keyTag, keyNode, valueNode) {
1260
var index, quantity;
1261
1262
keyNode = String(keyNode);
1263
1264
if (null === _result) {
1265
_result = {};
1266
}
1267
1268
if ('tag:yaml.org,2002:merge' === keyTag) {
1269
if (Array.isArray(valueNode)) {
1270
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1271
mergeMappings(state, _result, valueNode[index]);
1272
}
1273
} else {
1274
mergeMappings(state, _result, valueNode);
1275
}
1276
} else {
1277
_result[keyNode] = valueNode;
1278
}
1279
1280
return _result;
1281
}
1282
1283
function readLineBreak(state) {
1284
var ch;
1285
1286
ch = state.input.charCodeAt(state.position);
1287
1288
if (0x0A/* LF */ === ch) {
1289
state.position++;
1290
} else if (0x0D/* CR */ === ch) {
1291
state.position++;
1292
if (0x0A/* LF */ === state.input.charCodeAt(state.position)) {
1293
state.position++;
1294
}
1295
} else {
1296
throwError(state, 'a line break is expected');
1297
}
1298
1299
state.line += 1;
1300
state.lineStart = state.position;
1301
}
1302
1303
function skipSeparationSpace(state, allowComments, checkIndent) {
1304
var lineBreaks = 0,
1305
ch = state.input.charCodeAt(state.position);
1306
1307
while (0 !== ch) {
1308
while (is_WHITE_SPACE(ch)) {
1309
ch = state.input.charCodeAt(++state.position);
1310
}
1311
1312
if (allowComments && 0x23/* # */ === ch) {
1313
do {
1314
ch = state.input.charCodeAt(++state.position);
1315
} while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && 0 !== ch);
1316
}
1317
1318
if (is_EOL(ch)) {
1319
readLineBreak(state);
1320
1321
ch = state.input.charCodeAt(state.position);
1322
lineBreaks++;
1323
state.lineIndent = 0;
1324
1325
while (0x20/* Space */ === ch) {
1326
state.lineIndent++;
1327
ch = state.input.charCodeAt(++state.position);
1328
}
1329
} else {
1330
break;
1331
}
1332
}
1333
1334
if (-1 !== checkIndent && 0 !== lineBreaks && state.lineIndent < checkIndent) {
1335
throwWarning(state, 'deficient indentation');
1336
}
1337
1338
return lineBreaks;
1339
}
1340
1341
function testDocumentSeparator(state) {
1342
var _position = state.position,
1343
ch;
1344
1345
ch = state.input.charCodeAt(_position);
1346
1347
// Condition state.position === state.lineStart is tested
1348
// in parent on each call, for efficiency. No needs to test here again.
1349
if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
1350
state.input.charCodeAt(_position + 1) === ch &&
1351
state.input.charCodeAt(_position + 2) === ch) {
1352
1353
_position += 3;
1354
1355
ch = state.input.charCodeAt(_position);
1356
1357
if (ch === 0 || is_WS_OR_EOL(ch)) {
1358
return true;
1359
}
1360
}
1361
1362
return false;
1363
}
1364
1365
function writeFoldedLines(state, count) {
1366
if (1 === count) {
1367
state.result += ' ';
1368
} else if (count > 1) {
1369
state.result += common.repeat('\n', count - 1);
1370
}
1371
}
1372
1373
1374
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1375
var preceding,
1376
following,
1377
captureStart,
1378
captureEnd,
1379
hasPendingContent,
1380
_line,
1381
_lineStart,
1382
_lineIndent,
1383
_kind = state.kind,
1384
_result = state.result,
1385
ch;
1386
1387
ch = state.input.charCodeAt(state.position);
1388
1389
if (is_WS_OR_EOL(ch) ||
1390
is_FLOW_INDICATOR(ch) ||
1391
0x23/* # */ === ch ||
1392
0x26/* & */ === ch ||
1393
0x2A/* * */ === ch ||
1394
0x21/* ! */ === ch ||
1395
0x7C/* | */ === ch ||
1396
0x3E/* > */ === ch ||
1397
0x27/* ' */ === ch ||
1398
0x22/* " */ === ch ||
1399
0x25/* % */ === ch ||
1400
0x40/* @ */ === ch ||
1401
0x60/* ` */ === ch) {
1402
return false;
1403
}
1404
1405
if (0x3F/* ? */ === ch || 0x2D/* - */ === ch) {
1406
following = state.input.charCodeAt(state.position + 1);
1407
1408
if (is_WS_OR_EOL(following) ||
1409
withinFlowCollection && is_FLOW_INDICATOR(following)) {
1410
return false;
1411
}
1412
}
1413
1414
state.kind = 'scalar';
1415
state.result = '';
1416
captureStart = captureEnd = state.position;
1417
hasPendingContent = false;
1418
1419
while (0 !== ch) {
1420
if (0x3A/* : */ === ch) {
1421
following = state.input.charCodeAt(state.position + 1);
1422
1423
if (is_WS_OR_EOL(following) ||
1424
withinFlowCollection && is_FLOW_INDICATOR(following)) {
1425
break;
1426
}
1427
1428
} else if (0x23/* # */ === ch) {
1429
preceding = state.input.charCodeAt(state.position - 1);
1430
1431
if (is_WS_OR_EOL(preceding)) {
1432
break;
1433
}
1434
1435
} else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
1436
withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1437
break;
1438
1439
} else if (is_EOL(ch)) {
1440
_line = state.line;
1441
_lineStart = state.lineStart;
1442
_lineIndent = state.lineIndent;
1443
skipSeparationSpace(state, false, -1);
1444
1445
if (state.lineIndent >= nodeIndent) {
1446
hasPendingContent = true;
1447
ch = state.input.charCodeAt(state.position);
1448
continue;
1449
} else {
1450
state.position = captureEnd;
1451
state.line = _line;
1452
state.lineStart = _lineStart;
1453
state.lineIndent = _lineIndent;
1454
break;
1455
}
1456
}
1457
1458
if (hasPendingContent) {
1459
captureSegment(state, captureStart, captureEnd, false);
1460
writeFoldedLines(state, state.line - _line);
1461
captureStart = captureEnd = state.position;
1462
hasPendingContent = false;
1463
}
1464
1465
if (!is_WHITE_SPACE(ch)) {
1466
captureEnd = state.position + 1;
1467
}
1468
1469
ch = state.input.charCodeAt(++state.position);
1470
}
1471
1472
captureSegment(state, captureStart, captureEnd, false);
1473
1474
if (state.result) {
1475
return true;
1476
}
1477
1478
state.kind = _kind;
1479
state.result = _result;
1480
return false;
1481
}
1482
1483
function readSingleQuotedScalar(state, nodeIndent) {
1484
var ch,
1485
captureStart, captureEnd;
1486
1487
ch = state.input.charCodeAt(state.position);
1488
1489
if (0x27/* ' */ !== ch) {
1490
return false;
1491
}
1492
1493
state.kind = 'scalar';
1494
state.result = '';
1495
state.position++;
1496
captureStart = captureEnd = state.position;
1497
1498
while (0 !== (ch = state.input.charCodeAt(state.position))) {
1499
if (0x27/* ' */ === ch) {
1500
captureSegment(state, captureStart, state.position, true);
1501
ch = state.input.charCodeAt(++state.position);
1502
1503
if (0x27/* ' */ === ch) {
1504
captureStart = captureEnd = state.position;
1505
state.position++;
1506
} else {
1507
return true;
1508
}
1509
1510
} else if (is_EOL(ch)) {
1511
captureSegment(state, captureStart, captureEnd, true);
1512
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1513
captureStart = captureEnd = state.position;
1514
1515
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1516
throwError(state, 'unexpected end of the document within a single quoted scalar');
1517
1518
} else {
1519
state.position++;
1520
captureEnd = state.position;
1521
}
1522
}
1523
1524
throwError(state, 'unexpected end of the stream within a single quoted scalar');
1525
}
1526
1527
function readDoubleQuotedScalar(state, nodeIndent) {
1528
var captureStart,
1529
captureEnd,
1530
hexLength,
1531
hexResult,
1532
tmp, tmpEsc,
1533
ch;
1534
1535
ch = state.input.charCodeAt(state.position);
1536
1537
if (0x22/* " */ !== ch) {
1538
return false;
1539
}
1540
1541
state.kind = 'scalar';
1542
state.result = '';
1543
state.position++;
1544
captureStart = captureEnd = state.position;
1545
1546
while (0 !== (ch = state.input.charCodeAt(state.position))) {
1547
if (0x22/* " */ === ch) {
1548
captureSegment(state, captureStart, state.position, true);
1549
state.position++;
1550
return true;
1551
1552
} else if (0x5C/* \ */ === ch) {
1553
captureSegment(state, captureStart, state.position, true);
1554
ch = state.input.charCodeAt(++state.position);
1555
1556
if (is_EOL(ch)) {
1557
skipSeparationSpace(state, false, nodeIndent);
1558
1559
// TODO: rework to inline fn with no type cast?
1560
} else if (ch < 256 && simpleEscapeCheck[ch]) {
1561
state.result += simpleEscapeMap[ch];
1562
state.position++;
1563
1564
} else if ((tmp = escapedHexLen(ch)) > 0) {
1565
hexLength = tmp;
1566
hexResult = 0;
1567
1568
for (; hexLength > 0; hexLength--) {
1569
ch = state.input.charCodeAt(++state.position);
1570
1571
if ((tmp = fromHexCode(ch)) >= 0) {
1572
hexResult = (hexResult << 4) + tmp;
1573
1574
} else {
1575
throwError(state, 'expected hexadecimal character');
1576
}
1577
}
1578
1579
state.result += charFromCodepoint(hexResult);
1580
1581
state.position++;
1582
1583
} else {
1584
throwError(state, 'unknown escape sequence');
1585
}
1586
1587
captureStart = captureEnd = state.position;
1588
1589
} else if (is_EOL(ch)) {
1590
captureSegment(state, captureStart, captureEnd, true);
1591
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1592
captureStart = captureEnd = state.position;
1593
1594
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1595
throwError(state, 'unexpected end of the document within a double quoted scalar');
1596
1597
} else {
1598
state.position++;
1599
captureEnd = state.position;
1600
}
1601
}
1602
1603
throwError(state, 'unexpected end of the stream within a double quoted scalar');
1604
}
1605
1606
function readFlowCollection(state, nodeIndent) {
1607
var readNext = true,
1608
_line,
1609
_tag = state.tag,
1610
_result,
1611
_anchor = state.anchor,
1612
following,
1613
terminator,
1614
isPair,
1615
isExplicitPair,
1616
isMapping,
1617
keyNode,
1618
keyTag,
1619
valueNode,
1620
ch;
1621
1622
ch = state.input.charCodeAt(state.position);
1623
1624
if (ch === 0x5B/* [ */) {
1625
terminator = 0x5D;/* ] */
1626
isMapping = false;
1627
_result = [];
1628
} else if (ch === 0x7B/* { */) {
1629
terminator = 0x7D;/* } */
1630
isMapping = true;
1631
_result = {};
1632
} else {
1633
return false;
1634
}
1635
1636
if (null !== state.anchor) {
1637
state.anchorMap[state.anchor] = _result;
1638
}
1639
1640
ch = state.input.charCodeAt(++state.position);
1641
1642
while (0 !== ch) {
1643
skipSeparationSpace(state, true, nodeIndent);
1644
1645
ch = state.input.charCodeAt(state.position);
1646
1647
if (ch === terminator) {
1648
state.position++;
1649
state.tag = _tag;
1650
state.anchor = _anchor;
1651
state.kind = isMapping ? 'mapping' : 'sequence';
1652
state.result = _result;
1653
return true;
1654
} else if (!readNext) {
1655
throwError(state, 'missed comma between flow collection entries');
1656
}
1657
1658
keyTag = keyNode = valueNode = null;
1659
isPair = isExplicitPair = false;
1660
1661
if (0x3F/* ? */ === ch) {
1662
following = state.input.charCodeAt(state.position + 1);
1663
1664
if (is_WS_OR_EOL(following)) {
1665
isPair = isExplicitPair = true;
1666
state.position++;
1667
skipSeparationSpace(state, true, nodeIndent);
1668
}
1669
}
1670
1671
_line = state.line;
1672
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1673
keyTag = state.tag;
1674
keyNode = state.result;
1675
skipSeparationSpace(state, true, nodeIndent);
1676
1677
ch = state.input.charCodeAt(state.position);
1678
1679
if ((isExplicitPair || state.line === _line) && 0x3A/* : */ === ch) {
1680
isPair = true;
1681
ch = state.input.charCodeAt(++state.position);
1682
skipSeparationSpace(state, true, nodeIndent);
1683
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1684
valueNode = state.result;
1685
}
1686
1687
if (isMapping) {
1688
storeMappingPair(state, _result, keyTag, keyNode, valueNode);
1689
} else if (isPair) {
1690
_result.push(storeMappingPair(state, null, keyTag, keyNode, valueNode));
1691
} else {
1692
_result.push(keyNode);
1693
}
1694
1695
skipSeparationSpace(state, true, nodeIndent);
1696
1697
ch = state.input.charCodeAt(state.position);
1698
1699
if (0x2C/* , */ === ch) {
1700
readNext = true;
1701
ch = state.input.charCodeAt(++state.position);
1702
} else {
1703
readNext = false;
1704
}
1705
}
1706
1707
throwError(state, 'unexpected end of the stream within a flow collection');
1708
}
1709
1710
function readBlockScalar(state, nodeIndent) {
1711
var captureStart,
1712
folding,
1713
chomping = CHOMPING_CLIP,
1714
detectedIndent = false,
1715
textIndent = nodeIndent,
1716
emptyLines = 0,
1717
atMoreIndented = false,
1718
tmp,
1719
ch;
1720
1721
ch = state.input.charCodeAt(state.position);
1722
1723
if (ch === 0x7C/* | */) {
1724
folding = false;
1725
} else if (ch === 0x3E/* > */) {
1726
folding = true;
1727
} else {
1728
return false;
1729
}
1730
1731
state.kind = 'scalar';
1732
state.result = '';
1733
1734
while (0 !== ch) {
1735
ch = state.input.charCodeAt(++state.position);
1736
1737
if (0x2B/* + */ === ch || 0x2D/* - */ === ch) {
1738
if (CHOMPING_CLIP === chomping) {
1739
chomping = (0x2B/* + */ === ch) ? CHOMPING_KEEP : CHOMPING_STRIP;
1740
} else {
1741
throwError(state, 'repeat of a chomping mode identifier');
1742
}
1743
1744
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
1745
if (tmp === 0) {
1746
throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
1747
} else if (!detectedIndent) {
1748
textIndent = nodeIndent + tmp - 1;
1749
detectedIndent = true;
1750
} else {
1751
throwError(state, 'repeat of an indentation width identifier');
1752
}
1753
1754
} else {
1755
break;
1756
}
1757
}
1758
1759
if (is_WHITE_SPACE(ch)) {
1760
do { ch = state.input.charCodeAt(++state.position); }
1761
while (is_WHITE_SPACE(ch));
1762
1763
if (0x23/* # */ === ch) {
1764
do { ch = state.input.charCodeAt(++state.position); }
1765
while (!is_EOL(ch) && (0 !== ch));
1766
}
1767
}
1768
1769
while (0 !== ch) {
1770
readLineBreak(state);
1771
state.lineIndent = 0;
1772
1773
ch = state.input.charCodeAt(state.position);
1774
1775
while ((!detectedIndent || state.lineIndent < textIndent) &&
1776
(0x20/* Space */ === ch)) {
1777
state.lineIndent++;
1778
ch = state.input.charCodeAt(++state.position);
1779
}
1780
1781
if (!detectedIndent && state.lineIndent > textIndent) {
1782
textIndent = state.lineIndent;
1783
}
1784
1785
if (is_EOL(ch)) {
1786
emptyLines++;
1787
continue;
1788
}
1789
1790
// End of the scalar.
1791
if (state.lineIndent < textIndent) {
1792
1793
// Perform the chomping.
1794
if (chomping === CHOMPING_KEEP) {
1795
state.result += common.repeat('\n', emptyLines);
1796
} else if (chomping === CHOMPING_CLIP) {
1797
if (detectedIndent) { // i.e. only if the scalar is not empty.
1798
state.result += '\n';
1799
}
1800
}
1801
1802
// Break this `while` cycle and go to the funciton's epilogue.
1803
break;
1804
}
1805
1806
// Folded style: use fancy rules to handle line breaks.
1807
if (folding) {
1808
1809
// Lines starting with white space characters (more-indented lines) are not folded.
1810
if (is_WHITE_SPACE(ch)) {
1811
atMoreIndented = true;
1812
state.result += common.repeat('\n', emptyLines + 1);
1813
1814
// End of more-indented block.
1815
} else if (atMoreIndented) {
1816
atMoreIndented = false;
1817
state.result += common.repeat('\n', emptyLines + 1);
1818
1819
// Just one line break - perceive as the same line.
1820
} else if (0 === emptyLines) {
1821
if (detectedIndent) { // i.e. only if we have already read some scalar content.
1822
state.result += ' ';
1823
}
1824
1825
// Several line breaks - perceive as different lines.
1826
} else {
1827
state.result += common.repeat('\n', emptyLines);
1828
}
1829
1830
// Literal style: just add exact number of line breaks between content lines.
1831
} else if (detectedIndent) {
1832
// If current line isn't the first one - count line break from the last content line.
1833
state.result += common.repeat('\n', emptyLines + 1);
1834
} else {
1835
// In case of the first content line - count only empty lines.
1836
}
1837
1838
detectedIndent = true;
1839
emptyLines = 0;
1840
captureStart = state.position;
1841
1842
while (!is_EOL(ch) && (0 !== ch)) {
1843
ch = state.input.charCodeAt(++state.position);
1844
}
1845
1846
captureSegment(state, captureStart, state.position, false);
1847
}
1848
1849
return true;
1850
}
1851
1852
function readBlockSequence(state, nodeIndent) {
1853
var _line,
1854
_tag = state.tag,
1855
_anchor = state.anchor,
1856
_result = [],
1857
following,
1858
detected = false,
1859
ch;
1860
1861
if (null !== state.anchor) {
1862
state.anchorMap[state.anchor] = _result;
1863
}
1864
1865
ch = state.input.charCodeAt(state.position);
1866
1867
while (0 !== ch) {
1868
1869
if (0x2D/* - */ !== ch) {
1870
break;
1871
}
1872
1873
following = state.input.charCodeAt(state.position + 1);
1874
1875
if (!is_WS_OR_EOL(following)) {
1876
break;
1877
}
1878
1879
detected = true;
1880
state.position++;
1881
1882
if (skipSeparationSpace(state, true, -1)) {
1883
if (state.lineIndent <= nodeIndent) {
1884
_result.push(null);
1885
ch = state.input.charCodeAt(state.position);
1886
continue;
1887
}
1888
}
1889
1890
_line = state.line;
1891
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1892
_result.push(state.result);
1893
skipSeparationSpace(state, true, -1);
1894
1895
ch = state.input.charCodeAt(state.position);
1896
1897
if ((state.line === _line || state.lineIndent > nodeIndent) && (0 !== ch)) {
1898
throwError(state, 'bad indentation of a sequence entry');
1899
} else if (state.lineIndent < nodeIndent) {
1900
break;
1901
}
1902
}
1903
1904
if (detected) {
1905
state.tag = _tag;
1906
state.anchor = _anchor;
1907
state.kind = 'sequence';
1908
state.result = _result;
1909
return true;
1910
}
1911
return false;
1912
}
1913
1914
function readBlockMapping(state, nodeIndent, flowIndent) {
1915
var following,
1916
allowCompact,
1917
_line,
1918
_tag = state.tag,
1919
_anchor = state.anchor,
1920
_result = {},
1921
keyTag = null,
1922
keyNode = null,
1923
valueNode = null,
1924
atExplicitKey = false,
1925
detected = false,
1926
ch;
1927
1928
if (null !== state.anchor) {
1929
state.anchorMap[state.anchor] = _result;
1930
}
1931
1932
ch = state.input.charCodeAt(state.position);
1933
1934
while (0 !== ch) {
1935
following = state.input.charCodeAt(state.position + 1);
1936
_line = state.line; // Save the current line.
1937
1938
//
1939
// Explicit notation case. There are two separate blocks:
1940
// first for the key (denoted by "?") and second for the value (denoted by ":")
1941
//
1942
if ((0x3F/* ? */ === ch || 0x3A/* : */ === ch) && is_WS_OR_EOL(following)) {
1943
1944
if (0x3F/* ? */ === ch) {
1945
if (atExplicitKey) {
1946
storeMappingPair(state, _result, keyTag, keyNode, null);
1947
keyTag = keyNode = valueNode = null;
1948
}
1949
1950
detected = true;
1951
atExplicitKey = true;
1952
allowCompact = true;
1953
1954
} else if (atExplicitKey) {
1955
// i.e. 0x3A/* : */ === character after the explicit key.
1956
atExplicitKey = false;
1957
allowCompact = true;
1958
1959
} else {
1960
throwError(state, 'incomplete explicit mapping pair; a key node is missed');
1961
}
1962
1963
state.position += 1;
1964
ch = following;
1965
1966
//
1967
// Implicit notation case. Flow-style node as the key first, then ":", and the value.
1968
//
1969
} else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1970
1971
if (state.line === _line) {
1972
ch = state.input.charCodeAt(state.position);
1973
1974
while (is_WHITE_SPACE(ch)) {
1975
ch = state.input.charCodeAt(++state.position);
1976
}
1977
1978
if (0x3A/* : */ === ch) {
1979
ch = state.input.charCodeAt(++state.position);
1980
1981
if (!is_WS_OR_EOL(ch)) {
1982
throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
1983
}
1984
1985
if (atExplicitKey) {
1986
storeMappingPair(state, _result, keyTag, keyNode, null);
1987
keyTag = keyNode = valueNode = null;
1988
}
1989
1990
detected = true;
1991
atExplicitKey = false;
1992
allowCompact = false;
1993
keyTag = state.tag;
1994
keyNode = state.result;
1995
1996
} else if (detected) {
1997
throwError(state, 'can not read an implicit mapping pair; a colon is missed');
1998
1999
} else {
2000
state.tag = _tag;
2001
state.anchor = _anchor;
2002
return true; // Keep the result of `composeNode`.
2003
}
2004
2005
} else if (detected) {
2006
throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
2007
2008
} else {
2009
state.tag = _tag;
2010
state.anchor = _anchor;
2011
return true; // Keep the result of `composeNode`.
2012
}
2013
2014
} else {
2015
break; // Reading is done. Go to the epilogue.
2016
}
2017
2018
//
2019
// Common reading code for both explicit and implicit notations.
2020
//
2021
if (state.line === _line || state.lineIndent > nodeIndent) {
2022
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
2023
if (atExplicitKey) {
2024
keyNode = state.result;
2025
} else {
2026
valueNode = state.result;
2027
}
2028
}
2029
2030
if (!atExplicitKey) {
2031
storeMappingPair(state, _result, keyTag, keyNode, valueNode);
2032
keyTag = keyNode = valueNode = null;
2033
}
2034
2035
skipSeparationSpace(state, true, -1);
2036
ch = state.input.charCodeAt(state.position);
2037
}
2038
2039
if (state.lineIndent > nodeIndent && (0 !== ch)) {
2040
throwError(state, 'bad indentation of a mapping entry');
2041
} else if (state.lineIndent < nodeIndent) {
2042
break;
2043
}
2044
}
2045
2046
//
2047
// Epilogue.
2048
//
2049
2050
// Special case: last mapping's node contains only the key in explicit notation.
2051
if (atExplicitKey) {
2052
storeMappingPair(state, _result, keyTag, keyNode, null);
2053
}
2054
2055
// Expose the resulting mapping.
2056
if (detected) {
2057
state.tag = _tag;
2058
state.anchor = _anchor;
2059
state.kind = 'mapping';
2060
state.result = _result;
2061
}
2062
2063
return detected;
2064
}
2065
2066
function readTagProperty(state) {
2067
var _position,
2068
isVerbatim = false,
2069
isNamed = false,
2070
tagHandle,
2071
tagName,
2072
ch;
2073
2074
ch = state.input.charCodeAt(state.position);
2075
2076
if (0x21/* ! */ !== ch) {
2077
return false;
2078
}
2079
2080
if (null !== state.tag) {
2081
throwError(state, 'duplication of a tag property');
2082
}
2083
2084
ch = state.input.charCodeAt(++state.position);
2085
2086
if (0x3C/* < */ === ch) {
2087
isVerbatim = true;
2088
ch = state.input.charCodeAt(++state.position);
2089
2090
} else if (0x21/* ! */ === ch) {
2091
isNamed = true;
2092
tagHandle = '!!';
2093
ch = state.input.charCodeAt(++state.position);
2094
2095
} else {
2096
tagHandle = '!';
2097
}
2098
2099
_position = state.position;
2100
2101
if (isVerbatim) {
2102
do { ch = state.input.charCodeAt(++state.position); }
2103
while (0 !== ch && 0x3E/* > */ !== ch);
2104
2105
if (state.position < state.length) {
2106
tagName = state.input.slice(_position, state.position);
2107
ch = state.input.charCodeAt(++state.position);
2108
} else {
2109
throwError(state, 'unexpected end of the stream within a verbatim tag');
2110
}
2111
} else {
2112
while (0 !== ch && !is_WS_OR_EOL(ch)) {
2113
2114
if (0x21/* ! */ === ch) {
2115
if (!isNamed) {
2116
tagHandle = state.input.slice(_position - 1, state.position + 1);
2117
2118
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2119
throwError(state, 'named tag handle cannot contain such characters');
2120
}
2121
2122
isNamed = true;
2123
_position = state.position + 1;
2124
} else {
2125
throwError(state, 'tag suffix cannot contain exclamation marks');
2126
}
2127
}
2128
2129
ch = state.input.charCodeAt(++state.position);
2130
}
2131
2132
tagName = state.input.slice(_position, state.position);
2133
2134
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2135
throwError(state, 'tag suffix cannot contain flow indicator characters');
2136
}
2137
}
2138
2139
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2140
throwError(state, 'tag name cannot contain such characters: ' + tagName);
2141
}
2142
2143
if (isVerbatim) {
2144
state.tag = tagName;
2145
2146
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
2147
state.tag = state.tagMap[tagHandle] + tagName;
2148
2149
} else if ('!' === tagHandle) {
2150
state.tag = '!' + tagName;
2151
2152
} else if ('!!' === tagHandle) {
2153
state.tag = 'tag:yaml.org,2002:' + tagName;
2154
2155
} else {
2156
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2157
}
2158
2159
return true;
2160
}
2161
2162
function readAnchorProperty(state) {
2163
var _position,
2164
ch;
2165
2166
ch = state.input.charCodeAt(state.position);
2167
2168
if (0x26/* & */ !== ch) {
2169
return false;
2170
}
2171
2172
if (null !== state.anchor) {
2173
throwError(state, 'duplication of an anchor property');
2174
}
2175
2176
ch = state.input.charCodeAt(++state.position);
2177
_position = state.position;
2178
2179
while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2180
ch = state.input.charCodeAt(++state.position);
2181
}
2182
2183
if (state.position === _position) {
2184
throwError(state, 'name of an anchor node must contain at least one character');
2185
}
2186
2187
state.anchor = state.input.slice(_position, state.position);
2188
return true;
2189
}
2190
2191
function readAlias(state) {
2192
var _position, alias,
2193
len = state.length,
2194
input = state.input,
2195
ch;
2196
2197
ch = state.input.charCodeAt(state.position);
2198
2199
if (0x2A/* * */ !== ch) {
2200
return false;
2201
}
2202
2203
ch = state.input.charCodeAt(++state.position);
2204
_position = state.position;
2205
2206
while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2207
ch = state.input.charCodeAt(++state.position);
2208
}
2209
2210
if (state.position === _position) {
2211
throwError(state, 'name of an alias node must contain at least one character');
2212
}
2213
2214
alias = state.input.slice(_position, state.position);
2215
2216
if (!state.anchorMap.hasOwnProperty(alias)) {
2217
throwError(state, 'unidentified alias "' + alias + '"');
2218
}
2219
2220
state.result = state.anchorMap[alias];
2221
skipSeparationSpace(state, true, -1);
2222
return true;
2223
}
2224
2225
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2226
var allowBlockStyles,
2227
allowBlockScalars,
2228
allowBlockCollections,
2229
indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
2230
atNewLine = false,
2231
hasContent = false,
2232
typeIndex,
2233
typeQuantity,
2234
type,
2235
flowIndent,
2236
blockIndent,
2237
_result;
2238
2239
state.tag = null;
2240
state.anchor = null;
2241
state.kind = null;
2242
state.result = null;
2243
2244
allowBlockStyles = allowBlockScalars = allowBlockCollections =
2245
CONTEXT_BLOCK_OUT === nodeContext ||
2246
CONTEXT_BLOCK_IN === nodeContext;
2247
2248
if (allowToSeek) {
2249
if (skipSeparationSpace(state, true, -1)) {
2250
atNewLine = true;
2251
2252
if (state.lineIndent > parentIndent) {
2253
indentStatus = 1;
2254
} else if (state.lineIndent === parentIndent) {
2255
indentStatus = 0;
2256
} else if (state.lineIndent < parentIndent) {
2257
indentStatus = -1;
2258
}
2259
}
2260
}
2261
2262
if (1 === indentStatus) {
2263
while (readTagProperty(state) || readAnchorProperty(state)) {
2264
if (skipSeparationSpace(state, true, -1)) {
2265
atNewLine = true;
2266
allowBlockCollections = allowBlockStyles;
2267
2268
if (state.lineIndent > parentIndent) {
2269
indentStatus = 1;
2270
} else if (state.lineIndent === parentIndent) {
2271
indentStatus = 0;
2272
} else if (state.lineIndent < parentIndent) {
2273
indentStatus = -1;
2274
}
2275
} else {
2276
allowBlockCollections = false;
2277
}
2278
}
2279
}
2280
2281
if (allowBlockCollections) {
2282
allowBlockCollections = atNewLine || allowCompact;
2283
}
2284
2285
if (1 === indentStatus || CONTEXT_BLOCK_OUT === nodeContext) {
2286
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2287
flowIndent = parentIndent;
2288
} else {
2289
flowIndent = parentIndent + 1;
2290
}
2291
2292
blockIndent = state.position - state.lineStart;
2293
2294
if (1 === indentStatus) {
2295
if (allowBlockCollections &&
2296
(readBlockSequence(state, blockIndent) ||
2297
readBlockMapping(state, blockIndent, flowIndent)) ||
2298
readFlowCollection(state, flowIndent)) {
2299
hasContent = true;
2300
} else {
2301
if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
2302
readSingleQuotedScalar(state, flowIndent) ||
2303
readDoubleQuotedScalar(state, flowIndent)) {
2304
hasContent = true;
2305
2306
} else if (readAlias(state)) {
2307
hasContent = true;
2308
2309
if (null !== state.tag || null !== state.anchor) {
2310
throwError(state, 'alias node should not have any properties');
2311
}
2312
2313
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2314
hasContent = true;
2315
2316
if (null === state.tag) {
2317
state.tag = '?';
2318
}
2319
}
2320
2321
if (null !== state.anchor) {
2322
state.anchorMap[state.anchor] = state.result;
2323
}
2324
}
2325
} else if (0 === indentStatus) {
2326
// Special case: block sequences are allowed to have same indentation level as the parent.
2327
// http://www.yaml.org/spec/1.2/spec.html#id2799784
2328
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2329
}
2330
}
2331
2332
if (null !== state.tag && '!' !== state.tag) {
2333
if ('?' === state.tag) {
2334
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
2335
typeIndex < typeQuantity;
2336
typeIndex += 1) {
2337
type = state.implicitTypes[typeIndex];
2338
2339
// Implicit resolving is not allowed for non-scalar types, and '?'
2340
// non-specific tag is only assigned to plain scalars. So, it isn't
2341
// needed to check for 'kind' conformity.
2342
2343
if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
2344
state.result = type.construct(state.result);
2345
state.tag = type.tag;
2346
if (null !== state.anchor) {
2347
state.anchorMap[state.anchor] = state.result;
2348
}
2349
break;
2350
}
2351
}
2352
} else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
2353
type = state.typeMap[state.tag];
2354
2355
if (null !== state.result && type.kind !== state.kind) {
2356
throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2357
}
2358
2359
if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
2360
throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
2361
} else {
2362
state.result = type.construct(state.result);
2363
if (null !== state.anchor) {
2364
state.anchorMap[state.anchor] = state.result;
2365
}
2366
}
2367
} else {
2368
throwWarning(state, 'unknown tag !<' + state.tag + '>');
2369
}
2370
}
2371
2372
return null !== state.tag || null !== state.anchor || hasContent;
2373
}
2374
2375
function readDocument(state) {
2376
var documentStart = state.position,
2377
_position,
2378
directiveName,
2379
directiveArgs,
2380
hasDirectives = false,
2381
ch;
2382
2383
state.version = null;
2384
state.checkLineBreaks = state.legacy;
2385
state.tagMap = {};
2386
state.anchorMap = {};
2387
2388
while (0 !== (ch = state.input.charCodeAt(state.position))) {
2389
skipSeparationSpace(state, true, -1);
2390
2391
ch = state.input.charCodeAt(state.position);
2392
2393
if (state.lineIndent > 0 || 0x25/* % */ !== ch) {
2394
break;
2395
}
2396
2397
hasDirectives = true;
2398
ch = state.input.charCodeAt(++state.position);
2399
_position = state.position;
2400
2401
while (0 !== ch && !is_WS_OR_EOL(ch)) {
2402
ch = state.input.charCodeAt(++state.position);
2403
}
2404
2405
directiveName = state.input.slice(_position, state.position);
2406
directiveArgs = [];
2407
2408
if (directiveName.length < 1) {
2409
throwError(state, 'directive name must not be less than one character in length');
2410
}
2411
2412
while (0 !== ch) {
2413
while (is_WHITE_SPACE(ch)) {
2414
ch = state.input.charCodeAt(++state.position);
2415
}
2416
2417
if (0x23/* # */ === ch) {
2418
do { ch = state.input.charCodeAt(++state.position); }
2419
while (0 !== ch && !is_EOL(ch));
2420
break;
2421
}
2422
2423
if (is_EOL(ch)) {
2424
break;
2425
}
2426
2427
_position = state.position;
2428
2429
while (0 !== ch && !is_WS_OR_EOL(ch)) {
2430
ch = state.input.charCodeAt(++state.position);
2431
}
2432
2433
directiveArgs.push(state.input.slice(_position, state.position));
2434
}
2435
2436
if (0 !== ch) {
2437
readLineBreak(state);
2438
}
2439
2440
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2441
directiveHandlers[directiveName](state, directiveName, directiveArgs);
2442
} else {
2443
throwWarning(state, 'unknown document directive "' + directiveName + '"');
2444
}
2445
}
2446
2447
skipSeparationSpace(state, true, -1);
2448
2449
if (0 === state.lineIndent &&
2450
0x2D/* - */ === state.input.charCodeAt(state.position) &&
2451
0x2D/* - */ === state.input.charCodeAt(state.position + 1) &&
2452
0x2D/* - */ === state.input.charCodeAt(state.position + 2)) {
2453
state.position += 3;
2454
skipSeparationSpace(state, true, -1);
2455
2456
} else if (hasDirectives) {
2457
throwError(state, 'directives end mark is expected');
2458
}
2459
2460
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2461
skipSeparationSpace(state, true, -1);
2462
2463
if (state.checkLineBreaks &&
2464
PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2465
throwWarning(state, 'non-ASCII line breaks are interpreted as content');
2466
}
2467
2468
state.documents.push(state.result);
2469
2470
if (state.position === state.lineStart && testDocumentSeparator(state)) {
2471
2472
if (0x2E/* . */ === state.input.charCodeAt(state.position)) {
2473
state.position += 3;
2474
skipSeparationSpace(state, true, -1);
2475
}
2476
return;
2477
}
2478
2479
if (state.position < (state.length - 1)) {
2480
throwError(state, 'end of the stream or a document separator is expected');
2481
} else {
2482
return;
2483
}
2484
}
2485
2486
2487
function loadDocuments(input, options) {
2488
input = String(input);
2489
options = options || {};
2490
2491
if (input.length !== 0) {
2492
2493
// Add tailing `\n` if not exists
2494
if (0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
2495
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
2496
input += '\n';
2497
}
2498
2499
// Strip BOM
2500
if (input.charCodeAt(0) === 0xFEFF) {
2501
input = input.slice(1);
2502
}
2503
}
2504
2505
var state = new State(input, options);
2506
2507
if (PATTERN_NON_PRINTABLE.test(state.input)) {
2508
throwError(state, 'the stream contains non-printable characters');
2509
}
2510
2511
// Use 0 as string terminator. That significantly simplifies bounds check.
2512
state.input += '\0';
2513
2514
while (0x20/* Space */ === state.input.charCodeAt(state.position)) {
2515
state.lineIndent += 1;
2516
state.position += 1;
2517
}
2518
2519
while (state.position < (state.length - 1)) {
2520
readDocument(state);
2521
}
2522
2523
return state.documents;
2524
}
2525
2526
2527
function loadAll(input, iterator, options) {
2528
var documents = loadDocuments(input, options), index, length;
2529
2530
for (index = 0, length = documents.length; index < length; index += 1) {
2531
iterator(documents[index]);
2532
}
2533
}
2534
2535
2536
function load(input, options) {
2537
var documents = loadDocuments(input, options), index, length;
2538
2539
if (0 === documents.length) {
2540
/*eslint-disable no-undefined*/
2541
return undefined;
2542
} else if (1 === documents.length) {
2543
return documents[0];
2544
}
2545
throw new YAMLException('expected a single document in the stream, but found more');
2546
}
2547
2548
2549
function safeLoadAll(input, output, options) {
2550
loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2551
}
2552
2553
2554
function safeLoad(input, options) {
2555
return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2556
}
2557
2558
2559
module.exports.loadAll = loadAll;
2560
module.exports.load = load;
2561
module.exports.safeLoadAll = safeLoadAll;
2562
module.exports.safeLoad = safeLoad;
2563
2564
},{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){
2565
'use strict';
2566
2567
2568
var common = require('./common');
2569
2570
2571
function Mark(name, buffer, position, line, column) {
2572
this.name = name;
2573
this.buffer = buffer;
2574
this.position = position;
2575
this.line = line;
2576
this.column = column;
2577
}
2578
2579
2580
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2581
var head, start, tail, end, snippet;
2582
2583
if (!this.buffer) {
2584
return null;
2585
}
2586
2587
indent = indent || 4;
2588
maxLength = maxLength || 75;
2589
2590
head = '';
2591
start = this.position;
2592
2593
while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
2594
start -= 1;
2595
if (this.position - start > (maxLength / 2 - 1)) {
2596
head = ' ... ';
2597
start += 5;
2598
break;
2599
}
2600
}
2601
2602
tail = '';
2603
end = this.position;
2604
2605
while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
2606
end += 1;
2607
if (end - this.position > (maxLength / 2 - 1)) {
2608
tail = ' ... ';
2609
end -= 5;
2610
break;
2611
}
2612
}
2613
2614
snippet = this.buffer.slice(start, end);
2615
2616
return common.repeat(' ', indent) + head + snippet + tail + '\n' +
2617
common.repeat(' ', indent + this.position - start + head.length) + '^';
2618
};
2619
2620
2621
Mark.prototype.toString = function toString(compact) {
2622
var snippet, where = '';
2623
2624
if (this.name) {
2625
where += 'in "' + this.name + '" ';
2626
}
2627
2628
where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
2629
2630
if (!compact) {
2631
snippet = this.getSnippet();
2632
2633
if (snippet) {
2634
where += ':\n' + snippet;
2635
}
2636
}
2637
2638
return where;
2639
};
2640
2641
2642
module.exports = Mark;
2643
2644
},{"./common":2}],7:[function(require,module,exports){
2645
'use strict';
2646
2647
/*eslint-disable max-len*/
2648
2649
var common = require('./common');
2650
var YAMLException = require('./exception');
2651
var Type = require('./type');
2652
2653
2654
function compileList(schema, name, result) {
2655
var exclude = [];
2656
2657
schema.include.forEach(function (includedSchema) {
2658
result = compileList(includedSchema, name, result);
2659
});
2660
2661
schema[name].forEach(function (currentType) {
2662
result.forEach(function (previousType, previousIndex) {
2663
if (previousType.tag === currentType.tag) {
2664
exclude.push(previousIndex);
2665
}
2666
});
2667
2668
result.push(currentType);
2669
});
2670
2671
return result.filter(function (type, index) {
2672
return -1 === exclude.indexOf(index);
2673
});
2674
}
2675
2676
2677
function compileMap(/* lists... */) {
2678
var result = {}, index, length;
2679
2680
function collectType(type) {
2681
result[type.tag] = type;
2682
}
2683
2684
for (index = 0, length = arguments.length; index < length; index += 1) {
2685
arguments[index].forEach(collectType);
2686
}
2687
2688
return result;
2689
}
2690
2691
2692
function Schema(definition) {
2693
this.include = definition.include || [];
2694
this.implicit = definition.implicit || [];
2695
this.explicit = definition.explicit || [];
2696
2697
this.implicit.forEach(function (type) {
2698
if (type.loadKind && 'scalar' !== type.loadKind) {
2699
throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
2700
}
2701
});
2702
2703
this.compiledImplicit = compileList(this, 'implicit', []);
2704
this.compiledExplicit = compileList(this, 'explicit', []);
2705
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
2706
}
2707
2708
2709
Schema.DEFAULT = null;
2710
2711
2712
Schema.create = function createSchema() {
2713
var schemas, types;
2714
2715
switch (arguments.length) {
2716
case 1:
2717
schemas = Schema.DEFAULT;
2718
types = arguments[0];
2719
break;
2720
2721
case 2:
2722
schemas = arguments[0];
2723
types = arguments[1];
2724
break;
2725
2726
default:
2727
throw new YAMLException('Wrong number of arguments for Schema.create function');
2728
}
2729
2730
schemas = common.toArray(schemas);
2731
types = common.toArray(types);
2732
2733
if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
2734
throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
2735
}
2736
2737
if (!types.every(function (type) { return type instanceof Type; })) {
2738
throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
2739
}
2740
2741
return new Schema({
2742
include: schemas,
2743
explicit: types
2744
});
2745
};
2746
2747
2748
module.exports = Schema;
2749
2750
},{"./common":2,"./exception":4,"./type":13}],8:[function(require,module,exports){
2751
// Standard YAML's Core schema.
2752
// http://www.yaml.org/spec/1.2/spec.html#id2804923
2753
//
2754
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2755
// So, Core schema has no distinctions from JSON schema is JS-YAML.
2756
2757
2758
'use strict';
2759
2760
2761
var Schema = require('../schema');
2762
2763
2764
module.exports = new Schema({
2765
include: [
2766
require('./json')
2767
]
2768
});
2769
2770
},{"../schema":7,"./json":12}],9:[function(require,module,exports){
2771
// JS-YAML's default schema for `load` function.
2772
// It is not described in the YAML specification.
2773
//
2774
// This schema is based on JS-YAML's default safe schema and includes
2775
// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
2776
//
2777
// Also this schema is used as default base schema at `Schema.create` function.
2778
2779
2780
'use strict';
2781
2782
2783
var Schema = require('../schema');
2784
2785
2786
module.exports = Schema.DEFAULT = new Schema({
2787
include: [
2788
require('./default_safe')
2789
],
2790
explicit: [
2791
require('../type/js/undefined'),
2792
require('../type/js/regexp'),
2793
require('../type/js/function')
2794
]
2795
});
2796
2797
},{"../schema":7,"../type/js/function":18,"../type/js/regexp":19,"../type/js/undefined":20,"./default_safe":10}],10:[function(require,module,exports){
2798
// JS-YAML's default schema for `safeLoad` function.
2799
// It is not described in the YAML specification.
2800
//
2801
// This schema is based on standard YAML's Core schema and includes most of
2802
// extra types described at YAML tag repository. (http://yaml.org/type/)
2803
2804
2805
'use strict';
2806
2807
2808
var Schema = require('../schema');
2809
2810
2811
module.exports = new Schema({
2812
include: [
2813
require('./core')
2814
],
2815
implicit: [
2816
require('../type/timestamp'),
2817
require('../type/merge')
2818
],
2819
explicit: [
2820
require('../type/binary'),
2821
require('../type/omap'),
2822
require('../type/pairs'),
2823
require('../type/set')
2824
]
2825
});
2826
2827
},{"../schema":7,"../type/binary":14,"../type/merge":22,"../type/omap":24,"../type/pairs":25,"../type/set":27,"../type/timestamp":29,"./core":8}],11:[function(require,module,exports){
2828
// Standard YAML's Failsafe schema.
2829
// http://www.yaml.org/spec/1.2/spec.html#id2802346
2830
2831
2832
'use strict';
2833
2834
2835
var Schema = require('../schema');
2836
2837
2838
module.exports = new Schema({
2839
explicit: [
2840
require('../type/str'),
2841
require('../type/seq'),
2842
require('../type/map')
2843
]
2844
});
2845
2846
},{"../schema":7,"../type/map":21,"../type/seq":26,"../type/str":28}],12:[function(require,module,exports){
2847
// Standard YAML's JSON schema.
2848
// http://www.yaml.org/spec/1.2/spec.html#id2803231
2849
//
2850
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2851
// So, this schema is not such strict as defined in the YAML specification.
2852
// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
2853
2854
2855
'use strict';
2856
2857
2858
var Schema = require('../schema');
2859
2860
2861
module.exports = new Schema({
2862
include: [
2863
require('./failsafe')
2864
],
2865
implicit: [
2866
require('../type/null'),
2867
require('../type/bool'),
2868
require('../type/int'),
2869
require('../type/float')
2870
]
2871
});
2872
2873
},{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){
2874
'use strict';
2875
2876
var YAMLException = require('./exception');
2877
2878
var TYPE_CONSTRUCTOR_OPTIONS = [
2879
'kind',
2880
'resolve',
2881
'construct',
2882
'instanceOf',
2883
'predicate',
2884
'represent',
2885
'defaultStyle',
2886
'styleAliases'
2887
];
2888
2889
var YAML_NODE_KINDS = [
2890
'scalar',
2891
'sequence',
2892
'mapping'
2893
];
2894
2895
function compileStyleAliases(map) {
2896
var result = {};
2897
2898
if (null !== map) {
2899
Object.keys(map).forEach(function (style) {
2900
map[style].forEach(function (alias) {
2901
result[String(alias)] = style;
2902
});
2903
});
2904
}
2905
2906
return result;
2907
}
2908
2909
function Type(tag, options) {
2910
options = options || {};
2911
2912
Object.keys(options).forEach(function (name) {
2913
if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
2914
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
2915
}
2916
});
2917
2918
// TODO: Add tag format check.
2919
this.tag = tag;
2920
this.kind = options['kind'] || null;
2921
this.resolve = options['resolve'] || function () { return true; };
2922
this.construct = options['construct'] || function (data) { return data; };
2923
this.instanceOf = options['instanceOf'] || null;
2924
this.predicate = options['predicate'] || null;
2925
this.represent = options['represent'] || null;
2926
this.defaultStyle = options['defaultStyle'] || null;
2927
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
2928
2929
if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
2930
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
2931
}
2932
}
2933
2934
module.exports = Type;
2935
2936
},{"./exception":4}],14:[function(require,module,exports){
2937
'use strict';
2938
2939
/*eslint-disable no-bitwise*/
2940
2941
// A trick for browserified version.
2942
// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
2943
var NodeBuffer = require('buffer').Buffer;
2944
var Type = require('../type');
2945
2946
2947
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
2948
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
2949
2950
2951
function resolveYamlBinary(data) {
2952
if (null === data) {
2953
return false;
2954
}
2955
2956
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
2957
2958
// Convert one by one.
2959
for (idx = 0; idx < max; idx++) {
2960
code = map.indexOf(data.charAt(idx));
2961
2962
// Skip CR/LF
2963
if (code > 64) { continue; }
2964
2965
// Fail on illegal characters
2966
if (code < 0) { return false; }
2967
2968
bitlen += 6;
2969
}
2970
2971
// If there are any bits left, source was corrupted
2972
return (bitlen % 8) === 0;
2973
}
2974
2975
function constructYamlBinary(data) {
2976
var code, idx, tailbits,
2977
input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
2978
max = input.length,
2979
map = BASE64_MAP,
2980
bits = 0,
2981
result = [];
2982
2983
// Collect by 6*4 bits (3 bytes)
2984
2985
for (idx = 0; idx < max; idx++) {
2986
if ((idx % 4 === 0) && idx) {
2987
result.push((bits >> 16) & 0xFF);
2988
result.push((bits >> 8) & 0xFF);
2989
result.push(bits & 0xFF);
2990
}
2991
2992
bits = (bits << 6) | map.indexOf(input.charAt(idx));
2993
}
2994
2995
// Dump tail
2996
2997
tailbits = (max % 4) * 6;
2998
2999
if (tailbits === 0) {
3000
result.push((bits >> 16) & 0xFF);
3001
result.push((bits >> 8) & 0xFF);
3002
result.push(bits & 0xFF);
3003
} else if (tailbits === 18) {
3004
result.push((bits >> 10) & 0xFF);
3005
result.push((bits >> 2) & 0xFF);
3006
} else if (tailbits === 12) {
3007
result.push((bits >> 4) & 0xFF);
3008
}
3009
3010
// Wrap into Buffer for NodeJS and leave Array for browser
3011
if (NodeBuffer) {
3012
return new NodeBuffer(result);
3013
}
3014
3015
return result;
3016
}
3017
3018
function representYamlBinary(object /*, style*/) {
3019
var result = '', bits = 0, idx, tail,
3020
max = object.length,
3021
map = BASE64_MAP;
3022
3023
// Convert every three bytes to 4 ASCII characters.
3024
3025
for (idx = 0; idx < max; idx++) {
3026
if ((idx % 3 === 0) && idx) {
3027
result += map[(bits >> 18) & 0x3F];
3028
result += map[(bits >> 12) & 0x3F];
3029
result += map[(bits >> 6) & 0x3F];
3030
result += map[bits & 0x3F];
3031
}
3032
3033
bits = (bits << 8) + object[idx];
3034
}
3035
3036
// Dump tail
3037
3038
tail = max % 3;
3039
3040
if (tail === 0) {
3041
result += map[(bits >> 18) & 0x3F];
3042
result += map[(bits >> 12) & 0x3F];
3043
result += map[(bits >> 6) & 0x3F];
3044
result += map[bits & 0x3F];
3045
} else if (tail === 2) {
3046
result += map[(bits >> 10) & 0x3F];
3047
result += map[(bits >> 4) & 0x3F];
3048
result += map[(bits << 2) & 0x3F];
3049
result += map[64];
3050
} else if (tail === 1) {
3051
result += map[(bits >> 2) & 0x3F];
3052
result += map[(bits << 4) & 0x3F];
3053
result += map[64];
3054
result += map[64];
3055
}
3056
3057
return result;
3058
}
3059
3060
function isBinary(object) {
3061
return NodeBuffer && NodeBuffer.isBuffer(object);
3062
}
3063
3064
module.exports = new Type('tag:yaml.org,2002:binary', {
3065
kind: 'scalar',
3066
resolve: resolveYamlBinary,
3067
construct: constructYamlBinary,
3068
predicate: isBinary,
3069
represent: representYamlBinary
3070
});
3071
3072
},{"../type":13,"buffer":30}],15:[function(require,module,exports){
3073
'use strict';
3074
3075
var Type = require('../type');
3076
3077
function resolveYamlBoolean(data) {
3078
if (null === data) {
3079
return false;
3080
}
3081
3082
var max = data.length;
3083
3084
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
3085
(max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
3086
}
3087
3088
function constructYamlBoolean(data) {
3089
return data === 'true' ||
3090
data === 'True' ||
3091
data === 'TRUE';
3092
}
3093
3094
function isBoolean(object) {
3095
return '[object Boolean]' === Object.prototype.toString.call(object);
3096
}
3097
3098
module.exports = new Type('tag:yaml.org,2002:bool', {
3099
kind: 'scalar',
3100
resolve: resolveYamlBoolean,
3101
construct: constructYamlBoolean,
3102
predicate: isBoolean,
3103
represent: {
3104
lowercase: function (object) { return object ? 'true' : 'false'; },
3105
uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
3106
camelcase: function (object) { return object ? 'True' : 'False'; }
3107
},
3108
defaultStyle: 'lowercase'
3109
});
3110
3111
},{"../type":13}],16:[function(require,module,exports){
3112
'use strict';
3113
3114
var common = require('../common');
3115
var Type = require('../type');
3116
3117
var YAML_FLOAT_PATTERN = new RegExp(
3118
'^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
3119
'|\\.[0-9_]+(?:[eE][-+][0-9]+)?' +
3120
'|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
3121
'|[-+]?\\.(?:inf|Inf|INF)' +
3122
'|\\.(?:nan|NaN|NAN))$');
3123
3124
function resolveYamlFloat(data) {
3125
if (null === data) {
3126
return false;
3127
}
3128
3129
var value, sign, base, digits;
3130
3131
if (!YAML_FLOAT_PATTERN.test(data)) {
3132
return false;
3133
}
3134
return true;
3135
}
3136
3137
function constructYamlFloat(data) {
3138
var value, sign, base, digits;
3139
3140
value = data.replace(/_/g, '').toLowerCase();
3141
sign = '-' === value[0] ? -1 : 1;
3142
digits = [];
3143
3144
if (0 <= '+-'.indexOf(value[0])) {
3145
value = value.slice(1);
3146
}
3147
3148
if ('.inf' === value) {
3149
return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
3150
3151
} else if ('.nan' === value) {
3152
return NaN;
3153
3154
} else if (0 <= value.indexOf(':')) {
3155
value.split(':').forEach(function (v) {
3156
digits.unshift(parseFloat(v, 10));
3157
});
3158
3159
value = 0.0;
3160
base = 1;
3161
3162
digits.forEach(function (d) {
3163
value += d * base;
3164
base *= 60;
3165
});
3166
3167
return sign * value;
3168
3169
}
3170
return sign * parseFloat(value, 10);
3171
}
3172
3173
function representYamlFloat(object, style) {
3174
if (isNaN(object)) {
3175
switch (style) {
3176
case 'lowercase':
3177
return '.nan';
3178
case 'uppercase':
3179
return '.NAN';
3180
case 'camelcase':
3181
return '.NaN';
3182
}
3183
} else if (Number.POSITIVE_INFINITY === object) {
3184
switch (style) {
3185
case 'lowercase':
3186
return '.inf';
3187
case 'uppercase':
3188
return '.INF';
3189
case 'camelcase':
3190
return '.Inf';
3191
}
3192
} else if (Number.NEGATIVE_INFINITY === object) {
3193
switch (style) {
3194
case 'lowercase':
3195
return '-.inf';
3196
case 'uppercase':
3197
return '-.INF';
3198
case 'camelcase':
3199
return '-.Inf';
3200
}
3201
} else if (common.isNegativeZero(object)) {
3202
return '-0.0';
3203
}
3204
return object.toString(10);
3205
}
3206
3207
function isFloat(object) {
3208
return ('[object Number]' === Object.prototype.toString.call(object)) &&
3209
(0 !== object % 1 || common.isNegativeZero(object));
3210
}
3211
3212
module.exports = new Type('tag:yaml.org,2002:float', {
3213
kind: 'scalar',
3214
resolve: resolveYamlFloat,
3215
construct: constructYamlFloat,
3216
predicate: isFloat,
3217
represent: representYamlFloat,
3218
defaultStyle: 'lowercase'
3219
});
3220
3221
},{"../common":2,"../type":13}],17:[function(require,module,exports){
3222
'use strict';
3223
3224
var common = require('../common');
3225
var Type = require('../type');
3226
3227
function isHexCode(c) {
3228
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
3229
((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
3230
((0x61/* a */ <= c) && (c <= 0x66/* f */));
3231
}
3232
3233
function isOctCode(c) {
3234
return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
3235
}
3236
3237
function isDecCode(c) {
3238
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
3239
}
3240
3241
function resolveYamlInteger(data) {
3242
if (null === data) {
3243
return false;
3244
}
3245
3246
var max = data.length,
3247
index = 0,
3248
hasDigits = false,
3249
ch;
3250
3251
if (!max) { return false; }
3252
3253
ch = data[index];
3254
3255
// sign
3256
if (ch === '-' || ch === '+') {
3257
ch = data[++index];
3258
}
3259
3260
if (ch === '0') {
3261
// 0
3262
if (index + 1 === max) { return true; }
3263
ch = data[++index];
3264
3265
// base 2, base 8, base 16
3266
3267
if (ch === 'b') {
3268
// base 2
3269
index++;
3270
3271
for (; index < max; index++) {
3272
ch = data[index];
3273
if (ch === '_') { continue; }
3274
if (ch !== '0' && ch !== '1') {
3275
return false;
3276
}
3277
hasDigits = true;
3278
}
3279
return hasDigits;
3280
}
3281
3282
3283
if (ch === 'x') {
3284
// base 16
3285
index++;
3286
3287
for (; index < max; index++) {
3288
ch = data[index];
3289
if (ch === '_') { continue; }
3290
if (!isHexCode(data.charCodeAt(index))) {
3291
return false;
3292
}
3293
hasDigits = true;
3294
}
3295
return hasDigits;
3296
}
3297
3298
// base 8
3299
for (; index < max; index++) {
3300
ch = data[index];
3301
if (ch === '_') { continue; }
3302
if (!isOctCode(data.charCodeAt(index))) {
3303
return false;
3304
}
3305
hasDigits = true;
3306
}
3307
return hasDigits;
3308
}
3309
3310
// base 10 (except 0) or base 60
3311
3312
for (; index < max; index++) {
3313
ch = data[index];
3314
if (ch === '_') { continue; }
3315
if (ch === ':') { break; }
3316
if (!isDecCode(data.charCodeAt(index))) {
3317
return false;
3318
}
3319
hasDigits = true;
3320
}
3321
3322
if (!hasDigits) { return false; }
3323
3324
// if !base60 - done;
3325
if (ch !== ':') { return true; }
3326
3327
// base60 almost not used, no needs to optimize
3328
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
3329
}
3330
3331
function constructYamlInteger(data) {
3332
var value = data, sign = 1, ch, base, digits = [];
3333
3334
if (value.indexOf('_') !== -1) {
3335
value = value.replace(/_/g, '');
3336
}
3337
3338
ch = value[0];
3339
3340
if (ch === '-' || ch === '+') {
3341
if (ch === '-') { sign = -1; }
3342
value = value.slice(1);
3343
ch = value[0];
3344
}
3345
3346
if ('0' === value) {
3347
return 0;
3348
}
3349
3350
if (ch === '0') {
3351
if (value[1] === 'b') {
3352
return sign * parseInt(value.slice(2), 2);
3353
}
3354
if (value[1] === 'x') {
3355
return sign * parseInt(value, 16);
3356
}
3357
return sign * parseInt(value, 8);
3358
3359
}
3360
3361
if (value.indexOf(':') !== -1) {
3362
value.split(':').forEach(function (v) {
3363
digits.unshift(parseInt(v, 10));
3364
});
3365
3366
value = 0;
3367
base = 1;
3368
3369
digits.forEach(function (d) {
3370
value += (d * base);
3371
base *= 60;
3372
});
3373
3374
return sign * value;
3375
3376
}
3377
3378
return sign * parseInt(value, 10);
3379
}
3380
3381
function isInteger(object) {
3382
return ('[object Number]' === Object.prototype.toString.call(object)) &&
3383
(0 === object % 1 && !common.isNegativeZero(object));
3384
}
3385
3386
module.exports = new Type('tag:yaml.org,2002:int', {
3387
kind: 'scalar',
3388
resolve: resolveYamlInteger,
3389
construct: constructYamlInteger,
3390
predicate: isInteger,
3391
represent: {
3392
binary: function (object) { return '0b' + object.toString(2); },
3393
octal: function (object) { return '0' + object.toString(8); },
3394
decimal: function (object) { return object.toString(10); },
3395
hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
3396
},
3397
defaultStyle: 'decimal',
3398
styleAliases: {
3399
binary: [ 2, 'bin' ],
3400
octal: [ 8, 'oct' ],
3401
decimal: [ 10, 'dec' ],
3402
hexadecimal: [ 16, 'hex' ]
3403
}
3404
});
3405
3406
},{"../common":2,"../type":13}],18:[function(require,module,exports){
3407
'use strict';
3408
3409
var esprima;
3410
3411
// Browserified version does not have esprima
3412
//
3413
// 1. For node.js just require module as deps
3414
// 2. For browser try to require mudule via external AMD system.
3415
// If not found - try to fallback to window.esprima. If not
3416
// found too - then fail to parse.
3417
//
3418
try {
3419
esprima = require('esprima');
3420
} catch (_) {
3421
/*global window */
3422
if (typeof window !== 'undefined') { esprima = window.esprima; }
3423
}
3424
3425
var Type = require('../../type');
3426
3427
function resolveJavascriptFunction(data) {
3428
if (null === data) {
3429
return false;
3430
}
3431
3432
try {
3433
var source = '(' + data + ')',
3434
ast = esprima.parse(source, { range: true }),
3435
params = [],
3436
body;
3437
3438
if ('Program' !== ast.type ||
3439
1 !== ast.body.length ||
3440
'ExpressionStatement' !== ast.body[0].type ||
3441
'FunctionExpression' !== ast.body[0].expression.type) {
3442
return false;
3443
}
3444
3445
return true;
3446
} catch (err) {
3447
return false;
3448
}
3449
}
3450
3451
function constructJavascriptFunction(data) {
3452
/*jslint evil:true*/
3453
3454
var source = '(' + data + ')',
3455
ast = esprima.parse(source, { range: true }),
3456
params = [],
3457
body;
3458
3459
if ('Program' !== ast.type ||
3460
1 !== ast.body.length ||
3461
'ExpressionStatement' !== ast.body[0].type ||
3462
'FunctionExpression' !== ast.body[0].expression.type) {
3463
throw new Error('Failed to resolve function');
3464
}
3465
3466
ast.body[0].expression.params.forEach(function (param) {
3467
params.push(param.name);
3468
});
3469
3470
body = ast.body[0].expression.body.range;
3471
3472
// Esprima's ranges include the first '{' and the last '}' characters on
3473
// function expressions. So cut them out.
3474
/*eslint-disable no-new-func*/
3475
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
3476
}
3477
3478
function representJavascriptFunction(object /*, style*/) {
3479
return object.toString();
3480
}
3481
3482
function isFunction(object) {
3483
return '[object Function]' === Object.prototype.toString.call(object);
3484
}
3485
3486
module.exports = new Type('tag:yaml.org,2002:js/function', {
3487
kind: 'scalar',
3488
resolve: resolveJavascriptFunction,
3489
construct: constructJavascriptFunction,
3490
predicate: isFunction,
3491
represent: representJavascriptFunction
3492
});
3493
3494
},{"../../type":13,"esprima":"esprima"}],19:[function(require,module,exports){
3495
'use strict';
3496
3497
var Type = require('../../type');
3498
3499
function resolveJavascriptRegExp(data) {
3500
if (null === data) {
3501
return false;
3502
}
3503
3504
if (0 === data.length) {
3505
return false;
3506
}
3507
3508
var regexp = data,
3509
tail = /\/([gim]*)$/.exec(data),
3510
modifiers = '';
3511
3512
// if regexp starts with '/' it can have modifiers and must be properly closed
3513
// `/foo/gim` - modifiers tail can be maximum 3 chars
3514
if ('/' === regexp[0]) {
3515
if (tail) {
3516
modifiers = tail[1];
3517
}
3518
3519
if (modifiers.length > 3) { return false; }
3520
// if expression starts with /, is should be properly terminated
3521
if (regexp[regexp.length - modifiers.length - 1] !== '/') { return false; }
3522
3523
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3524
}
3525
3526
try {
3527
var dummy = new RegExp(regexp, modifiers);
3528
return true;
3529
} catch (error) {
3530
return false;
3531
}
3532
}
3533
3534
function constructJavascriptRegExp(data) {
3535
var regexp = data,
3536
tail = /\/([gim]*)$/.exec(data),
3537
modifiers = '';
3538
3539
// `/foo/gim` - tail can be maximum 4 chars
3540
if ('/' === regexp[0]) {
3541
if (tail) {
3542
modifiers = tail[1];
3543
}
3544
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3545
}
3546
3547
return new RegExp(regexp, modifiers);
3548
}
3549
3550
function representJavascriptRegExp(object /*, style*/) {
3551
var result = '/' + object.source + '/';
3552
3553
if (object.global) {
3554
result += 'g';
3555
}
3556
3557
if (object.multiline) {
3558
result += 'm';
3559
}
3560
3561
if (object.ignoreCase) {
3562
result += 'i';
3563
}
3564
3565
return result;
3566
}
3567
3568
function isRegExp(object) {
3569
return '[object RegExp]' === Object.prototype.toString.call(object);
3570
}
3571
3572
module.exports = new Type('tag:yaml.org,2002:js/regexp', {
3573
kind: 'scalar',
3574
resolve: resolveJavascriptRegExp,
3575
construct: constructJavascriptRegExp,
3576
predicate: isRegExp,
3577
represent: representJavascriptRegExp
3578
});
3579
3580
},{"../../type":13}],20:[function(require,module,exports){
3581
'use strict';
3582
3583
var Type = require('../../type');
3584
3585
function resolveJavascriptUndefined() {
3586
return true;
3587
}
3588
3589
function constructJavascriptUndefined() {
3590
/*eslint-disable no-undefined*/
3591
return undefined;
3592
}
3593
3594
function representJavascriptUndefined() {
3595
return '';
3596
}
3597
3598
function isUndefined(object) {
3599
return 'undefined' === typeof object;
3600
}
3601
3602
module.exports = new Type('tag:yaml.org,2002:js/undefined', {
3603
kind: 'scalar',
3604
resolve: resolveJavascriptUndefined,
3605
construct: constructJavascriptUndefined,
3606
predicate: isUndefined,
3607
represent: representJavascriptUndefined
3608
});
3609
3610
},{"../../type":13}],21:[function(require,module,exports){
3611
'use strict';
3612
3613
var Type = require('../type');
3614
3615
module.exports = new Type('tag:yaml.org,2002:map', {
3616
kind: 'mapping',
3617
construct: function (data) { return null !== data ? data : {}; }
3618
});
3619
3620
},{"../type":13}],22:[function(require,module,exports){
3621
'use strict';
3622
3623
var Type = require('../type');
3624
3625
function resolveYamlMerge(data) {
3626
return '<<' === data || null === data;
3627
}
3628
3629
module.exports = new Type('tag:yaml.org,2002:merge', {
3630
kind: 'scalar',
3631
resolve: resolveYamlMerge
3632
});
3633
3634
},{"../type":13}],23:[function(require,module,exports){
3635
'use strict';
3636
3637
var Type = require('../type');
3638
3639
function resolveYamlNull(data) {
3640
if (null === data) {
3641
return true;
3642
}
3643
3644
var max = data.length;
3645
3646
return (max === 1 && data === '~') ||
3647
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
3648
}
3649
3650
function constructYamlNull() {
3651
return null;
3652
}
3653
3654
function isNull(object) {
3655
return null === object;
3656
}
3657
3658
module.exports = new Type('tag:yaml.org,2002:null', {
3659
kind: 'scalar',
3660
resolve: resolveYamlNull,
3661
construct: constructYamlNull,
3662
predicate: isNull,
3663
represent: {
3664
canonical: function () { return '~'; },
3665
lowercase: function () { return 'null'; },
3666
uppercase: function () { return 'NULL'; },
3667
camelcase: function () { return 'Null'; }
3668
},
3669
defaultStyle: 'lowercase'
3670
});
3671
3672
},{"../type":13}],24:[function(require,module,exports){
3673
'use strict';
3674
3675
var Type = require('../type');
3676
3677
var _hasOwnProperty = Object.prototype.hasOwnProperty;
3678
var _toString = Object.prototype.toString;
3679
3680
function resolveYamlOmap(data) {
3681
if (null === data) {
3682
return true;
3683
}
3684
3685
var objectKeys = [], index, length, pair, pairKey, pairHasKey,
3686
object = data;
3687
3688
for (index = 0, length = object.length; index < length; index += 1) {
3689
pair = object[index];
3690
pairHasKey = false;
3691
3692
if ('[object Object]' !== _toString.call(pair)) {
3693
return false;
3694
}
3695
3696
for (pairKey in pair) {
3697
if (_hasOwnProperty.call(pair, pairKey)) {
3698
if (!pairHasKey) {
3699
pairHasKey = true;
3700
} else {
3701
return false;
3702
}
3703
}
3704
}
3705
3706
if (!pairHasKey) {
3707
return false;
3708
}
3709
3710
if (-1 === objectKeys.indexOf(pairKey)) {
3711
objectKeys.push(pairKey);
3712
} else {
3713
return false;
3714
}
3715
}
3716
3717
return true;
3718
}
3719
3720
function constructYamlOmap(data) {
3721
return null !== data ? data : [];
3722
}
3723
3724
module.exports = new Type('tag:yaml.org,2002:omap', {
3725
kind: 'sequence',
3726
resolve: resolveYamlOmap,
3727
construct: constructYamlOmap
3728
});
3729
3730
},{"../type":13}],25:[function(require,module,exports){
3731
'use strict';
3732
3733
var Type = require('../type');
3734
3735
var _toString = Object.prototype.toString;
3736
3737
function resolveYamlPairs(data) {
3738
if (null === data) {
3739
return true;
3740
}
3741
3742
var index, length, pair, keys, result,
3743
object = data;
3744
3745
result = new Array(object.length);
3746
3747
for (index = 0, length = object.length; index < length; index += 1) {
3748
pair = object[index];
3749
3750
if ('[object Object]' !== _toString.call(pair)) {
3751
return false;
3752
}
3753
3754
keys = Object.keys(pair);
3755
3756
if (1 !== keys.length) {
3757
return false;
3758
}
3759
3760
result[index] = [ keys[0], pair[keys[0]] ];
3761
}
3762
3763
return true;
3764
}
3765
3766
function constructYamlPairs(data) {
3767
if (null === data) {
3768
return [];
3769
}
3770
3771
var index, length, pair, keys, result,
3772
object = data;
3773
3774
result = new Array(object.length);
3775
3776
for (index = 0, length = object.length; index < length; index += 1) {
3777
pair = object[index];
3778
3779
keys = Object.keys(pair);
3780
3781
result[index] = [ keys[0], pair[keys[0]] ];
3782
}
3783
3784
return result;
3785
}
3786
3787
module.exports = new Type('tag:yaml.org,2002:pairs', {
3788
kind: 'sequence',
3789
resolve: resolveYamlPairs,
3790
construct: constructYamlPairs
3791
});
3792
3793
},{"../type":13}],26:[function(require,module,exports){
3794
'use strict';
3795
3796
var Type = require('../type');
3797
3798
module.exports = new Type('tag:yaml.org,2002:seq', {
3799
kind: 'sequence',
3800
construct: function (data) { return null !== data ? data : []; }
3801
});
3802
3803
},{"../type":13}],27:[function(require,module,exports){
3804
'use strict';
3805
3806
var Type = require('../type');
3807
3808
var _hasOwnProperty = Object.prototype.hasOwnProperty;
3809
3810
function resolveYamlSet(data) {
3811
if (null === data) {
3812
return true;
3813
}
3814
3815
var key, object = data;
3816
3817
for (key in object) {
3818
if (_hasOwnProperty.call(object, key)) {
3819
if (null !== object[key]) {
3820
return false;
3821
}
3822
}
3823
}
3824
3825
return true;
3826
}
3827
3828
function constructYamlSet(data) {
3829
return null !== data ? data : {};
3830
}
3831
3832
module.exports = new Type('tag:yaml.org,2002:set', {
3833
kind: 'mapping',
3834
resolve: resolveYamlSet,
3835
construct: constructYamlSet
3836
});
3837
3838
},{"../type":13}],28:[function(require,module,exports){
3839
'use strict';
3840
3841
var Type = require('../type');
3842
3843
module.exports = new Type('tag:yaml.org,2002:str', {
3844
kind: 'scalar',
3845
construct: function (data) { return null !== data ? data : ''; }
3846
});
3847
3848
},{"../type":13}],29:[function(require,module,exports){
3849
'use strict';
3850
3851
var Type = require('../type');
3852
3853
var YAML_TIMESTAMP_REGEXP = new RegExp(
3854
'^([0-9][0-9][0-9][0-9])' + // [1] year
3855
'-([0-9][0-9]?)' + // [2] month
3856
'-([0-9][0-9]?)' + // [3] day
3857
'(?:(?:[Tt]|[ \\t]+)' + // ...
3858
'([0-9][0-9]?)' + // [4] hour
3859
':([0-9][0-9])' + // [5] minute
3860
':([0-9][0-9])' + // [6] second
3861
'(?:\\.([0-9]*))?' + // [7] fraction
3862
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
3863
'(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
3864
3865
function resolveYamlTimestamp(data) {
3866
if (null === data) {
3867
return false;
3868
}
3869
3870
var match, year, month, day, hour, minute, second, fraction = 0,
3871
delta = null, tz_hour, tz_minute, date;
3872
3873
match = YAML_TIMESTAMP_REGEXP.exec(data);
3874
3875
if (null === match) {
3876
return false;
3877
}
3878
3879
return true;
3880
}
3881
3882
function constructYamlTimestamp(data) {
3883
var match, year, month, day, hour, minute, second, fraction = 0,
3884
delta = null, tz_hour, tz_minute, date;
3885
3886
match = YAML_TIMESTAMP_REGEXP.exec(data);
3887
3888
if (null === match) {
3889
throw new Error('Date resolve error');
3890
}
3891
3892
// match: [1] year [2] month [3] day
3893
3894
year = +(match[1]);
3895
month = +(match[2]) - 1; // JS month starts with 0
3896
day = +(match[3]);
3897
3898
if (!match[4]) { // no hour
3899
return new Date(Date.UTC(year, month, day));
3900
}
3901
3902
// match: [4] hour [5] minute [6] second [7] fraction
3903
3904
hour = +(match[4]);
3905
minute = +(match[5]);
3906
second = +(match[6]);
3907
3908
if (match[7]) {
3909
fraction = match[7].slice(0, 3);
3910
while (fraction.length < 3) { // milli-seconds
3911
fraction += '0';
3912
}
3913
fraction = +fraction;
3914
}
3915
3916
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
3917
3918
if (match[9]) {
3919
tz_hour = +(match[10]);
3920
tz_minute = +(match[11] || 0);
3921
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
3922
if ('-' === match[9]) {
3923
delta = -delta;
3924
}
3925
}
3926
3927
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
3928
3929
if (delta) {
3930
date.setTime(date.getTime() - delta);
3931
}
3932
3933
return date;
3934
}
3935
3936
function representYamlTimestamp(object /*, style*/) {
3937
return object.toISOString();
3938
}
3939
3940
module.exports = new Type('tag:yaml.org,2002:timestamp', {
3941
kind: 'scalar',
3942
resolve: resolveYamlTimestamp,
3943
construct: constructYamlTimestamp,
3944
instanceOf: Date,
3945
represent: representYamlTimestamp
3946
});
3947
3948
},{"../type":13}],30:[function(require,module,exports){
3949
3950
},{}],"/":[function(require,module,exports){
3951
'use strict';
3952
3953
3954
var yaml = require('./lib/js-yaml.js');
3955
3956
3957
module.exports = yaml;
3958
3959
},{"./lib/js-yaml.js":1}]},{},[])("/")
3960
});
3961