1 /* js-yaml 3.8.2 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){
5 var loader = require('./js-yaml/loader');
6 var dumper = require('./js-yaml/dumper');
9 function deprecated(name) {
11 throw new Error('Function ' + name + ' is deprecated and cannot be used.');
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');
31 // Deprecated 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');
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');
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){
46 function isNothing(subject) {
47 return (typeof subject === 'undefined') || (subject === null);
51 function isObject(subject) {
52 return (typeof subject === 'object') && (subject !== null);
56 function toArray(sequence) {
57 if (Array.isArray(sequence)) return sequence;
58 else if (isNothing(sequence)) return [];
64 function extend(target, source) {
65 var index, length, key, sourceKeys;
68 sourceKeys = Object.keys(source);
70 for (index = 0, length = sourceKeys.length; index < length; index += 1) {
71 key = sourceKeys[index];
72 target[key] = source[key];
80 function repeat(string, count) {
81 var result = '', cycle;
83 for (cycle = 0; cycle < count; cycle += 1) {
91 function isNegativeZero(number) {
92 return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
96 module.exports.isNothing = isNothing;
97 module.exports.isObject = isObject;
98 module.exports.toArray = toArray;
99 module.exports.repeat = repeat;
100 module.exports.isNegativeZero = isNegativeZero;
101 module.exports.extend = extend;
103 },{}],3:[function(require,module,exports){
106 /*eslint-disable no-use-before-define*/
108 var common = require('./common');
109 var YAMLException = require('./exception');
110 var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
111 var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
113 var _toString = Object.prototype.toString;
114 var _hasOwnProperty = Object.prototype.hasOwnProperty;
116 var CHAR_TAB = 0x09; /* Tab */
117 var CHAR_LINE_FEED = 0x0A; /* LF */
118 var CHAR_SPACE = 0x20; /* Space */
119 var CHAR_EXCLAMATION = 0x21; /* ! */
120 var CHAR_DOUBLE_QUOTE = 0x22; /* " */
121 var CHAR_SHARP = 0x23; /* # */
122 var CHAR_PERCENT = 0x25; /* % */
123 var CHAR_AMPERSAND = 0x26; /* & */
124 var CHAR_SINGLE_QUOTE = 0x27; /* ' */
125 var CHAR_ASTERISK = 0x2A; /* * */
126 var CHAR_COMMA = 0x2C; /* , */
127 var CHAR_MINUS = 0x2D; /* - */
128 var CHAR_COLON = 0x3A; /* : */
129 var CHAR_GREATER_THAN = 0x3E; /* > */
130 var CHAR_QUESTION = 0x3F; /* ? */
131 var CHAR_COMMERCIAL_AT = 0x40; /* @ */
132 var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
133 var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
134 var CHAR_GRAVE_ACCENT = 0x60; /* ` */
135 var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
136 var CHAR_VERTICAL_LINE = 0x7C; /* | */
137 var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
139 var ESCAPE_SEQUENCES = {};
141 ESCAPE_SEQUENCES[0x00] = '\\0';
142 ESCAPE_SEQUENCES[0x07] = '\\a';
143 ESCAPE_SEQUENCES[0x08] = '\\b';
144 ESCAPE_SEQUENCES[0x09] = '\\t';
145 ESCAPE_SEQUENCES[0x0A] = '\\n';
146 ESCAPE_SEQUENCES[0x0B] = '\\v';
147 ESCAPE_SEQUENCES[0x0C] = '\\f';
148 ESCAPE_SEQUENCES[0x0D] = '\\r';
149 ESCAPE_SEQUENCES[0x1B] = '\\e';
150 ESCAPE_SEQUENCES[0x22] = '\\"';
151 ESCAPE_SEQUENCES[0x5C] = '\\\\';
152 ESCAPE_SEQUENCES[0x85] = '\\N';
153 ESCAPE_SEQUENCES[0xA0] = '\\_';
154 ESCAPE_SEQUENCES[0x2028] = '\\L';
155 ESCAPE_SEQUENCES[0x2029] = '\\P';
157 var DEPRECATED_BOOLEANS_SYNTAX = [
158 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
159 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
162 function compileStyleMap(schema, map) {
163 var result, keys, index, length, tag, style, type;
165 if (map === null) return {};
168 keys = Object.keys(map);
170 for (index = 0, length = keys.length; index < length; index += 1) {
172 style = String(map[tag]);
174 if (tag.slice(0, 2) === '!!') {
175 tag = 'tag:yaml.org,2002:' + tag.slice(2);
177 type = schema.compiledTypeMap['fallback'][tag];
179 if (type && _hasOwnProperty.call(type.styleAliases, style)) {
180 style = type.styleAliases[style];
189 function encodeHex(character) {
190 var string, handle, length;
192 string = character.toString(16).toUpperCase();
194 if (character <= 0xFF) {
197 } else if (character <= 0xFFFF) {
200 } else if (character <= 0xFFFFFFFF) {
204 throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
207 return '\\' + handle + common.repeat('0', length - string.length) + string;
210 function State(options) {
211 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
212 this.indent = Math.max(1, (options['indent'] || 2));
213 this.skipInvalid = options['skipInvalid'] || false;
214 this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
215 this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
216 this.sortKeys = options['sortKeys'] || false;
217 this.lineWidth = options['lineWidth'] || 80;
218 this.noRefs = options['noRefs'] || false;
219 this.noCompatMode = options['noCompatMode'] || false;
221 this.implicitTypes = this.schema.compiledImplicit;
222 this.explicitTypes = this.schema.compiledExplicit;
227 this.duplicates = [];
228 this.usedDuplicates = null;
231 // Indents every line in a string. Empty lines (\n only) are not indented.
232 function indentString(string, spaces) {
233 var ind = common.repeat(' ', spaces),
238 length = string.length;
240 while (position < length) {
241 next = string.indexOf('\n', position);
243 line = string.slice(position);
246 line = string.slice(position, next + 1);
250 if (line.length && line !== '\n') result += ind;
258 function generateNextLine(state, level) {
259 return '\n' + common.repeat(' ', state.indent * level);
262 function testImplicitResolving(state, str) {
263 var index, length, type;
265 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
266 type = state.implicitTypes[index];
268 if (type.resolve(str)) {
276 // [33] s-white ::= s-space | s-tab
277 function isWhitespace(c) {
278 return c === CHAR_SPACE || c === CHAR_TAB;
281 // Returns true if the character can be printed without escaping.
282 // From YAML 1.2: "any allowed characters known to be non-printable
283 // should also be escaped. [However,] This isn’t mandatory"
284 // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
285 function isPrintable(c) {
286 return (0x00020 <= c && c <= 0x00007E)
287 || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
288 || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
289 || (0x10000 <= c && c <= 0x10FFFF);
292 // Simplified test for values allowed after the first character in plain style.
293 function isPlainSafe(c) {
294 // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
295 // where nb-char ::= c-printable - b-char - c-byte-order-mark.
296 return isPrintable(c) && c !== 0xFEFF
297 // - c-flow-indicator
299 && c !== CHAR_LEFT_SQUARE_BRACKET
300 && c !== CHAR_RIGHT_SQUARE_BRACKET
301 && c !== CHAR_LEFT_CURLY_BRACKET
302 && c !== CHAR_RIGHT_CURLY_BRACKET
308 // Simplified test for values allowed as the first character in plain style.
309 function isPlainSafeFirst(c) {
310 // Uses a subset of ns-char - c-indicator
311 // where ns-char = nb-char - s-white.
312 return isPrintable(c) && c !== 0xFEFF
313 && !isWhitespace(c) // - s-white
314 // - (c-indicator ::=
315 // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
317 && c !== CHAR_QUESTION
320 && c !== CHAR_LEFT_SQUARE_BRACKET
321 && c !== CHAR_RIGHT_SQUARE_BRACKET
322 && c !== CHAR_LEFT_CURLY_BRACKET
323 && c !== CHAR_RIGHT_CURLY_BRACKET
324 // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
326 && c !== CHAR_AMPERSAND
327 && c !== CHAR_ASTERISK
328 && c !== CHAR_EXCLAMATION
329 && c !== CHAR_VERTICAL_LINE
330 && c !== CHAR_GREATER_THAN
331 && c !== CHAR_SINGLE_QUOTE
332 && c !== CHAR_DOUBLE_QUOTE
333 // | “%” | “@” | “`”)
334 && c !== CHAR_PERCENT
335 && c !== CHAR_COMMERCIAL_AT
336 && c !== CHAR_GRAVE_ACCENT;
345 // Determines which scalar styles are possible and returns the preferred style.
346 // lineWidth = -1 => no limit.
347 // Pre-conditions: str.length > 0.
349 // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
350 // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
351 // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
352 function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
355 var hasLineBreak = false;
356 var hasFoldableLine = false; // only checked if shouldTrackWidth
357 var shouldTrackWidth = lineWidth !== -1;
358 var previousLineBreak = -1; // count the first line correctly
359 var plain = isPlainSafeFirst(string.charCodeAt(0))
360 && !isWhitespace(string.charCodeAt(string.length - 1));
362 if (singleLineOnly) {
363 // Case: no block styles.
364 // Check for disallowed characters to rule out plain and single.
365 for (i = 0; i < string.length; i++) {
366 char = string.charCodeAt(i);
367 if (!isPrintable(char)) {
370 plain = plain && isPlainSafe(char);
373 // Case: block styles permitted.
374 for (i = 0; i < string.length; i++) {
375 char = string.charCodeAt(i);
376 if (char === CHAR_LINE_FEED) {
378 // Check if any line can be folded.
379 if (shouldTrackWidth) {
380 hasFoldableLine = hasFoldableLine ||
381 // Foldable line = too long, and not more-indented.
382 (i - previousLineBreak - 1 > lineWidth &&
383 string[previousLineBreak + 1] !== ' ');
384 previousLineBreak = i;
386 } else if (!isPrintable(char)) {
389 plain = plain && isPlainSafe(char);
391 // in case the end is missing a \n
392 hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
393 (i - previousLineBreak - 1 > lineWidth &&
394 string[previousLineBreak + 1] !== ' '));
396 // Although every style can represent \n without escaping, prefer block styles
397 // for multiline, since they're more readable and they don't add empty lines.
398 // Also prefer folding a super-long line.
399 if (!hasLineBreak && !hasFoldableLine) {
400 // Strings interpretable as another type have to be quoted;
401 // e.g. the string 'true' vs. the boolean true.
402 return plain && !testAmbiguousType(string)
403 ? STYLE_PLAIN : STYLE_SINGLE;
405 // Edge case: block indentation indicator can only have one digit.
406 if (string[0] === ' ' && indentPerLevel > 9) {
409 // At this point we know block styles are valid.
410 // Prefer literal style unless we want to fold.
411 return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
414 // Note: line breaking/folding is implemented for only the folded style.
415 // NB. We drop the last trailing newline (if any) of a returned block scalar
416 // since the dumper adds its own newline. This always works:
417 // • No ending newline => unaffected; already using strip "-" chomping.
418 // • Ending newline => removed then restored.
419 // Importantly, this keeps the "+" chomp indicator from gaining an extra line.
420 function writeScalar(state, string, level, iskey) {
421 state.dump = (function () {
422 if (string.length === 0) {
425 if (!state.noCompatMode &&
426 DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
427 return "'" + string + "'";
430 var indent = state.indent * Math.max(1, level); // no 0-indent scalars
431 // As indentation gets deeper, let the width decrease monotonically
432 // to the lower bound min(state.lineWidth, 40).
433 // Note that this implies
434 // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
435 // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
436 // This behaves better than a constant minimum width which disallows narrower options,
437 // or an indent threshold which causes the width to suddenly increase.
438 var lineWidth = state.lineWidth === -1
439 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
441 // Without knowing if keys are implicit/explicit, assume implicit for safety.
442 var singleLineOnly = iskey
443 // No block styles in flow mode.
444 || (state.flowLevel > -1 && level >= state.flowLevel);
445 function testAmbiguity(string) {
446 return testImplicitResolving(state, string);
449 switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
453 return "'" + string.replace(/'/g, "''") + "'";
455 return '|' + blockHeader(string, state.indent)
456 + dropEndingNewline(indentString(string, indent));
458 return '>' + blockHeader(string, state.indent)
459 + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
461 return '"' + escapeString(string, lineWidth) + '"';
463 throw new YAMLException('impossible error: invalid scalar style');
468 // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
469 function blockHeader(string, indentPerLevel) {
470 var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : '';
472 // note the special case: the string '\n' counts as a "trailing" empty line.
473 var clip = string[string.length - 1] === '\n';
474 var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
475 var chomp = keep ? '+' : (clip ? '' : '-');
477 return indentIndicator + chomp + '\n';
480 // (See the note for writeScalar.)
481 function dropEndingNewline(string) {
482 return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
485 // Note: a long line without a suitable break point will exceed the width limit.
486 // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
487 function foldString(string, width) {
488 // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
489 // unless they're before or after a more-indented line, or at the very
490 // beginning or end, in which case $k$ maps to $k$.
491 // Therefore, parse each chunk as newline(s) followed by a content line.
492 var lineRe = /(\n+)([^\n]*)/g;
494 // first line (possibly an empty line)
495 var result = (function () {
496 var nextLF = string.indexOf('\n');
497 nextLF = nextLF !== -1 ? nextLF : string.length;
498 lineRe.lastIndex = nextLF;
499 return foldLine(string.slice(0, nextLF), width);
501 // If we haven't reached the first content line yet, don't add an extra \n.
502 var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
507 while ((match = lineRe.exec(string))) {
508 var prefix = match[1], line = match[2];
509 moreIndented = (line[0] === ' ');
511 + (!prevMoreIndented && !moreIndented && line !== ''
513 + foldLine(line, width);
514 prevMoreIndented = moreIndented;
520 // Greedy line breaking.
521 // Picks the longest line under the limit each time,
522 // otherwise settles for the shortest line over the limit.
523 // NB. More-indented lines *cannot* be folded, as that would add an extra \n.
524 function foldLine(line, width) {
525 if (line === '' || line[0] === ' ') return line;
527 // Since a more-indented line adds a \n, breaks can't be followed by a space.
528 var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
530 // start is an inclusive index. end, curr, and next are exclusive.
531 var start = 0, end, curr = 0, next = 0;
534 // Invariants: 0 <= start <= length-1.
535 // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
537 // A match implies length >= 2, so curr and next are <= length-2.
538 while ((match = breakRe.exec(line))) {
540 // maintain invariant: curr - start <= width
541 if (next - start > width) {
542 end = (curr > start) ? curr : next; // derive end <= length-2
543 result += '\n' + line.slice(start, end);
544 // skip the space that was output as \n
545 start = end + 1; // derive start <= length-1
550 // By the invariants, start <= length-1, so there is something left over.
551 // It is either the whole string or a part starting from non-whitespace.
553 // Insert a break if the remainder is too long and there is a break available.
554 if (line.length - start > width && curr > start) {
555 result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
557 result += line.slice(start);
560 return result.slice(1); // drop extra \n joiner
563 // Escapes a double-quoted string.
564 function escapeString(string) {
569 for (var i = 0; i < string.length; i++) {
570 char = string.charCodeAt(i);
571 escapeSeq = ESCAPE_SEQUENCES[char];
572 result += !escapeSeq && isPrintable(char)
574 : escapeSeq || encodeHex(char);
580 function writeFlowSequence(state, level, object) {
586 for (index = 0, length = object.length; index < length; index += 1) {
587 // Write only valid elements.
588 if (writeNode(state, level, object[index], false, false)) {
589 if (index !== 0) _result += ', ';
590 _result += state.dump;
595 state.dump = '[' + _result + ']';
598 function writeBlockSequence(state, level, object, compact) {
604 for (index = 0, length = object.length; index < length; index += 1) {
605 // Write only valid elements.
606 if (writeNode(state, level + 1, object[index], true, true)) {
607 if (!compact || index !== 0) {
608 _result += generateNextLine(state, level);
610 _result += '- ' + state.dump;
615 state.dump = _result || '[]'; // Empty sequence if no valid values.
618 function writeFlowMapping(state, level, object) {
621 objectKeyList = Object.keys(object),
628 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
631 if (index !== 0) pairBuffer += ', ';
633 objectKey = objectKeyList[index];
634 objectValue = object[objectKey];
636 if (!writeNode(state, level, objectKey, false, false)) {
637 continue; // Skip this pair because of invalid key;
640 if (state.dump.length > 1024) pairBuffer += '? ';
642 pairBuffer += state.dump + ': ';
644 if (!writeNode(state, level, objectValue, false, false)) {
645 continue; // Skip this pair because of invalid value.
648 pairBuffer += state.dump;
650 // Both key and value are valid.
651 _result += pairBuffer;
655 state.dump = '{' + _result + '}';
658 function writeBlockMapping(state, level, object, compact) {
661 objectKeyList = Object.keys(object),
669 // Allow sorting keys so that the output file is deterministic
670 if (state.sortKeys === true) {
672 objectKeyList.sort();
673 } else if (typeof state.sortKeys === 'function') {
674 // Custom sort function
675 objectKeyList.sort(state.sortKeys);
676 } else if (state.sortKeys) {
677 // Something is wrong
678 throw new YAMLException('sortKeys must be a boolean or a function');
681 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
684 if (!compact || index !== 0) {
685 pairBuffer += generateNextLine(state, level);
688 objectKey = objectKeyList[index];
689 objectValue = object[objectKey];
691 if (!writeNode(state, level + 1, objectKey, true, true, true)) {
692 continue; // Skip this pair because of invalid key.
695 explicitPair = (state.tag !== null && state.tag !== '?') ||
696 (state.dump && state.dump.length > 1024);
699 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
706 pairBuffer += state.dump;
709 pairBuffer += generateNextLine(state, level);
712 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
713 continue; // Skip this pair because of invalid value.
716 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
722 pairBuffer += state.dump;
724 // Both key and value are valid.
725 _result += pairBuffer;
729 state.dump = _result || '{}'; // Empty mapping if no valid pairs.
732 function detectType(state, object, explicit) {
733 var _result, typeList, index, length, type, style;
735 typeList = explicit ? state.explicitTypes : state.implicitTypes;
737 for (index = 0, length = typeList.length; index < length; index += 1) {
738 type = typeList[index];
740 if ((type.instanceOf || type.predicate) &&
741 (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
742 (!type.predicate || type.predicate(object))) {
744 state.tag = explicit ? type.tag : '?';
746 if (type.represent) {
747 style = state.styleMap[type.tag] || type.defaultStyle;
749 if (_toString.call(type.represent) === '[object Function]') {
750 _result = type.represent(object, style);
751 } else if (_hasOwnProperty.call(type.represent, style)) {
752 _result = type.represent[style](object, style);
754 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
757 state.dump = _result;
767 // Serializes `object` and writes it to global `result`.
768 // Returns true on success, or false on invalid object.
770 function writeNode(state, level, object, block, compact, iskey) {
774 if (!detectType(state, object, false)) {
775 detectType(state, object, true);
778 var type = _toString.call(state.dump);
781 block = (state.flowLevel < 0 || state.flowLevel > level);
784 var objectOrArray = type === '[object Object]' || type === '[object Array]',
789 duplicateIndex = state.duplicates.indexOf(object);
790 duplicate = duplicateIndex !== -1;
793 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
797 if (duplicate && state.usedDuplicates[duplicateIndex]) {
798 state.dump = '*ref_' + duplicateIndex;
800 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
801 state.usedDuplicates[duplicateIndex] = true;
803 if (type === '[object Object]') {
804 if (block && (Object.keys(state.dump).length !== 0)) {
805 writeBlockMapping(state, level, state.dump, compact);
807 state.dump = '&ref_' + duplicateIndex + state.dump;
810 writeFlowMapping(state, level, state.dump);
812 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
815 } else if (type === '[object Array]') {
816 if (block && (state.dump.length !== 0)) {
817 writeBlockSequence(state, level, state.dump, compact);
819 state.dump = '&ref_' + duplicateIndex + state.dump;
822 writeFlowSequence(state, level, state.dump);
824 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
827 } else if (type === '[object String]') {
828 if (state.tag !== '?') {
829 writeScalar(state, state.dump, level, iskey);
832 if (state.skipInvalid) return false;
833 throw new YAMLException('unacceptable kind of an object to dump ' + type);
836 if (state.tag !== null && state.tag !== '?') {
837 state.dump = '!<' + state.tag + '> ' + state.dump;
844 function getDuplicateReferences(object, state) {
846 duplicatesIndexes = [],
850 inspectNode(object, objects, duplicatesIndexes);
852 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
853 state.duplicates.push(objects[duplicatesIndexes[index]]);
855 state.usedDuplicates = new Array(length);
858 function inspectNode(object, objects, duplicatesIndexes) {
863 if (object !== null && typeof object === 'object') {
864 index = objects.indexOf(object);
866 if (duplicatesIndexes.indexOf(index) === -1) {
867 duplicatesIndexes.push(index);
870 objects.push(object);
872 if (Array.isArray(object)) {
873 for (index = 0, length = object.length; index < length; index += 1) {
874 inspectNode(object[index], objects, duplicatesIndexes);
877 objectKeyList = Object.keys(object);
879 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
880 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
887 function dump(input, options) {
888 options = options || {};
890 var state = new State(options);
892 if (!state.noRefs) getDuplicateReferences(input, state);
894 if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
899 function safeDump(input, options) {
900 return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
903 module.exports.dump = dump;
904 module.exports.safeDump = safeDump;
906 },{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){
907 // YAML error class. http://stackoverflow.com/questions/8458984
911 function YAMLException(reason, mark) {
915 // Include stack trace in error object
916 if (Error.captureStackTrace) {
918 Error.captureStackTrace(this, this.constructor);
920 // FF, IE 10+ and Safari 6+. Fallback for others
921 this.stack = (new Error()).stack || '';
924 this.name = 'YAMLException';
925 this.reason = reason;
927 this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
931 // Inherit from Error
932 YAMLException.prototype = Object.create(Error.prototype);
933 YAMLException.prototype.constructor = YAMLException;
936 YAMLException.prototype.toString = function toString(compact) {
937 var result = this.name + ': ';
939 result += this.reason || '(unknown reason)';
941 if (!compact && this.mark) {
942 result += ' ' + this.mark.toString();
949 module.exports = YAMLException;
951 },{}],5:[function(require,module,exports){
954 /*eslint-disable max-len,no-use-before-define*/
956 var common = require('./common');
957 var YAMLException = require('./exception');
958 var Mark = require('./mark');
959 var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
960 var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
963 var _hasOwnProperty = Object.prototype.hasOwnProperty;
966 var CONTEXT_FLOW_IN = 1;
967 var CONTEXT_FLOW_OUT = 2;
968 var CONTEXT_BLOCK_IN = 3;
969 var CONTEXT_BLOCK_OUT = 4;
972 var CHOMPING_CLIP = 1;
973 var CHOMPING_STRIP = 2;
974 var CHOMPING_KEEP = 3;
977 var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
978 var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
979 var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
980 var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
981 var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
985 return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
988 function is_WHITE_SPACE(c) {
989 return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
992 function is_WS_OR_EOL(c) {
993 return (c === 0x09/* Tab */) ||
994 (c === 0x20/* Space */) ||
995 (c === 0x0A/* LF */) ||
996 (c === 0x0D/* CR */);
999 function is_FLOW_INDICATOR(c) {
1000 return c === 0x2C/* , */ ||
1001 c === 0x5B/* [ */ ||
1002 c === 0x5D/* ] */ ||
1003 c === 0x7B/* { */ ||
1007 function fromHexCode(c) {
1010 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1014 /*eslint-disable no-bitwise*/
1017 if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
1018 return lc - 0x61 + 10;
1024 function escapedHexLen(c) {
1025 if (c === 0x78/* x */) { return 2; }
1026 if (c === 0x75/* u */) { return 4; }
1027 if (c === 0x55/* U */) { return 8; }
1031 function fromDecimalCode(c) {
1032 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1039 function simpleEscapeSequence(c) {
1040 return (c === 0x30/* 0 */) ? '\x00' :
1041 (c === 0x61/* a */) ? '\x07' :
1042 (c === 0x62/* b */) ? '\x08' :
1043 (c === 0x74/* t */) ? '\x09' :
1044 (c === 0x09/* Tab */) ? '\x09' :
1045 (c === 0x6E/* n */) ? '\x0A' :
1046 (c === 0x76/* v */) ? '\x0B' :
1047 (c === 0x66/* f */) ? '\x0C' :
1048 (c === 0x72/* r */) ? '\x0D' :
1049 (c === 0x65/* e */) ? '\x1B' :
1050 (c === 0x20/* Space */) ? ' ' :
1051 (c === 0x22/* " */) ? '\x22' :
1052 (c === 0x2F/* / */) ? '/' :
1053 (c === 0x5C/* \ */) ? '\x5C' :
1054 (c === 0x4E/* N */) ? '\x85' :
1055 (c === 0x5F/* _ */) ? '\xA0' :
1056 (c === 0x4C/* L */) ? '\u2028' :
1057 (c === 0x50/* P */) ? '\u2029' : '';
1060 function charFromCodepoint(c) {
1062 return String.fromCharCode(c);
1064 // Encode UTF-16 surrogate pair
1065 // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
1066 return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
1067 ((c - 0x010000) & 0x03FF) + 0xDC00);
1070 var simpleEscapeCheck = new Array(256); // integer, for fast access
1071 var simpleEscapeMap = new Array(256);
1072 for (var i = 0; i < 256; i++) {
1073 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1074 simpleEscapeMap[i] = simpleEscapeSequence(i);
1078 function State(input, options) {
1081 this.filename = options['filename'] || null;
1082 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
1083 this.onWarning = options['onWarning'] || null;
1084 this.legacy = options['legacy'] || false;
1085 this.json = options['json'] || false;
1086 this.listener = options['listener'] || null;
1088 this.implicitTypes = this.schema.compiledImplicit;
1089 this.typeMap = this.schema.compiledTypeMap;
1091 this.length = input.length;
1095 this.lineIndent = 0;
1097 this.documents = [];
1101 this.checkLineBreaks;
1112 function generateError(state, message) {
1113 return new YAMLException(
1115 new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
1118 function throwError(state, message) {
1119 throw generateError(state, message);
1122 function throwWarning(state, message) {
1123 if (state.onWarning) {
1124 state.onWarning.call(null, generateError(state, message));
1129 var directiveHandlers = {
1131 YAML: function handleYamlDirective(state, name, args) {
1133 var match, major, minor;
1135 if (state.version !== null) {
1136 throwError(state, 'duplication of %YAML directive');
1139 if (args.length !== 1) {
1140 throwError(state, 'YAML directive accepts exactly one argument');
1143 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1145 if (match === null) {
1146 throwError(state, 'ill-formed argument of the YAML directive');
1149 major = parseInt(match[1], 10);
1150 minor = parseInt(match[2], 10);
1153 throwError(state, 'unacceptable YAML version of the document');
1156 state.version = args[0];
1157 state.checkLineBreaks = (minor < 2);
1159 if (minor !== 1 && minor !== 2) {
1160 throwWarning(state, 'unsupported YAML version of the document');
1164 TAG: function handleTagDirective(state, name, args) {
1168 if (args.length !== 2) {
1169 throwError(state, 'TAG directive accepts exactly two arguments');
1175 if (!PATTERN_TAG_HANDLE.test(handle)) {
1176 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
1179 if (_hasOwnProperty.call(state.tagMap, handle)) {
1180 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1183 if (!PATTERN_TAG_URI.test(prefix)) {
1184 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
1187 state.tagMap[handle] = prefix;
1192 function captureSegment(state, start, end, checkJson) {
1193 var _position, _length, _character, _result;
1196 _result = state.input.slice(start, end);
1199 for (_position = 0, _length = _result.length;
1200 _position < _length;
1202 _character = _result.charCodeAt(_position);
1203 if (!(_character === 0x09 ||
1204 (0x20 <= _character && _character <= 0x10FFFF))) {
1205 throwError(state, 'expected valid JSON character');
1208 } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1209 throwError(state, 'the stream contains non-printable characters');
1212 state.result += _result;
1216 function mergeMappings(state, destination, source, overridableKeys) {
1217 var sourceKeys, key, index, quantity;
1219 if (!common.isObject(source)) {
1220 throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
1223 sourceKeys = Object.keys(source);
1225 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1226 key = sourceKeys[index];
1228 if (!_hasOwnProperty.call(destination, key)) {
1229 destination[key] = source[key];
1230 overridableKeys[key] = true;
1235 function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
1236 var index, quantity;
1238 keyNode = String(keyNode);
1240 if (_result === null) {
1244 if (keyTag === 'tag:yaml.org,2002:merge') {
1245 if (Array.isArray(valueNode)) {
1246 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1247 mergeMappings(state, _result, valueNode[index], overridableKeys);
1250 mergeMappings(state, _result, valueNode, overridableKeys);
1254 !_hasOwnProperty.call(overridableKeys, keyNode) &&
1255 _hasOwnProperty.call(_result, keyNode)) {
1256 state.line = startLine || state.line;
1257 state.position = startPos || state.position;
1258 throwError(state, 'duplicated mapping key');
1260 _result[keyNode] = valueNode;
1261 delete overridableKeys[keyNode];
1267 function readLineBreak(state) {
1270 ch = state.input.charCodeAt(state.position);
1272 if (ch === 0x0A/* LF */) {
1274 } else if (ch === 0x0D/* CR */) {
1276 if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
1280 throwError(state, 'a line break is expected');
1284 state.lineStart = state.position;
1287 function skipSeparationSpace(state, allowComments, checkIndent) {
1289 ch = state.input.charCodeAt(state.position);
1292 while (is_WHITE_SPACE(ch)) {
1293 ch = state.input.charCodeAt(++state.position);
1296 if (allowComments && ch === 0x23/* # */) {
1298 ch = state.input.charCodeAt(++state.position);
1299 } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
1303 readLineBreak(state);
1305 ch = state.input.charCodeAt(state.position);
1307 state.lineIndent = 0;
1309 while (ch === 0x20/* Space */) {
1311 ch = state.input.charCodeAt(++state.position);
1318 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1319 throwWarning(state, 'deficient indentation');
1325 function testDocumentSeparator(state) {
1326 var _position = state.position,
1329 ch = state.input.charCodeAt(_position);
1331 // Condition state.position === state.lineStart is tested
1332 // in parent on each call, for efficiency. No needs to test here again.
1333 if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
1334 ch === state.input.charCodeAt(_position + 1) &&
1335 ch === state.input.charCodeAt(_position + 2)) {
1339 ch = state.input.charCodeAt(_position);
1341 if (ch === 0 || is_WS_OR_EOL(ch)) {
1349 function writeFoldedLines(state, count) {
1351 state.result += ' ';
1352 } else if (count > 1) {
1353 state.result += common.repeat('\n', count - 1);
1358 function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1368 _result = state.result,
1371 ch = state.input.charCodeAt(state.position);
1373 if (is_WS_OR_EOL(ch) ||
1374 is_FLOW_INDICATOR(ch) ||
1375 ch === 0x23/* # */ ||
1376 ch === 0x26/* & */ ||
1377 ch === 0x2A/* * */ ||
1378 ch === 0x21/* ! */ ||
1379 ch === 0x7C/* | */ ||
1380 ch === 0x3E/* > */ ||
1381 ch === 0x27/* ' */ ||
1382 ch === 0x22/* " */ ||
1383 ch === 0x25/* % */ ||
1384 ch === 0x40/* @ */ ||
1385 ch === 0x60/* ` */) {
1389 if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
1390 following = state.input.charCodeAt(state.position + 1);
1392 if (is_WS_OR_EOL(following) ||
1393 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1398 state.kind = 'scalar';
1400 captureStart = captureEnd = state.position;
1401 hasPendingContent = false;
1404 if (ch === 0x3A/* : */) {
1405 following = state.input.charCodeAt(state.position + 1);
1407 if (is_WS_OR_EOL(following) ||
1408 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1412 } else if (ch === 0x23/* # */) {
1413 preceding = state.input.charCodeAt(state.position - 1);
1415 if (is_WS_OR_EOL(preceding)) {
1419 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
1420 withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1423 } else if (is_EOL(ch)) {
1425 _lineStart = state.lineStart;
1426 _lineIndent = state.lineIndent;
1427 skipSeparationSpace(state, false, -1);
1429 if (state.lineIndent >= nodeIndent) {
1430 hasPendingContent = true;
1431 ch = state.input.charCodeAt(state.position);
1434 state.position = captureEnd;
1436 state.lineStart = _lineStart;
1437 state.lineIndent = _lineIndent;
1442 if (hasPendingContent) {
1443 captureSegment(state, captureStart, captureEnd, false);
1444 writeFoldedLines(state, state.line - _line);
1445 captureStart = captureEnd = state.position;
1446 hasPendingContent = false;
1449 if (!is_WHITE_SPACE(ch)) {
1450 captureEnd = state.position + 1;
1453 ch = state.input.charCodeAt(++state.position);
1456 captureSegment(state, captureStart, captureEnd, false);
1463 state.result = _result;
1467 function readSingleQuotedScalar(state, nodeIndent) {
1469 captureStart, captureEnd;
1471 ch = state.input.charCodeAt(state.position);
1473 if (ch !== 0x27/* ' */) {
1477 state.kind = 'scalar';
1480 captureStart = captureEnd = state.position;
1482 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1483 if (ch === 0x27/* ' */) {
1484 captureSegment(state, captureStart, state.position, true);
1485 ch = state.input.charCodeAt(++state.position);
1487 if (ch === 0x27/* ' */) {
1488 captureStart = state.position;
1490 captureEnd = state.position;
1495 } else if (is_EOL(ch)) {
1496 captureSegment(state, captureStart, captureEnd, true);
1497 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1498 captureStart = captureEnd = state.position;
1500 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1501 throwError(state, 'unexpected end of the document within a single quoted scalar');
1505 captureEnd = state.position;
1509 throwError(state, 'unexpected end of the stream within a single quoted scalar');
1512 function readDoubleQuotedScalar(state, nodeIndent) {
1520 ch = state.input.charCodeAt(state.position);
1522 if (ch !== 0x22/* " */) {
1526 state.kind = 'scalar';
1529 captureStart = captureEnd = state.position;
1531 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1532 if (ch === 0x22/* " */) {
1533 captureSegment(state, captureStart, state.position, true);
1537 } else if (ch === 0x5C/* \ */) {
1538 captureSegment(state, captureStart, state.position, true);
1539 ch = state.input.charCodeAt(++state.position);
1542 skipSeparationSpace(state, false, nodeIndent);
1544 // TODO: rework to inline fn with no type cast?
1545 } else if (ch < 256 && simpleEscapeCheck[ch]) {
1546 state.result += simpleEscapeMap[ch];
1549 } else if ((tmp = escapedHexLen(ch)) > 0) {
1553 for (; hexLength > 0; hexLength--) {
1554 ch = state.input.charCodeAt(++state.position);
1556 if ((tmp = fromHexCode(ch)) >= 0) {
1557 hexResult = (hexResult << 4) + tmp;
1560 throwError(state, 'expected hexadecimal character');
1564 state.result += charFromCodepoint(hexResult);
1569 throwError(state, 'unknown escape sequence');
1572 captureStart = captureEnd = state.position;
1574 } else if (is_EOL(ch)) {
1575 captureSegment(state, captureStart, captureEnd, true);
1576 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1577 captureStart = captureEnd = state.position;
1579 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1580 throwError(state, 'unexpected end of the document within a double quoted scalar');
1584 captureEnd = state.position;
1588 throwError(state, 'unexpected end of the stream within a double quoted scalar');
1591 function readFlowCollection(state, nodeIndent) {
1592 var readNext = true,
1596 _anchor = state.anchor,
1602 overridableKeys = {},
1608 ch = state.input.charCodeAt(state.position);
1610 if (ch === 0x5B/* [ */) {
1611 terminator = 0x5D;/* ] */
1614 } else if (ch === 0x7B/* { */) {
1615 terminator = 0x7D;/* } */
1622 if (state.anchor !== null) {
1623 state.anchorMap[state.anchor] = _result;
1626 ch = state.input.charCodeAt(++state.position);
1629 skipSeparationSpace(state, true, nodeIndent);
1631 ch = state.input.charCodeAt(state.position);
1633 if (ch === terminator) {
1636 state.anchor = _anchor;
1637 state.kind = isMapping ? 'mapping' : 'sequence';
1638 state.result = _result;
1640 } else if (!readNext) {
1641 throwError(state, 'missed comma between flow collection entries');
1644 keyTag = keyNode = valueNode = null;
1645 isPair = isExplicitPair = false;
1647 if (ch === 0x3F/* ? */) {
1648 following = state.input.charCodeAt(state.position + 1);
1650 if (is_WS_OR_EOL(following)) {
1651 isPair = isExplicitPair = true;
1653 skipSeparationSpace(state, true, nodeIndent);
1658 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1660 keyNode = state.result;
1661 skipSeparationSpace(state, true, nodeIndent);
1663 ch = state.input.charCodeAt(state.position);
1665 if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
1667 ch = state.input.charCodeAt(++state.position);
1668 skipSeparationSpace(state, true, nodeIndent);
1669 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1670 valueNode = state.result;
1674 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
1675 } else if (isPair) {
1676 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
1678 _result.push(keyNode);
1681 skipSeparationSpace(state, true, nodeIndent);
1683 ch = state.input.charCodeAt(state.position);
1685 if (ch === 0x2C/* , */) {
1687 ch = state.input.charCodeAt(++state.position);
1693 throwError(state, 'unexpected end of the stream within a flow collection');
1696 function readBlockScalar(state, nodeIndent) {
1699 chomping = CHOMPING_CLIP,
1700 didReadContent = false,
1701 detectedIndent = false,
1702 textIndent = nodeIndent,
1704 atMoreIndented = false,
1708 ch = state.input.charCodeAt(state.position);
1710 if (ch === 0x7C/* | */) {
1712 } else if (ch === 0x3E/* > */) {
1718 state.kind = 'scalar';
1722 ch = state.input.charCodeAt(++state.position);
1724 if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
1725 if (CHOMPING_CLIP === chomping) {
1726 chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
1728 throwError(state, 'repeat of a chomping mode identifier');
1731 } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1733 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
1734 } else if (!detectedIndent) {
1735 textIndent = nodeIndent + tmp - 1;
1736 detectedIndent = true;
1738 throwError(state, 'repeat of an indentation width identifier');
1746 if (is_WHITE_SPACE(ch)) {
1747 do { ch = state.input.charCodeAt(++state.position); }
1748 while (is_WHITE_SPACE(ch));
1750 if (ch === 0x23/* # */) {
1751 do { ch = state.input.charCodeAt(++state.position); }
1752 while (!is_EOL(ch) && (ch !== 0));
1757 readLineBreak(state);
1758 state.lineIndent = 0;
1760 ch = state.input.charCodeAt(state.position);
1762 while ((!detectedIndent || state.lineIndent < textIndent) &&
1763 (ch === 0x20/* Space */)) {
1765 ch = state.input.charCodeAt(++state.position);
1768 if (!detectedIndent && state.lineIndent > textIndent) {
1769 textIndent = state.lineIndent;
1777 // End of the scalar.
1778 if (state.lineIndent < textIndent) {
1780 // Perform the chomping.
1781 if (chomping === CHOMPING_KEEP) {
1782 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1783 } else if (chomping === CHOMPING_CLIP) {
1784 if (didReadContent) { // i.e. only if the scalar is not empty.
1785 state.result += '\n';
1789 // Break this `while` cycle and go to the funciton's epilogue.
1793 // Folded style: use fancy rules to handle line breaks.
1796 // Lines starting with white space characters (more-indented lines) are not folded.
1797 if (is_WHITE_SPACE(ch)) {
1798 atMoreIndented = true;
1799 // except for the first content line (cf. Example 8.1)
1800 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1802 // End of more-indented block.
1803 } else if (atMoreIndented) {
1804 atMoreIndented = false;
1805 state.result += common.repeat('\n', emptyLines + 1);
1807 // Just one line break - perceive as the same line.
1808 } else if (emptyLines === 0) {
1809 if (didReadContent) { // i.e. only if we have already read some scalar content.
1810 state.result += ' ';
1813 // Several line breaks - perceive as different lines.
1815 state.result += common.repeat('\n', emptyLines);
1818 // Literal style: just add exact number of line breaks between content lines.
1820 // Keep all line breaks except the header line break.
1821 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1824 didReadContent = true;
1825 detectedIndent = true;
1827 captureStart = state.position;
1829 while (!is_EOL(ch) && (ch !== 0)) {
1830 ch = state.input.charCodeAt(++state.position);
1833 captureSegment(state, captureStart, state.position, false);
1839 function readBlockSequence(state, nodeIndent) {
1842 _anchor = state.anchor,
1848 if (state.anchor !== null) {
1849 state.anchorMap[state.anchor] = _result;
1852 ch = state.input.charCodeAt(state.position);
1856 if (ch !== 0x2D/* - */) {
1860 following = state.input.charCodeAt(state.position + 1);
1862 if (!is_WS_OR_EOL(following)) {
1869 if (skipSeparationSpace(state, true, -1)) {
1870 if (state.lineIndent <= nodeIndent) {
1872 ch = state.input.charCodeAt(state.position);
1878 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1879 _result.push(state.result);
1880 skipSeparationSpace(state, true, -1);
1882 ch = state.input.charCodeAt(state.position);
1884 if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
1885 throwError(state, 'bad indentation of a sequence entry');
1886 } else if (state.lineIndent < nodeIndent) {
1893 state.anchor = _anchor;
1894 state.kind = 'sequence';
1895 state.result = _result;
1901 function readBlockMapping(state, nodeIndent, flowIndent) {
1907 _anchor = state.anchor,
1909 overridableKeys = {},
1913 atExplicitKey = false,
1917 if (state.anchor !== null) {
1918 state.anchorMap[state.anchor] = _result;
1921 ch = state.input.charCodeAt(state.position);
1924 following = state.input.charCodeAt(state.position + 1);
1925 _line = state.line; // Save the current line.
1926 _pos = state.position;
1929 // Explicit notation case. There are two separate blocks:
1930 // first for the key (denoted by "?") and second for the value (denoted by ":")
1932 if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
1934 if (ch === 0x3F/* ? */) {
1935 if (atExplicitKey) {
1936 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1937 keyTag = keyNode = valueNode = null;
1941 atExplicitKey = true;
1942 allowCompact = true;
1944 } else if (atExplicitKey) {
1945 // i.e. 0x3A/* : */ === character after the explicit key.
1946 atExplicitKey = false;
1947 allowCompact = true;
1950 throwError(state, 'incomplete explicit mapping pair; a key node is missed');
1953 state.position += 1;
1957 // Implicit notation case. Flow-style node as the key first, then ":", and the value.
1959 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1961 if (state.line === _line) {
1962 ch = state.input.charCodeAt(state.position);
1964 while (is_WHITE_SPACE(ch)) {
1965 ch = state.input.charCodeAt(++state.position);
1968 if (ch === 0x3A/* : */) {
1969 ch = state.input.charCodeAt(++state.position);
1971 if (!is_WS_OR_EOL(ch)) {
1972 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
1975 if (atExplicitKey) {
1976 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1977 keyTag = keyNode = valueNode = null;
1981 atExplicitKey = false;
1982 allowCompact = false;
1984 keyNode = state.result;
1986 } else if (detected) {
1987 throwError(state, 'can not read an implicit mapping pair; a colon is missed');
1991 state.anchor = _anchor;
1992 return true; // Keep the result of `composeNode`.
1995 } else if (detected) {
1996 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
2000 state.anchor = _anchor;
2001 return true; // Keep the result of `composeNode`.
2005 break; // Reading is done. Go to the epilogue.
2009 // Common reading code for both explicit and implicit notations.
2011 if (state.line === _line || state.lineIndent > nodeIndent) {
2012 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
2013 if (atExplicitKey) {
2014 keyNode = state.result;
2016 valueNode = state.result;
2020 if (!atExplicitKey) {
2021 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
2022 keyTag = keyNode = valueNode = null;
2025 skipSeparationSpace(state, true, -1);
2026 ch = state.input.charCodeAt(state.position);
2029 if (state.lineIndent > nodeIndent && (ch !== 0)) {
2030 throwError(state, 'bad indentation of a mapping entry');
2031 } else if (state.lineIndent < nodeIndent) {
2040 // Special case: last mapping's node contains only the key in explicit notation.
2041 if (atExplicitKey) {
2042 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2045 // Expose the resulting mapping.
2048 state.anchor = _anchor;
2049 state.kind = 'mapping';
2050 state.result = _result;
2056 function readTagProperty(state) {
2064 ch = state.input.charCodeAt(state.position);
2066 if (ch !== 0x21/* ! */) return false;
2068 if (state.tag !== null) {
2069 throwError(state, 'duplication of a tag property');
2072 ch = state.input.charCodeAt(++state.position);
2074 if (ch === 0x3C/* < */) {
2076 ch = state.input.charCodeAt(++state.position);
2078 } else if (ch === 0x21/* ! */) {
2081 ch = state.input.charCodeAt(++state.position);
2087 _position = state.position;
2090 do { ch = state.input.charCodeAt(++state.position); }
2091 while (ch !== 0 && ch !== 0x3E/* > */);
2093 if (state.position < state.length) {
2094 tagName = state.input.slice(_position, state.position);
2095 ch = state.input.charCodeAt(++state.position);
2097 throwError(state, 'unexpected end of the stream within a verbatim tag');
2100 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2102 if (ch === 0x21/* ! */) {
2104 tagHandle = state.input.slice(_position - 1, state.position + 1);
2106 if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2107 throwError(state, 'named tag handle cannot contain such characters');
2111 _position = state.position + 1;
2113 throwError(state, 'tag suffix cannot contain exclamation marks');
2117 ch = state.input.charCodeAt(++state.position);
2120 tagName = state.input.slice(_position, state.position);
2122 if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2123 throwError(state, 'tag suffix cannot contain flow indicator characters');
2127 if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2128 throwError(state, 'tag name cannot contain such characters: ' + tagName);
2132 state.tag = tagName;
2134 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
2135 state.tag = state.tagMap[tagHandle] + tagName;
2137 } else if (tagHandle === '!') {
2138 state.tag = '!' + tagName;
2140 } else if (tagHandle === '!!') {
2141 state.tag = 'tag:yaml.org,2002:' + tagName;
2144 throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2150 function readAnchorProperty(state) {
2154 ch = state.input.charCodeAt(state.position);
2156 if (ch !== 0x26/* & */) return false;
2158 if (state.anchor !== null) {
2159 throwError(state, 'duplication of an anchor property');
2162 ch = state.input.charCodeAt(++state.position);
2163 _position = state.position;
2165 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2166 ch = state.input.charCodeAt(++state.position);
2169 if (state.position === _position) {
2170 throwError(state, 'name of an anchor node must contain at least one character');
2173 state.anchor = state.input.slice(_position, state.position);
2177 function readAlias(state) {
2178 var _position, alias,
2181 ch = state.input.charCodeAt(state.position);
2183 if (ch !== 0x2A/* * */) return false;
2185 ch = state.input.charCodeAt(++state.position);
2186 _position = state.position;
2188 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2189 ch = state.input.charCodeAt(++state.position);
2192 if (state.position === _position) {
2193 throwError(state, 'name of an alias node must contain at least one character');
2196 alias = state.input.slice(_position, state.position);
2198 if (!state.anchorMap.hasOwnProperty(alias)) {
2199 throwError(state, 'unidentified alias "' + alias + '"');
2202 state.result = state.anchorMap[alias];
2203 skipSeparationSpace(state, true, -1);
2207 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2208 var allowBlockStyles,
2210 allowBlockCollections,
2211 indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
2220 if (state.listener !== null) {
2221 state.listener('open', state);
2225 state.anchor = null;
2227 state.result = null;
2229 allowBlockStyles = allowBlockScalars = allowBlockCollections =
2230 CONTEXT_BLOCK_OUT === nodeContext ||
2231 CONTEXT_BLOCK_IN === nodeContext;
2234 if (skipSeparationSpace(state, true, -1)) {
2237 if (state.lineIndent > parentIndent) {
2239 } else if (state.lineIndent === parentIndent) {
2241 } else if (state.lineIndent < parentIndent) {
2247 if (indentStatus === 1) {
2248 while (readTagProperty(state) || readAnchorProperty(state)) {
2249 if (skipSeparationSpace(state, true, -1)) {
2251 allowBlockCollections = allowBlockStyles;
2253 if (state.lineIndent > parentIndent) {
2255 } else if (state.lineIndent === parentIndent) {
2257 } else if (state.lineIndent < parentIndent) {
2261 allowBlockCollections = false;
2266 if (allowBlockCollections) {
2267 allowBlockCollections = atNewLine || allowCompact;
2270 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2271 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2272 flowIndent = parentIndent;
2274 flowIndent = parentIndent + 1;
2277 blockIndent = state.position - state.lineStart;
2279 if (indentStatus === 1) {
2280 if (allowBlockCollections &&
2281 (readBlockSequence(state, blockIndent) ||
2282 readBlockMapping(state, blockIndent, flowIndent)) ||
2283 readFlowCollection(state, flowIndent)) {
2286 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
2287 readSingleQuotedScalar(state, flowIndent) ||
2288 readDoubleQuotedScalar(state, flowIndent)) {
2291 } else if (readAlias(state)) {
2294 if (state.tag !== null || state.anchor !== null) {
2295 throwError(state, 'alias node should not have any properties');
2298 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2301 if (state.tag === null) {
2306 if (state.anchor !== null) {
2307 state.anchorMap[state.anchor] = state.result;
2310 } else if (indentStatus === 0) {
2311 // Special case: block sequences are allowed to have same indentation level as the parent.
2312 // http://www.yaml.org/spec/1.2/spec.html#id2799784
2313 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2317 if (state.tag !== null && state.tag !== '!') {
2318 if (state.tag === '?') {
2319 for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
2320 typeIndex < typeQuantity;
2322 type = state.implicitTypes[typeIndex];
2324 // Implicit resolving is not allowed for non-scalar types, and '?'
2325 // non-specific tag is only assigned to plain scalars. So, it isn't
2326 // needed to check for 'kind' conformity.
2328 if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
2329 state.result = type.construct(state.result);
2330 state.tag = type.tag;
2331 if (state.anchor !== null) {
2332 state.anchorMap[state.anchor] = state.result;
2337 } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
2338 type = state.typeMap[state.kind || 'fallback'][state.tag];
2340 if (state.result !== null && type.kind !== state.kind) {
2341 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2344 if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
2345 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
2347 state.result = type.construct(state.result);
2348 if (state.anchor !== null) {
2349 state.anchorMap[state.anchor] = state.result;
2353 throwError(state, 'unknown tag !<' + state.tag + '>');
2357 if (state.listener !== null) {
2358 state.listener('close', state);
2360 return state.tag !== null || state.anchor !== null || hasContent;
2363 function readDocument(state) {
2364 var documentStart = state.position,
2368 hasDirectives = false,
2371 state.version = null;
2372 state.checkLineBreaks = state.legacy;
2374 state.anchorMap = {};
2376 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2377 skipSeparationSpace(state, true, -1);
2379 ch = state.input.charCodeAt(state.position);
2381 if (state.lineIndent > 0 || ch !== 0x25/* % */) {
2385 hasDirectives = true;
2386 ch = state.input.charCodeAt(++state.position);
2387 _position = state.position;
2389 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2390 ch = state.input.charCodeAt(++state.position);
2393 directiveName = state.input.slice(_position, state.position);
2396 if (directiveName.length < 1) {
2397 throwError(state, 'directive name must not be less than one character in length');
2401 while (is_WHITE_SPACE(ch)) {
2402 ch = state.input.charCodeAt(++state.position);
2405 if (ch === 0x23/* # */) {
2406 do { ch = state.input.charCodeAt(++state.position); }
2407 while (ch !== 0 && !is_EOL(ch));
2411 if (is_EOL(ch)) break;
2413 _position = state.position;
2415 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2416 ch = state.input.charCodeAt(++state.position);
2419 directiveArgs.push(state.input.slice(_position, state.position));
2422 if (ch !== 0) readLineBreak(state);
2424 if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2425 directiveHandlers[directiveName](state, directiveName, directiveArgs);
2427 throwWarning(state, 'unknown document directive "' + directiveName + '"');
2431 skipSeparationSpace(state, true, -1);
2433 if (state.lineIndent === 0 &&
2434 state.input.charCodeAt(state.position) === 0x2D/* - */ &&
2435 state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
2436 state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
2437 state.position += 3;
2438 skipSeparationSpace(state, true, -1);
2440 } else if (hasDirectives) {
2441 throwError(state, 'directives end mark is expected');
2444 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2445 skipSeparationSpace(state, true, -1);
2447 if (state.checkLineBreaks &&
2448 PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2449 throwWarning(state, 'non-ASCII line breaks are interpreted as content');
2452 state.documents.push(state.result);
2454 if (state.position === state.lineStart && testDocumentSeparator(state)) {
2456 if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
2457 state.position += 3;
2458 skipSeparationSpace(state, true, -1);
2463 if (state.position < (state.length - 1)) {
2464 throwError(state, 'end of the stream or a document separator is expected');
2471 function loadDocuments(input, options) {
2472 input = String(input);
2473 options = options || {};
2475 if (input.length !== 0) {
2477 // Add tailing `\n` if not exists
2478 if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
2479 input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
2484 if (input.charCodeAt(0) === 0xFEFF) {
2485 input = input.slice(1);
2489 var state = new State(input, options);
2491 // Use 0 as string terminator. That significantly simplifies bounds check.
2492 state.input += '\0';
2494 while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
2495 state.lineIndent += 1;
2496 state.position += 1;
2499 while (state.position < (state.length - 1)) {
2500 readDocument(state);
2503 return state.documents;
2507 function loadAll(input, iterator, options) {
2508 var documents = loadDocuments(input, options), index, length;
2510 for (index = 0, length = documents.length; index < length; index += 1) {
2511 iterator(documents[index]);
2516 function load(input, options) {
2517 var documents = loadDocuments(input, options);
2519 if (documents.length === 0) {
2520 /*eslint-disable no-undefined*/
2522 } else if (documents.length === 1) {
2523 return documents[0];
2525 throw new YAMLException('expected a single document in the stream, but found more');
2529 function safeLoadAll(input, output, options) {
2530 loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2534 function safeLoad(input, options) {
2535 return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2539 module.exports.loadAll = loadAll;
2540 module.exports.load = load;
2541 module.exports.safeLoadAll = safeLoadAll;
2542 module.exports.safeLoad = safeLoad;
2544 },{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){
2548 var common = require('./common');
2551 function Mark(name, buffer, position, line, column) {
2553 this.buffer = buffer;
2554 this.position = position;
2556 this.column = column;
2560 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2561 var head, start, tail, end, snippet;
2563 if (!this.buffer) return null;
2565 indent = indent || 4;
2566 maxLength = maxLength || 75;
2569 start = this.position;
2571 while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
2573 if (this.position - start > (maxLength / 2 - 1)) {
2581 end = this.position;
2583 while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
2585 if (end - this.position > (maxLength / 2 - 1)) {
2592 snippet = this.buffer.slice(start, end);
2594 return common.repeat(' ', indent) + head + snippet + tail + '\n' +
2595 common.repeat(' ', indent + this.position - start + head.length) + '^';
2599 Mark.prototype.toString = function toString(compact) {
2600 var snippet, where = '';
2603 where += 'in "' + this.name + '" ';
2606 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
2609 snippet = this.getSnippet();
2612 where += ':\n' + snippet;
2620 module.exports = Mark;
2622 },{"./common":2}],7:[function(require,module,exports){
2625 /*eslint-disable max-len*/
2627 var common = require('./common');
2628 var YAMLException = require('./exception');
2629 var Type = require('./type');
2632 function compileList(schema, name, result) {
2635 schema.include.forEach(function (includedSchema) {
2636 result = compileList(includedSchema, name, result);
2639 schema[name].forEach(function (currentType) {
2640 result.forEach(function (previousType, previousIndex) {
2641 if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
2642 exclude.push(previousIndex);
2646 result.push(currentType);
2649 return result.filter(function (type, index) {
2650 return exclude.indexOf(index) === -1;
2655 function compileMap(/* lists... */) {
2663 function collectType(type) {
2664 result[type.kind][type.tag] = result['fallback'][type.tag] = type;
2667 for (index = 0, length = arguments.length; index < length; index += 1) {
2668 arguments[index].forEach(collectType);
2674 function Schema(definition) {
2675 this.include = definition.include || [];
2676 this.implicit = definition.implicit || [];
2677 this.explicit = definition.explicit || [];
2679 this.implicit.forEach(function (type) {
2680 if (type.loadKind && type.loadKind !== 'scalar') {
2681 throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
2685 this.compiledImplicit = compileList(this, 'implicit', []);
2686 this.compiledExplicit = compileList(this, 'explicit', []);
2687 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
2691 Schema.DEFAULT = null;
2694 Schema.create = function createSchema() {
2697 switch (arguments.length) {
2699 schemas = Schema.DEFAULT;
2700 types = arguments[0];
2704 schemas = arguments[0];
2705 types = arguments[1];
2709 throw new YAMLException('Wrong number of arguments for Schema.create function');
2712 schemas = common.toArray(schemas);
2713 types = common.toArray(types);
2715 if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
2716 throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
2719 if (!types.every(function (type) { return type instanceof Type; })) {
2720 throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
2730 module.exports = Schema;
2732 },{"./common":2,"./exception":4,"./type":13}],8:[function(require,module,exports){
2733 // Standard YAML's Core schema.
2734 // http://www.yaml.org/spec/1.2/spec.html#id2804923
2736 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2737 // So, Core schema has no distinctions from JSON schema is JS-YAML.
2743 var Schema = require('../schema');
2746 module.exports = new Schema({
2752 },{"../schema":7,"./json":12}],9:[function(require,module,exports){
2753 // JS-YAML's default schema for `load` function.
2754 // It is not described in the YAML specification.
2756 // This schema is based on JS-YAML's default safe schema and includes
2757 // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
2759 // Also this schema is used as default base schema at `Schema.create` function.
2765 var Schema = require('../schema');
2768 module.exports = Schema.DEFAULT = new Schema({
2770 require('./default_safe')
2773 require('../type/js/undefined'),
2774 require('../type/js/regexp'),
2775 require('../type/js/function')
2779 },{"../schema":7,"../type/js/function":18,"../type/js/regexp":19,"../type/js/undefined":20,"./default_safe":10}],10:[function(require,module,exports){
2780 // JS-YAML's default schema for `safeLoad` function.
2781 // It is not described in the YAML specification.
2783 // This schema is based on standard YAML's Core schema and includes most of
2784 // extra types described at YAML tag repository. (http://yaml.org/type/)
2790 var Schema = require('../schema');
2793 module.exports = new Schema({
2798 require('../type/timestamp'),
2799 require('../type/merge')
2802 require('../type/binary'),
2803 require('../type/omap'),
2804 require('../type/pairs'),
2805 require('../type/set')
2809 },{"../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){
2810 // Standard YAML's Failsafe schema.
2811 // http://www.yaml.org/spec/1.2/spec.html#id2802346
2817 var Schema = require('../schema');
2820 module.exports = new Schema({
2822 require('../type/str'),
2823 require('../type/seq'),
2824 require('../type/map')
2828 },{"../schema":7,"../type/map":21,"../type/seq":26,"../type/str":28}],12:[function(require,module,exports){
2829 // Standard YAML's JSON schema.
2830 // http://www.yaml.org/spec/1.2/spec.html#id2803231
2832 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2833 // So, this schema is not such strict as defined in the YAML specification.
2834 // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
2840 var Schema = require('../schema');
2843 module.exports = new Schema({
2845 require('./failsafe')
2848 require('../type/null'),
2849 require('../type/bool'),
2850 require('../type/int'),
2851 require('../type/float')
2855 },{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){
2858 var YAMLException = require('./exception');
2860 var TYPE_CONSTRUCTOR_OPTIONS = [
2871 var YAML_NODE_KINDS = [
2877 function compileStyleAliases(map) {
2881 Object.keys(map).forEach(function (style) {
2882 map[style].forEach(function (alias) {
2883 result[String(alias)] = style;
2891 function Type(tag, options) {
2892 options = options || {};
2894 Object.keys(options).forEach(function (name) {
2895 if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
2896 throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
2900 // TODO: Add tag format check.
2902 this.kind = options['kind'] || null;
2903 this.resolve = options['resolve'] || function () { return true; };
2904 this.construct = options['construct'] || function (data) { return data; };
2905 this.instanceOf = options['instanceOf'] || null;
2906 this.predicate = options['predicate'] || null;
2907 this.represent = options['represent'] || null;
2908 this.defaultStyle = options['defaultStyle'] || null;
2909 this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
2911 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
2912 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
2916 module.exports = Type;
2918 },{"./exception":4}],14:[function(require,module,exports){
2921 /*eslint-disable no-bitwise*/
2926 // A trick for browserified version, to not include `Buffer` shim
2927 var _require = require;
2928 NodeBuffer = _require('buffer').Buffer;
2931 var Type = require('../type');
2934 // [ 64, 65, 66 ] -> [ padding, CR, LF ]
2935 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
2938 function resolveYamlBinary(data) {
2939 if (data === null) return false;
2941 var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
2943 // Convert one by one.
2944 for (idx = 0; idx < max; idx++) {
2945 code = map.indexOf(data.charAt(idx));
2948 if (code > 64) continue;
2950 // Fail on illegal characters
2951 if (code < 0) return false;
2956 // If there are any bits left, source was corrupted
2957 return (bitlen % 8) === 0;
2960 function constructYamlBinary(data) {
2962 input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
2968 // Collect by 6*4 bits (3 bytes)
2970 for (idx = 0; idx < max; idx++) {
2971 if ((idx % 4 === 0) && idx) {
2972 result.push((bits >> 16) & 0xFF);
2973 result.push((bits >> 8) & 0xFF);
2974 result.push(bits & 0xFF);
2977 bits = (bits << 6) | map.indexOf(input.charAt(idx));
2982 tailbits = (max % 4) * 6;
2984 if (tailbits === 0) {
2985 result.push((bits >> 16) & 0xFF);
2986 result.push((bits >> 8) & 0xFF);
2987 result.push(bits & 0xFF);
2988 } else if (tailbits === 18) {
2989 result.push((bits >> 10) & 0xFF);
2990 result.push((bits >> 2) & 0xFF);
2991 } else if (tailbits === 12) {
2992 result.push((bits >> 4) & 0xFF);
2995 // Wrap into Buffer for NodeJS and leave Array for browser
2997 // Support node 6.+ Buffer API when available
2998 return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
3004 function representYamlBinary(object /*, style*/) {
3005 var result = '', bits = 0, idx, tail,
3006 max = object.length,
3009 // Convert every three bytes to 4 ASCII characters.
3011 for (idx = 0; idx < max; idx++) {
3012 if ((idx % 3 === 0) && idx) {
3013 result += map[(bits >> 18) & 0x3F];
3014 result += map[(bits >> 12) & 0x3F];
3015 result += map[(bits >> 6) & 0x3F];
3016 result += map[bits & 0x3F];
3019 bits = (bits << 8) + object[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 } else if (tail === 2) {
3032 result += map[(bits >> 10) & 0x3F];
3033 result += map[(bits >> 4) & 0x3F];
3034 result += map[(bits << 2) & 0x3F];
3036 } else if (tail === 1) {
3037 result += map[(bits >> 2) & 0x3F];
3038 result += map[(bits << 4) & 0x3F];
3046 function isBinary(object) {
3047 return NodeBuffer && NodeBuffer.isBuffer(object);
3050 module.exports = new Type('tag:yaml.org,2002:binary', {
3052 resolve: resolveYamlBinary,
3053 construct: constructYamlBinary,
3054 predicate: isBinary,
3055 represent: representYamlBinary
3058 },{"../type":13}],15:[function(require,module,exports){
3061 var Type = require('../type');
3063 function resolveYamlBoolean(data) {
3064 if (data === null) return false;
3066 var max = data.length;
3068 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
3069 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
3072 function constructYamlBoolean(data) {
3073 return data === 'true' ||
3078 function isBoolean(object) {
3079 return Object.prototype.toString.call(object) === '[object Boolean]';
3082 module.exports = new Type('tag:yaml.org,2002:bool', {
3084 resolve: resolveYamlBoolean,
3085 construct: constructYamlBoolean,
3086 predicate: isBoolean,
3088 lowercase: function (object) { return object ? 'true' : 'false'; },
3089 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
3090 camelcase: function (object) { return object ? 'True' : 'False'; }
3092 defaultStyle: 'lowercase'
3095 },{"../type":13}],16:[function(require,module,exports){
3098 var common = require('../common');
3099 var Type = require('../type');
3101 var YAML_FLOAT_PATTERN = new RegExp(
3102 // 2.5e4, 2.5 and integers
3103 '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
3105 // special case, seems not from spec
3106 '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
3108 '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
3110 '|[-+]?\\.(?:inf|Inf|INF)' +
3112 '|\\.(?:nan|NaN|NAN))$');
3114 function resolveYamlFloat(data) {
3115 if (data === null) return false;
3117 if (!YAML_FLOAT_PATTERN.test(data)) return false;
3122 function constructYamlFloat(data) {
3123 var value, sign, base, digits;
3125 value = data.replace(/_/g, '').toLowerCase();
3126 sign = value[0] === '-' ? -1 : 1;
3129 if ('+-'.indexOf(value[0]) >= 0) {
3130 value = value.slice(1);
3133 if (value === '.inf') {
3134 return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
3136 } else if (value === '.nan') {
3139 } else if (value.indexOf(':') >= 0) {
3140 value.split(':').forEach(function (v) {
3141 digits.unshift(parseFloat(v, 10));
3147 digits.forEach(function (d) {
3152 return sign * value;
3155 return sign * parseFloat(value, 10);
3159 var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
3161 function representYamlFloat(object, style) {
3164 if (isNaN(object)) {
3166 case 'lowercase': return '.nan';
3167 case 'uppercase': return '.NAN';
3168 case 'camelcase': return '.NaN';
3170 } else if (Number.POSITIVE_INFINITY === object) {
3172 case 'lowercase': return '.inf';
3173 case 'uppercase': return '.INF';
3174 case 'camelcase': return '.Inf';
3176 } else if (Number.NEGATIVE_INFINITY === object) {
3178 case 'lowercase': return '-.inf';
3179 case 'uppercase': return '-.INF';
3180 case 'camelcase': return '-.Inf';
3182 } else if (common.isNegativeZero(object)) {
3186 res = object.toString(10);
3188 // JS stringifier can build scientific format without dots: 5e-100,
3189 // while YAML requres dot: 5.e-100. Fix it with simple hack
3191 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
3194 function isFloat(object) {
3195 return (Object.prototype.toString.call(object) === '[object Number]') &&
3196 (object % 1 !== 0 || common.isNegativeZero(object));
3199 module.exports = new Type('tag:yaml.org,2002:float', {
3201 resolve: resolveYamlFloat,
3202 construct: constructYamlFloat,
3204 represent: representYamlFloat,
3205 defaultStyle: 'lowercase'
3208 },{"../common":2,"../type":13}],17:[function(require,module,exports){
3211 var common = require('../common');
3212 var Type = require('../type');
3214 function isHexCode(c) {
3215 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
3216 ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
3217 ((0x61/* a */ <= c) && (c <= 0x66/* f */));
3220 function isOctCode(c) {
3221 return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
3224 function isDecCode(c) {
3225 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
3228 function resolveYamlInteger(data) {
3229 if (data === null) return false;
3231 var max = data.length,
3236 if (!max) return false;
3241 if (ch === '-' || ch === '+') {
3247 if (index + 1 === max) return true;
3250 // base 2, base 8, base 16
3256 for (; index < max; index++) {
3258 if (ch === '_') continue;
3259 if (ch !== '0' && ch !== '1') return false;
3270 for (; index < max; index++) {
3272 if (ch === '_') continue;
3273 if (!isHexCode(data.charCodeAt(index))) return false;
3280 for (; index < max; index++) {
3282 if (ch === '_') continue;
3283 if (!isOctCode(data.charCodeAt(index))) return false;
3289 // base 10 (except 0) or base 60
3291 for (; index < max; index++) {
3293 if (ch === '_') continue;
3294 if (ch === ':') break;
3295 if (!isDecCode(data.charCodeAt(index))) {
3301 if (!hasDigits) return false;
3303 // if !base60 - done;
3304 if (ch !== ':') return true;
3306 // base60 almost not used, no needs to optimize
3307 return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
3310 function constructYamlInteger(data) {
3311 var value = data, sign = 1, ch, base, digits = [];
3313 if (value.indexOf('_') !== -1) {
3314 value = value.replace(/_/g, '');
3319 if (ch === '-' || ch === '+') {
3320 if (ch === '-') sign = -1;
3321 value = value.slice(1);
3325 if (value === '0') return 0;
3328 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
3329 if (value[1] === 'x') return sign * parseInt(value, 16);
3330 return sign * parseInt(value, 8);
3333 if (value.indexOf(':') !== -1) {
3334 value.split(':').forEach(function (v) {
3335 digits.unshift(parseInt(v, 10));
3341 digits.forEach(function (d) {
3342 value += (d * base);
3346 return sign * value;
3350 return sign * parseInt(value, 10);
3353 function isInteger(object) {
3354 return (Object.prototype.toString.call(object)) === '[object Number]' &&
3355 (object % 1 === 0 && !common.isNegativeZero(object));
3358 module.exports = new Type('tag:yaml.org,2002:int', {
3360 resolve: resolveYamlInteger,
3361 construct: constructYamlInteger,
3362 predicate: isInteger,
3364 binary: function (object) { return '0b' + object.toString(2); },
3365 octal: function (object) { return '0' + object.toString(8); },
3366 decimal: function (object) { return object.toString(10); },
3367 hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
3369 defaultStyle: 'decimal',
3371 binary: [ 2, 'bin' ],
3372 octal: [ 8, 'oct' ],
3373 decimal: [ 10, 'dec' ],
3374 hexadecimal: [ 16, 'hex' ]
3378 },{"../common":2,"../type":13}],18:[function(require,module,exports){
3383 // Browserified version does not have esprima
3385 // 1. For node.js just require module as deps
3386 // 2. For browser try to require mudule via external AMD system.
3387 // If not found - try to fallback to window.esprima. If not
3388 // found too - then fail to parse.
3391 // workaround to exclude package from browserify list.
3392 var _require = require;
3393 esprima = _require('esprima');
3396 if (typeof window !== 'undefined') esprima = window.esprima;
3399 var Type = require('../../type');
3401 function resolveJavascriptFunction(data) {
3402 if (data === null) return false;
3405 var source = '(' + data + ')',
3406 ast = esprima.parse(source, { range: true });
3408 if (ast.type !== 'Program' ||
3409 ast.body.length !== 1 ||
3410 ast.body[0].type !== 'ExpressionStatement' ||
3411 ast.body[0].expression.type !== 'FunctionExpression') {
3421 function constructJavascriptFunction(data) {
3422 /*jslint evil:true*/
3424 var source = '(' + data + ')',
3425 ast = esprima.parse(source, { range: true }),
3429 if (ast.type !== 'Program' ||
3430 ast.body.length !== 1 ||
3431 ast.body[0].type !== 'ExpressionStatement' ||
3432 ast.body[0].expression.type !== 'FunctionExpression') {
3433 throw new Error('Failed to resolve function');
3436 ast.body[0].expression.params.forEach(function (param) {
3437 params.push(param.name);
3440 body = ast.body[0].expression.body.range;
3442 // Esprima's ranges include the first '{' and the last '}' characters on
3443 // function expressions. So cut them out.
3444 /*eslint-disable no-new-func*/
3445 return new Function(params, source.slice(body[0] + 1, body[1] - 1));
3448 function representJavascriptFunction(object /*, style*/) {
3449 return object.toString();
3452 function isFunction(object) {
3453 return Object.prototype.toString.call(object) === '[object Function]';
3456 module.exports = new Type('tag:yaml.org,2002:js/function', {
3458 resolve: resolveJavascriptFunction,
3459 construct: constructJavascriptFunction,
3460 predicate: isFunction,
3461 represent: representJavascriptFunction
3464 },{"../../type":13}],19:[function(require,module,exports){
3467 var Type = require('../../type');
3469 function resolveJavascriptRegExp(data) {
3470 if (data === null) return false;
3471 if (data.length === 0) return false;
3474 tail = /\/([gim]*)$/.exec(data),
3477 // if regexp starts with '/' it can have modifiers and must be properly closed
3478 // `/foo/gim` - modifiers tail can be maximum 3 chars
3479 if (regexp[0] === '/') {
3480 if (tail) modifiers = tail[1];
3482 if (modifiers.length > 3) return false;
3483 // if expression starts with /, is should be properly terminated
3484 if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
3490 function constructJavascriptRegExp(data) {
3492 tail = /\/([gim]*)$/.exec(data),
3495 // `/foo/gim` - tail can be maximum 4 chars
3496 if (regexp[0] === '/') {
3497 if (tail) modifiers = tail[1];
3498 regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3501 return new RegExp(regexp, modifiers);
3504 function representJavascriptRegExp(object /*, style*/) {
3505 var result = '/' + object.source + '/';
3507 if (object.global) result += 'g';
3508 if (object.multiline) result += 'm';
3509 if (object.ignoreCase) result += 'i';
3514 function isRegExp(object) {
3515 return Object.prototype.toString.call(object) === '[object RegExp]';
3518 module.exports = new Type('tag:yaml.org,2002:js/regexp', {
3520 resolve: resolveJavascriptRegExp,
3521 construct: constructJavascriptRegExp,
3522 predicate: isRegExp,
3523 represent: representJavascriptRegExp
3526 },{"../../type":13}],20:[function(require,module,exports){
3529 var Type = require('../../type');
3531 function resolveJavascriptUndefined() {
3535 function constructJavascriptUndefined() {
3536 /*eslint-disable no-undefined*/
3540 function representJavascriptUndefined() {
3544 function isUndefined(object) {
3545 return typeof object === 'undefined';
3548 module.exports = new Type('tag:yaml.org,2002:js/undefined', {
3550 resolve: resolveJavascriptUndefined,
3551 construct: constructJavascriptUndefined,
3552 predicate: isUndefined,
3553 represent: representJavascriptUndefined
3556 },{"../../type":13}],21:[function(require,module,exports){
3559 var Type = require('../type');
3561 module.exports = new Type('tag:yaml.org,2002:map', {
3563 construct: function (data) { return data !== null ? data : {}; }
3566 },{"../type":13}],22:[function(require,module,exports){
3569 var Type = require('../type');
3571 function resolveYamlMerge(data) {
3572 return data === '<<' || data === null;
3575 module.exports = new Type('tag:yaml.org,2002:merge', {
3577 resolve: resolveYamlMerge
3580 },{"../type":13}],23:[function(require,module,exports){
3583 var Type = require('../type');
3585 function resolveYamlNull(data) {
3586 if (data === null) return true;
3588 var max = data.length;
3590 return (max === 1 && data === '~') ||
3591 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
3594 function constructYamlNull() {
3598 function isNull(object) {
3599 return object === null;
3602 module.exports = new Type('tag:yaml.org,2002:null', {
3604 resolve: resolveYamlNull,
3605 construct: constructYamlNull,
3608 canonical: function () { return '~'; },
3609 lowercase: function () { return 'null'; },
3610 uppercase: function () { return 'NULL'; },
3611 camelcase: function () { return 'Null'; }
3613 defaultStyle: 'lowercase'
3616 },{"../type":13}],24:[function(require,module,exports){
3619 var Type = require('../type');
3621 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3622 var _toString = Object.prototype.toString;
3624 function resolveYamlOmap(data) {
3625 if (data === null) return true;
3627 var objectKeys = [], index, length, pair, pairKey, pairHasKey,
3630 for (index = 0, length = object.length; index < length; index += 1) {
3631 pair = object[index];
3634 if (_toString.call(pair) !== '[object Object]') return false;
3636 for (pairKey in pair) {
3637 if (_hasOwnProperty.call(pair, pairKey)) {
3638 if (!pairHasKey) pairHasKey = true;
3643 if (!pairHasKey) return false;
3645 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
3652 function constructYamlOmap(data) {
3653 return data !== null ? data : [];
3656 module.exports = new Type('tag:yaml.org,2002:omap', {
3658 resolve: resolveYamlOmap,
3659 construct: constructYamlOmap
3662 },{"../type":13}],25:[function(require,module,exports){
3665 var Type = require('../type');
3667 var _toString = Object.prototype.toString;
3669 function resolveYamlPairs(data) {
3670 if (data === null) return true;
3672 var index, length, pair, keys, result,
3675 result = new Array(object.length);
3677 for (index = 0, length = object.length; index < length; index += 1) {
3678 pair = object[index];
3680 if (_toString.call(pair) !== '[object Object]') return false;
3682 keys = Object.keys(pair);
3684 if (keys.length !== 1) return false;
3686 result[index] = [ keys[0], pair[keys[0]] ];
3692 function constructYamlPairs(data) {
3693 if (data === null) return [];
3695 var index, length, pair, keys, result,
3698 result = new Array(object.length);
3700 for (index = 0, length = object.length; index < length; index += 1) {
3701 pair = object[index];
3703 keys = Object.keys(pair);
3705 result[index] = [ keys[0], pair[keys[0]] ];
3711 module.exports = new Type('tag:yaml.org,2002:pairs', {
3713 resolve: resolveYamlPairs,
3714 construct: constructYamlPairs
3717 },{"../type":13}],26:[function(require,module,exports){
3720 var Type = require('../type');
3722 module.exports = new Type('tag:yaml.org,2002:seq', {
3724 construct: function (data) { return data !== null ? data : []; }
3727 },{"../type":13}],27:[function(require,module,exports){
3730 var Type = require('../type');
3732 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3734 function resolveYamlSet(data) {
3735 if (data === null) return true;
3737 var key, object = data;
3739 for (key in object) {
3740 if (_hasOwnProperty.call(object, key)) {
3741 if (object[key] !== null) return false;
3748 function constructYamlSet(data) {
3749 return data !== null ? data : {};
3752 module.exports = new Type('tag:yaml.org,2002:set', {
3754 resolve: resolveYamlSet,
3755 construct: constructYamlSet
3758 },{"../type":13}],28:[function(require,module,exports){
3761 var Type = require('../type');
3763 module.exports = new Type('tag:yaml.org,2002:str', {
3765 construct: function (data) { return data !== null ? data : ''; }
3768 },{"../type":13}],29:[function(require,module,exports){
3771 var Type = require('../type');
3773 var YAML_DATE_REGEXP = new RegExp(
3774 '^([0-9][0-9][0-9][0-9])' + // [1] year
3775 '-([0-9][0-9])' + // [2] month
3776 '-([0-9][0-9])$'); // [3] day
3778 var YAML_TIMESTAMP_REGEXP = new RegExp(
3779 '^([0-9][0-9][0-9][0-9])' + // [1] year
3780 '-([0-9][0-9]?)' + // [2] month
3781 '-([0-9][0-9]?)' + // [3] day
3782 '(?:[Tt]|[ \\t]+)' + // ...
3783 '([0-9][0-9]?)' + // [4] hour
3784 ':([0-9][0-9])' + // [5] minute
3785 ':([0-9][0-9])' + // [6] second
3786 '(?:\\.([0-9]*))?' + // [7] fraction
3787 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
3788 '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
3790 function resolveYamlTimestamp(data) {
3791 if (data === null) return false;
3792 if (YAML_DATE_REGEXP.exec(data) !== null) return true;
3793 if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
3797 function constructYamlTimestamp(data) {
3798 var match, year, month, day, hour, minute, second, fraction = 0,
3799 delta = null, tz_hour, tz_minute, date;
3801 match = YAML_DATE_REGEXP.exec(data);
3802 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
3804 if (match === null) throw new Error('Date resolve error');
3806 // match: [1] year [2] month [3] day
3809 month = +(match[2]) - 1; // JS month starts with 0
3812 if (!match[4]) { // no hour
3813 return new Date(Date.UTC(year, month, day));
3816 // match: [4] hour [5] minute [6] second [7] fraction
3819 minute = +(match[5]);
3820 second = +(match[6]);
3823 fraction = match[7].slice(0, 3);
3824 while (fraction.length < 3) { // milli-seconds
3827 fraction = +fraction;
3830 // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
3833 tz_hour = +(match[10]);
3834 tz_minute = +(match[11] || 0);
3835 delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
3836 if (match[9] === '-') delta = -delta;
3839 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
3841 if (delta) date.setTime(date.getTime() - delta);
3846 function representYamlTimestamp(object /*, style*/) {
3847 return object.toISOString();
3850 module.exports = new Type('tag:yaml.org,2002:timestamp', {
3852 resolve: resolveYamlTimestamp,
3853 construct: constructYamlTimestamp,
3855 represent: representYamlTimestamp
3858 },{"../type":13}],"/":[function(require,module,exports){
3862 var yaml = require('./lib/js-yaml.js');
3865 module.exports = yaml;
3867 },{"./lib/js-yaml.js":1}]},{},[])("/")