Bug 24193: Add CodeMirror linting of JavaScript, CSS, HTML, and YAML
[koha.git] / koha-tmpl / intranet-tmpl / lib / linters / js-yaml.js
blobfad044a48a8e4fe23d0f903afa390bb916d1ac1d
1 /* js-yaml 3.13.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(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2 'use strict';
5 var loader = require('./js-yaml/loader');
6 var dumper = require('./js-yaml/dumper');
9 function deprecated(name) {
10   return function () {
11     throw new Error('Function ' + name + ' is deprecated and cannot be used.');
12   };
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){
43 'use strict';
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 [];
60   return [ sequence ];
64 function extend(target, source) {
65   var index, length, key, sourceKeys;
67   if (source) {
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];
73     }
74   }
76   return target;
80 function repeat(string, count) {
81   var result = '', cycle;
83   for (cycle = 0; cycle < count; cycle += 1) {
84     result += string;
85   }
87   return result;
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){
104 'use strict';
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 {};
167   result = {};
168   keys = Object.keys(map);
170   for (index = 0, length = keys.length; index < length; index += 1) {
171     tag = keys[index];
172     style = String(map[tag]);
174     if (tag.slice(0, 2) === '!!') {
175       tag = 'tag:yaml.org,2002:' + tag.slice(2);
176     }
177     type = schema.compiledTypeMap['fallback'][tag];
179     if (type && _hasOwnProperty.call(type.styleAliases, style)) {
180       style = type.styleAliases[style];
181     }
183     result[tag] = style;
184   }
186   return result;
189 function encodeHex(character) {
190   var string, handle, length;
192   string = character.toString(16).toUpperCase();
194   if (character <= 0xFF) {
195     handle = 'x';
196     length = 2;
197   } else if (character <= 0xFFFF) {
198     handle = 'u';
199     length = 4;
200   } else if (character <= 0xFFFFFFFF) {
201     handle = 'U';
202     length = 8;
203   } else {
204     throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
205   }
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.noArrayIndent = options['noArrayIndent'] || false;
214   this.skipInvalid   = options['skipInvalid'] || false;
215   this.flowLevel     = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
216   this.styleMap      = compileStyleMap(this.schema, options['styles'] || null);
217   this.sortKeys      = options['sortKeys'] || false;
218   this.lineWidth     = options['lineWidth'] || 80;
219   this.noRefs        = options['noRefs'] || false;
220   this.noCompatMode  = options['noCompatMode'] || false;
221   this.condenseFlow  = options['condenseFlow'] || false;
223   this.implicitTypes = this.schema.compiledImplicit;
224   this.explicitTypes = this.schema.compiledExplicit;
226   this.tag = null;
227   this.result = '';
229   this.duplicates = [];
230   this.usedDuplicates = null;
233 // Indents every line in a string. Empty lines (\n only) are not indented.
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;
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     }
252     if (line.length && line !== '\n') result += ind;
254     result += line;
255   }
257   return result;
260 function generateNextLine(state, level) {
261   return '\n' + common.repeat(' ', state.indent * level);
264 function testImplicitResolving(state, str) {
265   var index, length, type;
267   for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
268     type = state.implicitTypes[index];
270     if (type.resolve(str)) {
271       return true;
272     }
273   }
275   return false;
278 // [33] s-white ::= s-space | s-tab
279 function isWhitespace(c) {
280   return c === CHAR_SPACE || c === CHAR_TAB;
283 // Returns true if the character can be printed without escaping.
284 // From YAML 1.2: "any allowed characters known to be non-printable
285 // should also be escaped. [However,] This isn’t mandatory"
286 // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
287 function isPrintable(c) {
288   return  (0x00020 <= c && c <= 0x00007E)
289       || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
290       || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
291       ||  (0x10000 <= c && c <= 0x10FFFF);
294 // Simplified test for values allowed after the first character in plain style.
295 function isPlainSafe(c) {
296   // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
297   // where nb-char ::= c-printable - b-char - c-byte-order-mark.
298   return isPrintable(c) && c !== 0xFEFF
299     // - c-flow-indicator
300     && c !== CHAR_COMMA
301     && c !== CHAR_LEFT_SQUARE_BRACKET
302     && c !== CHAR_RIGHT_SQUARE_BRACKET
303     && c !== CHAR_LEFT_CURLY_BRACKET
304     && c !== CHAR_RIGHT_CURLY_BRACKET
305     // - ":" - "#"
306     && c !== CHAR_COLON
307     && c !== CHAR_SHARP;
310 // Simplified test for values allowed as the first character in plain style.
311 function isPlainSafeFirst(c) {
312   // Uses a subset of ns-char - c-indicator
313   // where ns-char = nb-char - s-white.
314   return isPrintable(c) && c !== 0xFEFF
315     && !isWhitespace(c) // - s-white
316     // - (c-indicator ::=
317     // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
318     && c !== CHAR_MINUS
319     && c !== CHAR_QUESTION
320     && c !== CHAR_COLON
321     && c !== CHAR_COMMA
322     && c !== CHAR_LEFT_SQUARE_BRACKET
323     && c !== CHAR_RIGHT_SQUARE_BRACKET
324     && c !== CHAR_LEFT_CURLY_BRACKET
325     && c !== CHAR_RIGHT_CURLY_BRACKET
326     // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
327     && c !== CHAR_SHARP
328     && c !== CHAR_AMPERSAND
329     && c !== CHAR_ASTERISK
330     && c !== CHAR_EXCLAMATION
331     && c !== CHAR_VERTICAL_LINE
332     && c !== CHAR_GREATER_THAN
333     && c !== CHAR_SINGLE_QUOTE
334     && c !== CHAR_DOUBLE_QUOTE
335     // | “%” | “@” | “`”)
336     && c !== CHAR_PERCENT
337     && c !== CHAR_COMMERCIAL_AT
338     && c !== CHAR_GRAVE_ACCENT;
341 // Determines whether block indentation indicator is required.
342 function needIndentIndicator(string) {
343   var leadingSpaceRe = /^\n* /;
344   return leadingSpaceRe.test(string);
347 var STYLE_PLAIN   = 1,
348     STYLE_SINGLE  = 2,
349     STYLE_LITERAL = 3,
350     STYLE_FOLDED  = 4,
351     STYLE_DOUBLE  = 5;
353 // Determines which scalar styles are possible and returns the preferred style.
354 // lineWidth = -1 => no limit.
355 // Pre-conditions: str.length > 0.
356 // Post-conditions:
357 //    STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
358 //    STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
359 //    STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
360 function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
361   var i;
362   var char;
363   var hasLineBreak = false;
364   var hasFoldableLine = false; // only checked if shouldTrackWidth
365   var shouldTrackWidth = lineWidth !== -1;
366   var previousLineBreak = -1; // count the first line correctly
367   var plain = isPlainSafeFirst(string.charCodeAt(0))
368           && !isWhitespace(string.charCodeAt(string.length - 1));
370   if (singleLineOnly) {
371     // Case: no block styles.
372     // Check for disallowed characters to rule out plain and single.
373     for (i = 0; i < string.length; i++) {
374       char = string.charCodeAt(i);
375       if (!isPrintable(char)) {
376         return STYLE_DOUBLE;
377       }
378       plain = plain && isPlainSafe(char);
379     }
380   } else {
381     // Case: block styles permitted.
382     for (i = 0; i < string.length; i++) {
383       char = string.charCodeAt(i);
384       if (char === CHAR_LINE_FEED) {
385         hasLineBreak = true;
386         // Check if any line can be folded.
387         if (shouldTrackWidth) {
388           hasFoldableLine = hasFoldableLine ||
389             // Foldable line = too long, and not more-indented.
390             (i - previousLineBreak - 1 > lineWidth &&
391              string[previousLineBreak + 1] !== ' ');
392           previousLineBreak = i;
393         }
394       } else if (!isPrintable(char)) {
395         return STYLE_DOUBLE;
396       }
397       plain = plain && isPlainSafe(char);
398     }
399     // in case the end is missing a \n
400     hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
401       (i - previousLineBreak - 1 > lineWidth &&
402        string[previousLineBreak + 1] !== ' '));
403   }
404   // Although every style can represent \n without escaping, prefer block styles
405   // for multiline, since they're more readable and they don't add empty lines.
406   // Also prefer folding a super-long line.
407   if (!hasLineBreak && !hasFoldableLine) {
408     // Strings interpretable as another type have to be quoted;
409     // e.g. the string 'true' vs. the boolean true.
410     return plain && !testAmbiguousType(string)
411       ? STYLE_PLAIN : STYLE_SINGLE;
412   }
413   // Edge case: block indentation indicator can only have one digit.
414   if (indentPerLevel > 9 && needIndentIndicator(string)) {
415     return STYLE_DOUBLE;
416   }
417   // At this point we know block styles are valid.
418   // Prefer literal style unless we want to fold.
419   return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
422 // Note: line breaking/folding is implemented for only the folded style.
423 // NB. We drop the last trailing newline (if any) of a returned block scalar
424 //  since the dumper adds its own newline. This always works:
425 //    • No ending newline => unaffected; already using strip "-" chomping.
426 //    • Ending newline    => removed then restored.
427 //  Importantly, this keeps the "+" chomp indicator from gaining an extra line.
428 function writeScalar(state, string, level, iskey) {
429   state.dump = (function () {
430     if (string.length === 0) {
431       return "''";
432     }
433     if (!state.noCompatMode &&
434         DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
435       return "'" + string + "'";
436     }
438     var indent = state.indent * Math.max(1, level); // no 0-indent scalars
439     // As indentation gets deeper, let the width decrease monotonically
440     // to the lower bound min(state.lineWidth, 40).
441     // Note that this implies
442     //  state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
443     //  state.lineWidth > 40 + state.indent: width decreases until the lower bound.
444     // This behaves better than a constant minimum width which disallows narrower options,
445     // or an indent threshold which causes the width to suddenly increase.
446     var lineWidth = state.lineWidth === -1
447       ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
449     // Without knowing if keys are implicit/explicit, assume implicit for safety.
450     var singleLineOnly = iskey
451       // No block styles in flow mode.
452       || (state.flowLevel > -1 && level >= state.flowLevel);
453     function testAmbiguity(string) {
454       return testImplicitResolving(state, string);
455     }
457     switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
458       case STYLE_PLAIN:
459         return string;
460       case STYLE_SINGLE:
461         return "'" + string.replace(/'/g, "''") + "'";
462       case STYLE_LITERAL:
463         return '|' + blockHeader(string, state.indent)
464           + dropEndingNewline(indentString(string, indent));
465       case STYLE_FOLDED:
466         return '>' + blockHeader(string, state.indent)
467           + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
468       case STYLE_DOUBLE:
469         return '"' + escapeString(string, lineWidth) + '"';
470       default:
471         throw new YAMLException('impossible error: invalid scalar style');
472     }
473   }());
476 // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
477 function blockHeader(string, indentPerLevel) {
478   var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
480   // note the special case: the string '\n' counts as a "trailing" empty line.
481   var clip =          string[string.length - 1] === '\n';
482   var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
483   var chomp = keep ? '+' : (clip ? '' : '-');
485   return indentIndicator + chomp + '\n';
488 // (See the note for writeScalar.)
489 function dropEndingNewline(string) {
490   return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
493 // Note: a long line without a suitable break point will exceed the width limit.
494 // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
495 function foldString(string, width) {
496   // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
497   // unless they're before or after a more-indented line, or at the very
498   // beginning or end, in which case $k$ maps to $k$.
499   // Therefore, parse each chunk as newline(s) followed by a content line.
500   var lineRe = /(\n+)([^\n]*)/g;
502   // first line (possibly an empty line)
503   var result = (function () {
504     var nextLF = string.indexOf('\n');
505     nextLF = nextLF !== -1 ? nextLF : string.length;
506     lineRe.lastIndex = nextLF;
507     return foldLine(string.slice(0, nextLF), width);
508   }());
509   // If we haven't reached the first content line yet, don't add an extra \n.
510   var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
511   var moreIndented;
513   // rest of the lines
514   var match;
515   while ((match = lineRe.exec(string))) {
516     var prefix = match[1], line = match[2];
517     moreIndented = (line[0] === ' ');
518     result += prefix
519       + (!prevMoreIndented && !moreIndented && line !== ''
520         ? '\n' : '')
521       + foldLine(line, width);
522     prevMoreIndented = moreIndented;
523   }
525   return result;
528 // Greedy line breaking.
529 // Picks the longest line under the limit each time,
530 // otherwise settles for the shortest line over the limit.
531 // NB. More-indented lines *cannot* be folded, as that would add an extra \n.
532 function foldLine(line, width) {
533   if (line === '' || line[0] === ' ') return line;
535   // Since a more-indented line adds a \n, breaks can't be followed by a space.
536   var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
537   var match;
538   // start is an inclusive index. end, curr, and next are exclusive.
539   var start = 0, end, curr = 0, next = 0;
540   var result = '';
542   // Invariants: 0 <= start <= length-1.
543   //   0 <= curr <= next <= max(0, length-2). curr - start <= width.
544   // Inside the loop:
545   //   A match implies length >= 2, so curr and next are <= length-2.
546   while ((match = breakRe.exec(line))) {
547     next = match.index;
548     // maintain invariant: curr - start <= width
549     if (next - start > width) {
550       end = (curr > start) ? curr : next; // derive end <= length-2
551       result += '\n' + line.slice(start, end);
552       // skip the space that was output as \n
553       start = end + 1;                    // derive start <= length-1
554     }
555     curr = next;
556   }
558   // By the invariants, start <= length-1, so there is something left over.
559   // It is either the whole string or a part starting from non-whitespace.
560   result += '\n';
561   // Insert a break if the remainder is too long and there is a break available.
562   if (line.length - start > width && curr > start) {
563     result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
564   } else {
565     result += line.slice(start);
566   }
568   return result.slice(1); // drop extra \n joiner
571 // Escapes a double-quoted string.
572 function escapeString(string) {
573   var result = '';
574   var char, nextChar;
575   var escapeSeq;
577   for (var i = 0; i < string.length; i++) {
578     char = string.charCodeAt(i);
579     // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
580     if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) {
581       nextChar = string.charCodeAt(i + 1);
582       if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) {
583         // Combine the surrogate pair and store it escaped.
584         result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
585         // Advance index one extra since we already used that char here.
586         i++; continue;
587       }
588     }
589     escapeSeq = ESCAPE_SEQUENCES[char];
590     result += !escapeSeq && isPrintable(char)
591       ? string[i]
592       : escapeSeq || encodeHex(char);
593   }
595   return result;
598 function writeFlowSequence(state, level, object) {
599   var _result = '',
600       _tag    = state.tag,
601       index,
602       length;
604   for (index = 0, length = object.length; index < length; index += 1) {
605     // Write only valid elements.
606     if (writeNode(state, level, object[index], false, false)) {
607       if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
608       _result += state.dump;
609     }
610   }
612   state.tag = _tag;
613   state.dump = '[' + _result + ']';
616 function writeBlockSequence(state, level, object, compact) {
617   var _result = '',
618       _tag    = state.tag,
619       index,
620       length;
622   for (index = 0, length = object.length; index < length; index += 1) {
623     // Write only valid elements.
624     if (writeNode(state, level + 1, object[index], true, true)) {
625       if (!compact || index !== 0) {
626         _result += generateNextLine(state, level);
627       }
629       if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
630         _result += '-';
631       } else {
632         _result += '- ';
633       }
635       _result += state.dump;
636     }
637   }
639   state.tag = _tag;
640   state.dump = _result || '[]'; // Empty sequence if no valid values.
643 function writeFlowMapping(state, level, object) {
644   var _result       = '',
645       _tag          = state.tag,
646       objectKeyList = Object.keys(object),
647       index,
648       length,
649       objectKey,
650       objectValue,
651       pairBuffer;
653   for (index = 0, length = objectKeyList.length; index < length; index += 1) {
654     pairBuffer = state.condenseFlow ? '"' : '';
656     if (index !== 0) pairBuffer += ', ';
658     objectKey = objectKeyList[index];
659     objectValue = object[objectKey];
661     if (!writeNode(state, level, objectKey, false, false)) {
662       continue; // Skip this pair because of invalid key;
663     }
665     if (state.dump.length > 1024) pairBuffer += '? ';
667     pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
669     if (!writeNode(state, level, objectValue, false, false)) {
670       continue; // Skip this pair because of invalid value.
671     }
673     pairBuffer += state.dump;
675     // Both key and value are valid.
676     _result += pairBuffer;
677   }
679   state.tag = _tag;
680   state.dump = '{' + _result + '}';
683 function writeBlockMapping(state, level, object, compact) {
684   var _result       = '',
685       _tag          = state.tag,
686       objectKeyList = Object.keys(object),
687       index,
688       length,
689       objectKey,
690       objectValue,
691       explicitPair,
692       pairBuffer;
694   // Allow sorting keys so that the output file is deterministic
695   if (state.sortKeys === true) {
696     // Default sorting
697     objectKeyList.sort();
698   } else if (typeof state.sortKeys === 'function') {
699     // Custom sort function
700     objectKeyList.sort(state.sortKeys);
701   } else if (state.sortKeys) {
702     // Something is wrong
703     throw new YAMLException('sortKeys must be a boolean or a function');
704   }
706   for (index = 0, length = objectKeyList.length; index < length; index += 1) {
707     pairBuffer = '';
709     if (!compact || index !== 0) {
710       pairBuffer += generateNextLine(state, level);
711     }
713     objectKey = objectKeyList[index];
714     objectValue = object[objectKey];
716     if (!writeNode(state, level + 1, objectKey, true, true, true)) {
717       continue; // Skip this pair because of invalid key.
718     }
720     explicitPair = (state.tag !== null && state.tag !== '?') ||
721                    (state.dump && state.dump.length > 1024);
723     if (explicitPair) {
724       if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
725         pairBuffer += '?';
726       } else {
727         pairBuffer += '? ';
728       }
729     }
731     pairBuffer += state.dump;
733     if (explicitPair) {
734       pairBuffer += generateNextLine(state, level);
735     }
737     if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
738       continue; // Skip this pair because of invalid value.
739     }
741     if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
742       pairBuffer += ':';
743     } else {
744       pairBuffer += ': ';
745     }
747     pairBuffer += state.dump;
749     // Both key and value are valid.
750     _result += pairBuffer;
751   }
753   state.tag = _tag;
754   state.dump = _result || '{}'; // Empty mapping if no valid pairs.
757 function detectType(state, object, explicit) {
758   var _result, typeList, index, length, type, style;
760   typeList = explicit ? state.explicitTypes : state.implicitTypes;
762   for (index = 0, length = typeList.length; index < length; index += 1) {
763     type = typeList[index];
765     if ((type.instanceOf  || type.predicate) &&
766         (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
767         (!type.predicate  || type.predicate(object))) {
769       state.tag = explicit ? type.tag : '?';
771       if (type.represent) {
772         style = state.styleMap[type.tag] || type.defaultStyle;
774         if (_toString.call(type.represent) === '[object Function]') {
775           _result = type.represent(object, style);
776         } else if (_hasOwnProperty.call(type.represent, style)) {
777           _result = type.represent[style](object, style);
778         } else {
779           throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
780         }
782         state.dump = _result;
783       }
785       return true;
786     }
787   }
789   return false;
792 // Serializes `object` and writes it to global `result`.
793 // Returns true on success, or false on invalid object.
795 function writeNode(state, level, object, block, compact, iskey) {
796   state.tag = null;
797   state.dump = object;
799   if (!detectType(state, object, false)) {
800     detectType(state, object, true);
801   }
803   var type = _toString.call(state.dump);
805   if (block) {
806     block = (state.flowLevel < 0 || state.flowLevel > level);
807   }
809   var objectOrArray = type === '[object Object]' || type === '[object Array]',
810       duplicateIndex,
811       duplicate;
813   if (objectOrArray) {
814     duplicateIndex = state.duplicates.indexOf(object);
815     duplicate = duplicateIndex !== -1;
816   }
818   if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
819     compact = false;
820   }
822   if (duplicate && state.usedDuplicates[duplicateIndex]) {
823     state.dump = '*ref_' + duplicateIndex;
824   } else {
825     if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
826       state.usedDuplicates[duplicateIndex] = true;
827     }
828     if (type === '[object Object]') {
829       if (block && (Object.keys(state.dump).length !== 0)) {
830         writeBlockMapping(state, level, state.dump, compact);
831         if (duplicate) {
832           state.dump = '&ref_' + duplicateIndex + state.dump;
833         }
834       } else {
835         writeFlowMapping(state, level, state.dump);
836         if (duplicate) {
837           state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
838         }
839       }
840     } else if (type === '[object Array]') {
841       var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level;
842       if (block && (state.dump.length !== 0)) {
843         writeBlockSequence(state, arrayLevel, state.dump, compact);
844         if (duplicate) {
845           state.dump = '&ref_' + duplicateIndex + state.dump;
846         }
847       } else {
848         writeFlowSequence(state, arrayLevel, state.dump);
849         if (duplicate) {
850           state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
851         }
852       }
853     } else if (type === '[object String]') {
854       if (state.tag !== '?') {
855         writeScalar(state, state.dump, level, iskey);
856       }
857     } else {
858       if (state.skipInvalid) return false;
859       throw new YAMLException('unacceptable kind of an object to dump ' + type);
860     }
862     if (state.tag !== null && state.tag !== '?') {
863       state.dump = '!<' + state.tag + '> ' + state.dump;
864     }
865   }
867   return true;
870 function getDuplicateReferences(object, state) {
871   var objects = [],
872       duplicatesIndexes = [],
873       index,
874       length;
876   inspectNode(object, objects, duplicatesIndexes);
878   for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
879     state.duplicates.push(objects[duplicatesIndexes[index]]);
880   }
881   state.usedDuplicates = new Array(length);
884 function inspectNode(object, objects, duplicatesIndexes) {
885   var objectKeyList,
886       index,
887       length;
889   if (object !== null && typeof object === 'object') {
890     index = objects.indexOf(object);
891     if (index !== -1) {
892       if (duplicatesIndexes.indexOf(index) === -1) {
893         duplicatesIndexes.push(index);
894       }
895     } else {
896       objects.push(object);
898       if (Array.isArray(object)) {
899         for (index = 0, length = object.length; index < length; index += 1) {
900           inspectNode(object[index], objects, duplicatesIndexes);
901         }
902       } else {
903         objectKeyList = Object.keys(object);
905         for (index = 0, length = objectKeyList.length; index < length; index += 1) {
906           inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
907         }
908       }
909     }
910   }
913 function dump(input, options) {
914   options = options || {};
916   var state = new State(options);
918   if (!state.noRefs) getDuplicateReferences(input, state);
920   if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
922   return '';
925 function safeDump(input, options) {
926   return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
929 module.exports.dump     = dump;
930 module.exports.safeDump = safeDump;
932 },{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){
933 // YAML error class. http://stackoverflow.com/questions/8458984
935 'use strict';
937 function YAMLException(reason, mark) {
938   // Super constructor
939   Error.call(this);
941   this.name = 'YAMLException';
942   this.reason = reason;
943   this.mark = mark;
944   this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
946   // Include stack trace in error object
947   if (Error.captureStackTrace) {
948     // Chrome and NodeJS
949     Error.captureStackTrace(this, this.constructor);
950   } else {
951     // FF, IE 10+ and Safari 6+. Fallback for others
952     this.stack = (new Error()).stack || '';
953   }
957 // Inherit from Error
958 YAMLException.prototype = Object.create(Error.prototype);
959 YAMLException.prototype.constructor = YAMLException;
962 YAMLException.prototype.toString = function toString(compact) {
963   var result = this.name + ': ';
965   result += this.reason || '(unknown reason)';
967   if (!compact && this.mark) {
968     result += ' ' + this.mark.toString();
969   }
971   return result;
975 module.exports = YAMLException;
977 },{}],5:[function(require,module,exports){
978 'use strict';
980 /*eslint-disable max-len,no-use-before-define*/
982 var common              = require('./common');
983 var YAMLException       = require('./exception');
984 var Mark                = require('./mark');
985 var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
986 var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
989 var _hasOwnProperty = Object.prototype.hasOwnProperty;
992 var CONTEXT_FLOW_IN   = 1;
993 var CONTEXT_FLOW_OUT  = 2;
994 var CONTEXT_BLOCK_IN  = 3;
995 var CONTEXT_BLOCK_OUT = 4;
998 var CHOMPING_CLIP  = 1;
999 var CHOMPING_STRIP = 2;
1000 var CHOMPING_KEEP  = 3;
1003 var PATTERN_NON_PRINTABLE         = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1004 var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1005 var PATTERN_FLOW_INDICATORS       = /[,\[\]\{\}]/;
1006 var PATTERN_TAG_HANDLE            = /^(?:!|!!|![a-z\-]+!)$/i;
1007 var PATTERN_TAG_URI               = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1010 function _class(obj) { return Object.prototype.toString.call(obj); }
1012 function is_EOL(c) {
1013   return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
1016 function is_WHITE_SPACE(c) {
1017   return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
1020 function is_WS_OR_EOL(c) {
1021   return (c === 0x09/* Tab */) ||
1022          (c === 0x20/* Space */) ||
1023          (c === 0x0A/* LF */) ||
1024          (c === 0x0D/* CR */);
1027 function is_FLOW_INDICATOR(c) {
1028   return c === 0x2C/* , */ ||
1029          c === 0x5B/* [ */ ||
1030          c === 0x5D/* ] */ ||
1031          c === 0x7B/* { */ ||
1032          c === 0x7D/* } */;
1035 function fromHexCode(c) {
1036   var lc;
1038   if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1039     return c - 0x30;
1040   }
1042   /*eslint-disable no-bitwise*/
1043   lc = c | 0x20;
1045   if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
1046     return lc - 0x61 + 10;
1047   }
1049   return -1;
1052 function escapedHexLen(c) {
1053   if (c === 0x78/* x */) { return 2; }
1054   if (c === 0x75/* u */) { return 4; }
1055   if (c === 0x55/* U */) { return 8; }
1056   return 0;
1059 function fromDecimalCode(c) {
1060   if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1061     return c - 0x30;
1062   }
1064   return -1;
1067 function simpleEscapeSequence(c) {
1068   /* eslint-disable indent */
1069   return (c === 0x30/* 0 */) ? '\x00' :
1070         (c === 0x61/* a */) ? '\x07' :
1071         (c === 0x62/* b */) ? '\x08' :
1072         (c === 0x74/* t */) ? '\x09' :
1073         (c === 0x09/* Tab */) ? '\x09' :
1074         (c === 0x6E/* n */) ? '\x0A' :
1075         (c === 0x76/* v */) ? '\x0B' :
1076         (c === 0x66/* f */) ? '\x0C' :
1077         (c === 0x72/* r */) ? '\x0D' :
1078         (c === 0x65/* e */) ? '\x1B' :
1079         (c === 0x20/* Space */) ? ' ' :
1080         (c === 0x22/* " */) ? '\x22' :
1081         (c === 0x2F/* / */) ? '/' :
1082         (c === 0x5C/* \ */) ? '\x5C' :
1083         (c === 0x4E/* N */) ? '\x85' :
1084         (c === 0x5F/* _ */) ? '\xA0' :
1085         (c === 0x4C/* L */) ? '\u2028' :
1086         (c === 0x50/* P */) ? '\u2029' : '';
1089 function charFromCodepoint(c) {
1090   if (c <= 0xFFFF) {
1091     return String.fromCharCode(c);
1092   }
1093   // Encode UTF-16 surrogate pair
1094   // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
1095   return String.fromCharCode(
1096     ((c - 0x010000) >> 10) + 0xD800,
1097     ((c - 0x010000) & 0x03FF) + 0xDC00
1098   );
1101 var simpleEscapeCheck = new Array(256); // integer, for fast access
1102 var simpleEscapeMap = new Array(256);
1103 for (var i = 0; i < 256; i++) {
1104   simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1105   simpleEscapeMap[i] = simpleEscapeSequence(i);
1109 function State(input, options) {
1110   this.input = input;
1112   this.filename  = options['filename']  || null;
1113   this.schema    = options['schema']    || DEFAULT_FULL_SCHEMA;
1114   this.onWarning = options['onWarning'] || null;
1115   this.legacy    = options['legacy']    || false;
1116   this.json      = options['json']      || false;
1117   this.listener  = options['listener']  || null;
1119   this.implicitTypes = this.schema.compiledImplicit;
1120   this.typeMap       = this.schema.compiledTypeMap;
1122   this.length     = input.length;
1123   this.position   = 0;
1124   this.line       = 0;
1125   this.lineStart  = 0;
1126   this.lineIndent = 0;
1128   this.documents = [];
1130   /*
1131   this.version;
1132   this.checkLineBreaks;
1133   this.tagMap;
1134   this.anchorMap;
1135   this.tag;
1136   this.anchor;
1137   this.kind;
1138   this.result;*/
1143 function generateError(state, message) {
1144   return new YAMLException(
1145     message,
1146     new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
1149 function throwError(state, message) {
1150   throw generateError(state, message);
1153 function throwWarning(state, message) {
1154   if (state.onWarning) {
1155     state.onWarning.call(null, generateError(state, message));
1156   }
1160 var directiveHandlers = {
1162   YAML: function handleYamlDirective(state, name, args) {
1164     var match, major, minor;
1166     if (state.version !== null) {
1167       throwError(state, 'duplication of %YAML directive');
1168     }
1170     if (args.length !== 1) {
1171       throwError(state, 'YAML directive accepts exactly one argument');
1172     }
1174     match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1176     if (match === null) {
1177       throwError(state, 'ill-formed argument of the YAML directive');
1178     }
1180     major = parseInt(match[1], 10);
1181     minor = parseInt(match[2], 10);
1183     if (major !== 1) {
1184       throwError(state, 'unacceptable YAML version of the document');
1185     }
1187     state.version = args[0];
1188     state.checkLineBreaks = (minor < 2);
1190     if (minor !== 1 && minor !== 2) {
1191       throwWarning(state, 'unsupported YAML version of the document');
1192     }
1193   },
1195   TAG: function handleTagDirective(state, name, args) {
1197     var handle, prefix;
1199     if (args.length !== 2) {
1200       throwError(state, 'TAG directive accepts exactly two arguments');
1201     }
1203     handle = args[0];
1204     prefix = args[1];
1206     if (!PATTERN_TAG_HANDLE.test(handle)) {
1207       throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
1208     }
1210     if (_hasOwnProperty.call(state.tagMap, handle)) {
1211       throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1212     }
1214     if (!PATTERN_TAG_URI.test(prefix)) {
1215       throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
1216     }
1218     state.tagMap[handle] = prefix;
1219   }
1223 function captureSegment(state, start, end, checkJson) {
1224   var _position, _length, _character, _result;
1226   if (start < end) {
1227     _result = state.input.slice(start, end);
1229     if (checkJson) {
1230       for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1231         _character = _result.charCodeAt(_position);
1232         if (!(_character === 0x09 ||
1233               (0x20 <= _character && _character <= 0x10FFFF))) {
1234           throwError(state, 'expected valid JSON character');
1235         }
1236       }
1237     } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1238       throwError(state, 'the stream contains non-printable characters');
1239     }
1241     state.result += _result;
1242   }
1245 function mergeMappings(state, destination, source, overridableKeys) {
1246   var sourceKeys, key, index, quantity;
1248   if (!common.isObject(source)) {
1249     throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
1250   }
1252   sourceKeys = Object.keys(source);
1254   for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1255     key = sourceKeys[index];
1257     if (!_hasOwnProperty.call(destination, key)) {
1258       destination[key] = source[key];
1259       overridableKeys[key] = true;
1260     }
1261   }
1264 function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
1265   var index, quantity;
1267   // The output is a plain object here, so keys can only be strings.
1268   // We need to convert keyNode to a string, but doing so can hang the process
1269   // (deeply nested arrays that explode exponentially using aliases).
1270   if (Array.isArray(keyNode)) {
1271     keyNode = Array.prototype.slice.call(keyNode);
1273     for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1274       if (Array.isArray(keyNode[index])) {
1275         throwError(state, 'nested arrays are not supported inside keys');
1276       }
1278       if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
1279         keyNode[index] = '[object Object]';
1280       }
1281     }
1282   }
1284   // Avoid code execution in load() via toString property
1285   // (still use its own toString for arrays, timestamps,
1286   // and whatever user schema extensions happen to have @@toStringTag)
1287   if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
1288     keyNode = '[object Object]';
1289   }
1292   keyNode = String(keyNode);
1294   if (_result === null) {
1295     _result = {};
1296   }
1298   if (keyTag === 'tag:yaml.org,2002:merge') {
1299     if (Array.isArray(valueNode)) {
1300       for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1301         mergeMappings(state, _result, valueNode[index], overridableKeys);
1302       }
1303     } else {
1304       mergeMappings(state, _result, valueNode, overridableKeys);
1305     }
1306   } else {
1307     if (!state.json &&
1308         !_hasOwnProperty.call(overridableKeys, keyNode) &&
1309         _hasOwnProperty.call(_result, keyNode)) {
1310       state.line = startLine || state.line;
1311       state.position = startPos || state.position;
1312       throwError(state, 'duplicated mapping key');
1313     }
1314     _result[keyNode] = valueNode;
1315     delete overridableKeys[keyNode];
1316   }
1318   return _result;
1321 function readLineBreak(state) {
1322   var ch;
1324   ch = state.input.charCodeAt(state.position);
1326   if (ch === 0x0A/* LF */) {
1327     state.position++;
1328   } else if (ch === 0x0D/* CR */) {
1329     state.position++;
1330     if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
1331       state.position++;
1332     }
1333   } else {
1334     throwError(state, 'a line break is expected');
1335   }
1337   state.line += 1;
1338   state.lineStart = state.position;
1341 function skipSeparationSpace(state, allowComments, checkIndent) {
1342   var lineBreaks = 0,
1343       ch = state.input.charCodeAt(state.position);
1345   while (ch !== 0) {
1346     while (is_WHITE_SPACE(ch)) {
1347       ch = state.input.charCodeAt(++state.position);
1348     }
1350     if (allowComments && ch === 0x23/* # */) {
1351       do {
1352         ch = state.input.charCodeAt(++state.position);
1353       } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
1354     }
1356     if (is_EOL(ch)) {
1357       readLineBreak(state);
1359       ch = state.input.charCodeAt(state.position);
1360       lineBreaks++;
1361       state.lineIndent = 0;
1363       while (ch === 0x20/* Space */) {
1364         state.lineIndent++;
1365         ch = state.input.charCodeAt(++state.position);
1366       }
1367     } else {
1368       break;
1369     }
1370   }
1372   if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1373     throwWarning(state, 'deficient indentation');
1374   }
1376   return lineBreaks;
1379 function testDocumentSeparator(state) {
1380   var _position = state.position,
1381       ch;
1383   ch = state.input.charCodeAt(_position);
1385   // Condition state.position === state.lineStart is tested
1386   // in parent on each call, for efficiency. No needs to test here again.
1387   if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
1388       ch === state.input.charCodeAt(_position + 1) &&
1389       ch === state.input.charCodeAt(_position + 2)) {
1391     _position += 3;
1393     ch = state.input.charCodeAt(_position);
1395     if (ch === 0 || is_WS_OR_EOL(ch)) {
1396       return true;
1397     }
1398   }
1400   return false;
1403 function writeFoldedLines(state, count) {
1404   if (count === 1) {
1405     state.result += ' ';
1406   } else if (count > 1) {
1407     state.result += common.repeat('\n', count - 1);
1408   }
1412 function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1413   var preceding,
1414       following,
1415       captureStart,
1416       captureEnd,
1417       hasPendingContent,
1418       _line,
1419       _lineStart,
1420       _lineIndent,
1421       _kind = state.kind,
1422       _result = state.result,
1423       ch;
1425   ch = state.input.charCodeAt(state.position);
1427   if (is_WS_OR_EOL(ch)      ||
1428       is_FLOW_INDICATOR(ch) ||
1429       ch === 0x23/* # */    ||
1430       ch === 0x26/* & */    ||
1431       ch === 0x2A/* * */    ||
1432       ch === 0x21/* ! */    ||
1433       ch === 0x7C/* | */    ||
1434       ch === 0x3E/* > */    ||
1435       ch === 0x27/* ' */    ||
1436       ch === 0x22/* " */    ||
1437       ch === 0x25/* % */    ||
1438       ch === 0x40/* @ */    ||
1439       ch === 0x60/* ` */) {
1440     return false;
1441   }
1443   if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
1444     following = state.input.charCodeAt(state.position + 1);
1446     if (is_WS_OR_EOL(following) ||
1447         withinFlowCollection && is_FLOW_INDICATOR(following)) {
1448       return false;
1449     }
1450   }
1452   state.kind = 'scalar';
1453   state.result = '';
1454   captureStart = captureEnd = state.position;
1455   hasPendingContent = false;
1457   while (ch !== 0) {
1458     if (ch === 0x3A/* : */) {
1459       following = state.input.charCodeAt(state.position + 1);
1461       if (is_WS_OR_EOL(following) ||
1462           withinFlowCollection && is_FLOW_INDICATOR(following)) {
1463         break;
1464       }
1466     } else if (ch === 0x23/* # */) {
1467       preceding = state.input.charCodeAt(state.position - 1);
1469       if (is_WS_OR_EOL(preceding)) {
1470         break;
1471       }
1473     } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
1474                withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1475       break;
1477     } else if (is_EOL(ch)) {
1478       _line = state.line;
1479       _lineStart = state.lineStart;
1480       _lineIndent = state.lineIndent;
1481       skipSeparationSpace(state, false, -1);
1483       if (state.lineIndent >= nodeIndent) {
1484         hasPendingContent = true;
1485         ch = state.input.charCodeAt(state.position);
1486         continue;
1487       } else {
1488         state.position = captureEnd;
1489         state.line = _line;
1490         state.lineStart = _lineStart;
1491         state.lineIndent = _lineIndent;
1492         break;
1493       }
1494     }
1496     if (hasPendingContent) {
1497       captureSegment(state, captureStart, captureEnd, false);
1498       writeFoldedLines(state, state.line - _line);
1499       captureStart = captureEnd = state.position;
1500       hasPendingContent = false;
1501     }
1503     if (!is_WHITE_SPACE(ch)) {
1504       captureEnd = state.position + 1;
1505     }
1507     ch = state.input.charCodeAt(++state.position);
1508   }
1510   captureSegment(state, captureStart, captureEnd, false);
1512   if (state.result) {
1513     return true;
1514   }
1516   state.kind = _kind;
1517   state.result = _result;
1518   return false;
1521 function readSingleQuotedScalar(state, nodeIndent) {
1522   var ch,
1523       captureStart, captureEnd;
1525   ch = state.input.charCodeAt(state.position);
1527   if (ch !== 0x27/* ' */) {
1528     return false;
1529   }
1531   state.kind = 'scalar';
1532   state.result = '';
1533   state.position++;
1534   captureStart = captureEnd = state.position;
1536   while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1537     if (ch === 0x27/* ' */) {
1538       captureSegment(state, captureStart, state.position, true);
1539       ch = state.input.charCodeAt(++state.position);
1541       if (ch === 0x27/* ' */) {
1542         captureStart = state.position;
1543         state.position++;
1544         captureEnd = state.position;
1545       } else {
1546         return true;
1547       }
1549     } else if (is_EOL(ch)) {
1550       captureSegment(state, captureStart, captureEnd, true);
1551       writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1552       captureStart = captureEnd = state.position;
1554     } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1555       throwError(state, 'unexpected end of the document within a single quoted scalar');
1557     } else {
1558       state.position++;
1559       captureEnd = state.position;
1560     }
1561   }
1563   throwError(state, 'unexpected end of the stream within a single quoted scalar');
1566 function readDoubleQuotedScalar(state, nodeIndent) {
1567   var captureStart,
1568       captureEnd,
1569       hexLength,
1570       hexResult,
1571       tmp,
1572       ch;
1574   ch = state.input.charCodeAt(state.position);
1576   if (ch !== 0x22/* " */) {
1577     return false;
1578   }
1580   state.kind = 'scalar';
1581   state.result = '';
1582   state.position++;
1583   captureStart = captureEnd = state.position;
1585   while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1586     if (ch === 0x22/* " */) {
1587       captureSegment(state, captureStart, state.position, true);
1588       state.position++;
1589       return true;
1591     } else if (ch === 0x5C/* \ */) {
1592       captureSegment(state, captureStart, state.position, true);
1593       ch = state.input.charCodeAt(++state.position);
1595       if (is_EOL(ch)) {
1596         skipSeparationSpace(state, false, nodeIndent);
1598         // TODO: rework to inline fn with no type cast?
1599       } else if (ch < 256 && simpleEscapeCheck[ch]) {
1600         state.result += simpleEscapeMap[ch];
1601         state.position++;
1603       } else if ((tmp = escapedHexLen(ch)) > 0) {
1604         hexLength = tmp;
1605         hexResult = 0;
1607         for (; hexLength > 0; hexLength--) {
1608           ch = state.input.charCodeAt(++state.position);
1610           if ((tmp = fromHexCode(ch)) >= 0) {
1611             hexResult = (hexResult << 4) + tmp;
1613           } else {
1614             throwError(state, 'expected hexadecimal character');
1615           }
1616         }
1618         state.result += charFromCodepoint(hexResult);
1620         state.position++;
1622       } else {
1623         throwError(state, 'unknown escape sequence');
1624       }
1626       captureStart = captureEnd = state.position;
1628     } else if (is_EOL(ch)) {
1629       captureSegment(state, captureStart, captureEnd, true);
1630       writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1631       captureStart = captureEnd = state.position;
1633     } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1634       throwError(state, 'unexpected end of the document within a double quoted scalar');
1636     } else {
1637       state.position++;
1638       captureEnd = state.position;
1639     }
1640   }
1642   throwError(state, 'unexpected end of the stream within a double quoted scalar');
1645 function readFlowCollection(state, nodeIndent) {
1646   var readNext = true,
1647       _line,
1648       _tag     = state.tag,
1649       _result,
1650       _anchor  = state.anchor,
1651       following,
1652       terminator,
1653       isPair,
1654       isExplicitPair,
1655       isMapping,
1656       overridableKeys = {},
1657       keyNode,
1658       keyTag,
1659       valueNode,
1660       ch;
1662   ch = state.input.charCodeAt(state.position);
1664   if (ch === 0x5B/* [ */) {
1665     terminator = 0x5D;/* ] */
1666     isMapping = false;
1667     _result = [];
1668   } else if (ch === 0x7B/* { */) {
1669     terminator = 0x7D;/* } */
1670     isMapping = true;
1671     _result = {};
1672   } else {
1673     return false;
1674   }
1676   if (state.anchor !== null) {
1677     state.anchorMap[state.anchor] = _result;
1678   }
1680   ch = state.input.charCodeAt(++state.position);
1682   while (ch !== 0) {
1683     skipSeparationSpace(state, true, nodeIndent);
1685     ch = state.input.charCodeAt(state.position);
1687     if (ch === terminator) {
1688       state.position++;
1689       state.tag = _tag;
1690       state.anchor = _anchor;
1691       state.kind = isMapping ? 'mapping' : 'sequence';
1692       state.result = _result;
1693       return true;
1694     } else if (!readNext) {
1695       throwError(state, 'missed comma between flow collection entries');
1696     }
1698     keyTag = keyNode = valueNode = null;
1699     isPair = isExplicitPair = false;
1701     if (ch === 0x3F/* ? */) {
1702       following = state.input.charCodeAt(state.position + 1);
1704       if (is_WS_OR_EOL(following)) {
1705         isPair = isExplicitPair = true;
1706         state.position++;
1707         skipSeparationSpace(state, true, nodeIndent);
1708       }
1709     }
1711     _line = state.line;
1712     composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1713     keyTag = state.tag;
1714     keyNode = state.result;
1715     skipSeparationSpace(state, true, nodeIndent);
1717     ch = state.input.charCodeAt(state.position);
1719     if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
1720       isPair = true;
1721       ch = state.input.charCodeAt(++state.position);
1722       skipSeparationSpace(state, true, nodeIndent);
1723       composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1724       valueNode = state.result;
1725     }
1727     if (isMapping) {
1728       storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
1729     } else if (isPair) {
1730       _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
1731     } else {
1732       _result.push(keyNode);
1733     }
1735     skipSeparationSpace(state, true, nodeIndent);
1737     ch = state.input.charCodeAt(state.position);
1739     if (ch === 0x2C/* , */) {
1740       readNext = true;
1741       ch = state.input.charCodeAt(++state.position);
1742     } else {
1743       readNext = false;
1744     }
1745   }
1747   throwError(state, 'unexpected end of the stream within a flow collection');
1750 function readBlockScalar(state, nodeIndent) {
1751   var captureStart,
1752       folding,
1753       chomping       = CHOMPING_CLIP,
1754       didReadContent = false,
1755       detectedIndent = false,
1756       textIndent     = nodeIndent,
1757       emptyLines     = 0,
1758       atMoreIndented = false,
1759       tmp,
1760       ch;
1762   ch = state.input.charCodeAt(state.position);
1764   if (ch === 0x7C/* | */) {
1765     folding = false;
1766   } else if (ch === 0x3E/* > */) {
1767     folding = true;
1768   } else {
1769     return false;
1770   }
1772   state.kind = 'scalar';
1773   state.result = '';
1775   while (ch !== 0) {
1776     ch = state.input.charCodeAt(++state.position);
1778     if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
1779       if (CHOMPING_CLIP === chomping) {
1780         chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
1781       } else {
1782         throwError(state, 'repeat of a chomping mode identifier');
1783       }
1785     } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1786       if (tmp === 0) {
1787         throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
1788       } else if (!detectedIndent) {
1789         textIndent = nodeIndent + tmp - 1;
1790         detectedIndent = true;
1791       } else {
1792         throwError(state, 'repeat of an indentation width identifier');
1793       }
1795     } else {
1796       break;
1797     }
1798   }
1800   if (is_WHITE_SPACE(ch)) {
1801     do { ch = state.input.charCodeAt(++state.position); }
1802     while (is_WHITE_SPACE(ch));
1804     if (ch === 0x23/* # */) {
1805       do { ch = state.input.charCodeAt(++state.position); }
1806       while (!is_EOL(ch) && (ch !== 0));
1807     }
1808   }
1810   while (ch !== 0) {
1811     readLineBreak(state);
1812     state.lineIndent = 0;
1814     ch = state.input.charCodeAt(state.position);
1816     while ((!detectedIndent || state.lineIndent < textIndent) &&
1817            (ch === 0x20/* Space */)) {
1818       state.lineIndent++;
1819       ch = state.input.charCodeAt(++state.position);
1820     }
1822     if (!detectedIndent && state.lineIndent > textIndent) {
1823       textIndent = state.lineIndent;
1824     }
1826     if (is_EOL(ch)) {
1827       emptyLines++;
1828       continue;
1829     }
1831     // End of the scalar.
1832     if (state.lineIndent < textIndent) {
1834       // Perform the chomping.
1835       if (chomping === CHOMPING_KEEP) {
1836         state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1837       } else if (chomping === CHOMPING_CLIP) {
1838         if (didReadContent) { // i.e. only if the scalar is not empty.
1839           state.result += '\n';
1840         }
1841       }
1843       // Break this `while` cycle and go to the funciton's epilogue.
1844       break;
1845     }
1847     // Folded style: use fancy rules to handle line breaks.
1848     if (folding) {
1850       // Lines starting with white space characters (more-indented lines) are not folded.
1851       if (is_WHITE_SPACE(ch)) {
1852         atMoreIndented = true;
1853         // except for the first content line (cf. Example 8.1)
1854         state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1856       // End of more-indented block.
1857       } else if (atMoreIndented) {
1858         atMoreIndented = false;
1859         state.result += common.repeat('\n', emptyLines + 1);
1861       // Just one line break - perceive as the same line.
1862       } else if (emptyLines === 0) {
1863         if (didReadContent) { // i.e. only if we have already read some scalar content.
1864           state.result += ' ';
1865         }
1867       // Several line breaks - perceive as different lines.
1868       } else {
1869         state.result += common.repeat('\n', emptyLines);
1870       }
1872     // Literal style: just add exact number of line breaks between content lines.
1873     } else {
1874       // Keep all line breaks except the header line break.
1875       state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1876     }
1878     didReadContent = true;
1879     detectedIndent = true;
1880     emptyLines = 0;
1881     captureStart = state.position;
1883     while (!is_EOL(ch) && (ch !== 0)) {
1884       ch = state.input.charCodeAt(++state.position);
1885     }
1887     captureSegment(state, captureStart, state.position, false);
1888   }
1890   return true;
1893 function readBlockSequence(state, nodeIndent) {
1894   var _line,
1895       _tag      = state.tag,
1896       _anchor   = state.anchor,
1897       _result   = [],
1898       following,
1899       detected  = false,
1900       ch;
1902   if (state.anchor !== null) {
1903     state.anchorMap[state.anchor] = _result;
1904   }
1906   ch = state.input.charCodeAt(state.position);
1908   while (ch !== 0) {
1910     if (ch !== 0x2D/* - */) {
1911       break;
1912     }
1914     following = state.input.charCodeAt(state.position + 1);
1916     if (!is_WS_OR_EOL(following)) {
1917       break;
1918     }
1920     detected = true;
1921     state.position++;
1923     if (skipSeparationSpace(state, true, -1)) {
1924       if (state.lineIndent <= nodeIndent) {
1925         _result.push(null);
1926         ch = state.input.charCodeAt(state.position);
1927         continue;
1928       }
1929     }
1931     _line = state.line;
1932     composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1933     _result.push(state.result);
1934     skipSeparationSpace(state, true, -1);
1936     ch = state.input.charCodeAt(state.position);
1938     if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
1939       throwError(state, 'bad indentation of a sequence entry');
1940     } else if (state.lineIndent < nodeIndent) {
1941       break;
1942     }
1943   }
1945   if (detected) {
1946     state.tag = _tag;
1947     state.anchor = _anchor;
1948     state.kind = 'sequence';
1949     state.result = _result;
1950     return true;
1951   }
1952   return false;
1955 function readBlockMapping(state, nodeIndent, flowIndent) {
1956   var following,
1957       allowCompact,
1958       _line,
1959       _pos,
1960       _tag          = state.tag,
1961       _anchor       = state.anchor,
1962       _result       = {},
1963       overridableKeys = {},
1964       keyTag        = null,
1965       keyNode       = null,
1966       valueNode     = null,
1967       atExplicitKey = false,
1968       detected      = false,
1969       ch;
1971   if (state.anchor !== null) {
1972     state.anchorMap[state.anchor] = _result;
1973   }
1975   ch = state.input.charCodeAt(state.position);
1977   while (ch !== 0) {
1978     following = state.input.charCodeAt(state.position + 1);
1979     _line = state.line; // Save the current line.
1980     _pos = state.position;
1982     //
1983     // Explicit notation case. There are two separate blocks:
1984     // first for the key (denoted by "?") and second for the value (denoted by ":")
1985     //
1986     if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
1988       if (ch === 0x3F/* ? */) {
1989         if (atExplicitKey) {
1990           storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1991           keyTag = keyNode = valueNode = null;
1992         }
1994         detected = true;
1995         atExplicitKey = true;
1996         allowCompact = true;
1998       } else if (atExplicitKey) {
1999         // i.e. 0x3A/* : */ === character after the explicit key.
2000         atExplicitKey = false;
2001         allowCompact = true;
2003       } else {
2004         throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
2005       }
2007       state.position += 1;
2008       ch = following;
2010     //
2011     // Implicit notation case. Flow-style node as the key first, then ":", and the value.
2012     //
2013     } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
2015       if (state.line === _line) {
2016         ch = state.input.charCodeAt(state.position);
2018         while (is_WHITE_SPACE(ch)) {
2019           ch = state.input.charCodeAt(++state.position);
2020         }
2022         if (ch === 0x3A/* : */) {
2023           ch = state.input.charCodeAt(++state.position);
2025           if (!is_WS_OR_EOL(ch)) {
2026             throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
2027           }
2029           if (atExplicitKey) {
2030             storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2031             keyTag = keyNode = valueNode = null;
2032           }
2034           detected = true;
2035           atExplicitKey = false;
2036           allowCompact = false;
2037           keyTag = state.tag;
2038           keyNode = state.result;
2040         } else if (detected) {
2041           throwError(state, 'can not read an implicit mapping pair; a colon is missed');
2043         } else {
2044           state.tag = _tag;
2045           state.anchor = _anchor;
2046           return true; // Keep the result of `composeNode`.
2047         }
2049       } else if (detected) {
2050         throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
2052       } else {
2053         state.tag = _tag;
2054         state.anchor = _anchor;
2055         return true; // Keep the result of `composeNode`.
2056       }
2058     } else {
2059       break; // Reading is done. Go to the epilogue.
2060     }
2062     //
2063     // Common reading code for both explicit and implicit notations.
2064     //
2065     if (state.line === _line || state.lineIndent > nodeIndent) {
2066       if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
2067         if (atExplicitKey) {
2068           keyNode = state.result;
2069         } else {
2070           valueNode = state.result;
2071         }
2072       }
2074       if (!atExplicitKey) {
2075         storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
2076         keyTag = keyNode = valueNode = null;
2077       }
2079       skipSeparationSpace(state, true, -1);
2080       ch = state.input.charCodeAt(state.position);
2081     }
2083     if (state.lineIndent > nodeIndent && (ch !== 0)) {
2084       throwError(state, 'bad indentation of a mapping entry');
2085     } else if (state.lineIndent < nodeIndent) {
2086       break;
2087     }
2088   }
2090   //
2091   // Epilogue.
2092   //
2094   // Special case: last mapping's node contains only the key in explicit notation.
2095   if (atExplicitKey) {
2096     storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2097   }
2099   // Expose the resulting mapping.
2100   if (detected) {
2101     state.tag = _tag;
2102     state.anchor = _anchor;
2103     state.kind = 'mapping';
2104     state.result = _result;
2105   }
2107   return detected;
2110 function readTagProperty(state) {
2111   var _position,
2112       isVerbatim = false,
2113       isNamed    = false,
2114       tagHandle,
2115       tagName,
2116       ch;
2118   ch = state.input.charCodeAt(state.position);
2120   if (ch !== 0x21/* ! */) return false;
2122   if (state.tag !== null) {
2123     throwError(state, 'duplication of a tag property');
2124   }
2126   ch = state.input.charCodeAt(++state.position);
2128   if (ch === 0x3C/* < */) {
2129     isVerbatim = true;
2130     ch = state.input.charCodeAt(++state.position);
2132   } else if (ch === 0x21/* ! */) {
2133     isNamed = true;
2134     tagHandle = '!!';
2135     ch = state.input.charCodeAt(++state.position);
2137   } else {
2138     tagHandle = '!';
2139   }
2141   _position = state.position;
2143   if (isVerbatim) {
2144     do { ch = state.input.charCodeAt(++state.position); }
2145     while (ch !== 0 && ch !== 0x3E/* > */);
2147     if (state.position < state.length) {
2148       tagName = state.input.slice(_position, state.position);
2149       ch = state.input.charCodeAt(++state.position);
2150     } else {
2151       throwError(state, 'unexpected end of the stream within a verbatim tag');
2152     }
2153   } else {
2154     while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2156       if (ch === 0x21/* ! */) {
2157         if (!isNamed) {
2158           tagHandle = state.input.slice(_position - 1, state.position + 1);
2160           if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2161             throwError(state, 'named tag handle cannot contain such characters');
2162           }
2164           isNamed = true;
2165           _position = state.position + 1;
2166         } else {
2167           throwError(state, 'tag suffix cannot contain exclamation marks');
2168         }
2169       }
2171       ch = state.input.charCodeAt(++state.position);
2172     }
2174     tagName = state.input.slice(_position, state.position);
2176     if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2177       throwError(state, 'tag suffix cannot contain flow indicator characters');
2178     }
2179   }
2181   if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2182     throwError(state, 'tag name cannot contain such characters: ' + tagName);
2183   }
2185   if (isVerbatim) {
2186     state.tag = tagName;
2188   } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
2189     state.tag = state.tagMap[tagHandle] + tagName;
2191   } else if (tagHandle === '!') {
2192     state.tag = '!' + tagName;
2194   } else if (tagHandle === '!!') {
2195     state.tag = 'tag:yaml.org,2002:' + tagName;
2197   } else {
2198     throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2199   }
2201   return true;
2204 function readAnchorProperty(state) {
2205   var _position,
2206       ch;
2208   ch = state.input.charCodeAt(state.position);
2210   if (ch !== 0x26/* & */) return false;
2212   if (state.anchor !== null) {
2213     throwError(state, 'duplication of an anchor property');
2214   }
2216   ch = state.input.charCodeAt(++state.position);
2217   _position = state.position;
2219   while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2220     ch = state.input.charCodeAt(++state.position);
2221   }
2223   if (state.position === _position) {
2224     throwError(state, 'name of an anchor node must contain at least one character');
2225   }
2227   state.anchor = state.input.slice(_position, state.position);
2228   return true;
2231 function readAlias(state) {
2232   var _position, alias,
2233       ch;
2235   ch = state.input.charCodeAt(state.position);
2237   if (ch !== 0x2A/* * */) return false;
2239   ch = state.input.charCodeAt(++state.position);
2240   _position = state.position;
2242   while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2243     ch = state.input.charCodeAt(++state.position);
2244   }
2246   if (state.position === _position) {
2247     throwError(state, 'name of an alias node must contain at least one character');
2248   }
2250   alias = state.input.slice(_position, state.position);
2252   if (!state.anchorMap.hasOwnProperty(alias)) {
2253     throwError(state, 'unidentified alias "' + alias + '"');
2254   }
2256   state.result = state.anchorMap[alias];
2257   skipSeparationSpace(state, true, -1);
2258   return true;
2261 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2262   var allowBlockStyles,
2263       allowBlockScalars,
2264       allowBlockCollections,
2265       indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
2266       atNewLine  = false,
2267       hasContent = false,
2268       typeIndex,
2269       typeQuantity,
2270       type,
2271       flowIndent,
2272       blockIndent;
2274   if (state.listener !== null) {
2275     state.listener('open', state);
2276   }
2278   state.tag    = null;
2279   state.anchor = null;
2280   state.kind   = null;
2281   state.result = null;
2283   allowBlockStyles = allowBlockScalars = allowBlockCollections =
2284     CONTEXT_BLOCK_OUT === nodeContext ||
2285     CONTEXT_BLOCK_IN  === nodeContext;
2287   if (allowToSeek) {
2288     if (skipSeparationSpace(state, true, -1)) {
2289       atNewLine = true;
2291       if (state.lineIndent > parentIndent) {
2292         indentStatus = 1;
2293       } else if (state.lineIndent === parentIndent) {
2294         indentStatus = 0;
2295       } else if (state.lineIndent < parentIndent) {
2296         indentStatus = -1;
2297       }
2298     }
2299   }
2301   if (indentStatus === 1) {
2302     while (readTagProperty(state) || readAnchorProperty(state)) {
2303       if (skipSeparationSpace(state, true, -1)) {
2304         atNewLine = true;
2305         allowBlockCollections = allowBlockStyles;
2307         if (state.lineIndent > parentIndent) {
2308           indentStatus = 1;
2309         } else if (state.lineIndent === parentIndent) {
2310           indentStatus = 0;
2311         } else if (state.lineIndent < parentIndent) {
2312           indentStatus = -1;
2313         }
2314       } else {
2315         allowBlockCollections = false;
2316       }
2317     }
2318   }
2320   if (allowBlockCollections) {
2321     allowBlockCollections = atNewLine || allowCompact;
2322   }
2324   if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2325     if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2326       flowIndent = parentIndent;
2327     } else {
2328       flowIndent = parentIndent + 1;
2329     }
2331     blockIndent = state.position - state.lineStart;
2333     if (indentStatus === 1) {
2334       if (allowBlockCollections &&
2335           (readBlockSequence(state, blockIndent) ||
2336            readBlockMapping(state, blockIndent, flowIndent)) ||
2337           readFlowCollection(state, flowIndent)) {
2338         hasContent = true;
2339       } else {
2340         if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
2341             readSingleQuotedScalar(state, flowIndent) ||
2342             readDoubleQuotedScalar(state, flowIndent)) {
2343           hasContent = true;
2345         } else if (readAlias(state)) {
2346           hasContent = true;
2348           if (state.tag !== null || state.anchor !== null) {
2349             throwError(state, 'alias node should not have any properties');
2350           }
2352         } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2353           hasContent = true;
2355           if (state.tag === null) {
2356             state.tag = '?';
2357           }
2358         }
2360         if (state.anchor !== null) {
2361           state.anchorMap[state.anchor] = state.result;
2362         }
2363       }
2364     } else if (indentStatus === 0) {
2365       // Special case: block sequences are allowed to have same indentation level as the parent.
2366       // http://www.yaml.org/spec/1.2/spec.html#id2799784
2367       hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2368     }
2369   }
2371   if (state.tag !== null && state.tag !== '!') {
2372     if (state.tag === '?') {
2373       for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
2374         type = state.implicitTypes[typeIndex];
2376         // Implicit resolving is not allowed for non-scalar types, and '?'
2377         // non-specific tag is only assigned to plain scalars. So, it isn't
2378         // needed to check for 'kind' conformity.
2380         if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
2381           state.result = type.construct(state.result);
2382           state.tag = type.tag;
2383           if (state.anchor !== null) {
2384             state.anchorMap[state.anchor] = state.result;
2385           }
2386           break;
2387         }
2388       }
2389     } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
2390       type = state.typeMap[state.kind || 'fallback'][state.tag];
2392       if (state.result !== null && type.kind !== state.kind) {
2393         throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2394       }
2396       if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
2397         throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
2398       } else {
2399         state.result = type.construct(state.result);
2400         if (state.anchor !== null) {
2401           state.anchorMap[state.anchor] = state.result;
2402         }
2403       }
2404     } else {
2405       throwError(state, 'unknown tag !<' + state.tag + '>');
2406     }
2407   }
2409   if (state.listener !== null) {
2410     state.listener('close', state);
2411   }
2412   return state.tag !== null ||  state.anchor !== null || hasContent;
2415 function readDocument(state) {
2416   var documentStart = state.position,
2417       _position,
2418       directiveName,
2419       directiveArgs,
2420       hasDirectives = false,
2421       ch;
2423   state.version = null;
2424   state.checkLineBreaks = state.legacy;
2425   state.tagMap = {};
2426   state.anchorMap = {};
2428   while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2429     skipSeparationSpace(state, true, -1);
2431     ch = state.input.charCodeAt(state.position);
2433     if (state.lineIndent > 0 || ch !== 0x25/* % */) {
2434       break;
2435     }
2437     hasDirectives = true;
2438     ch = state.input.charCodeAt(++state.position);
2439     _position = state.position;
2441     while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2442       ch = state.input.charCodeAt(++state.position);
2443     }
2445     directiveName = state.input.slice(_position, state.position);
2446     directiveArgs = [];
2448     if (directiveName.length < 1) {
2449       throwError(state, 'directive name must not be less than one character in length');
2450     }
2452     while (ch !== 0) {
2453       while (is_WHITE_SPACE(ch)) {
2454         ch = state.input.charCodeAt(++state.position);
2455       }
2457       if (ch === 0x23/* # */) {
2458         do { ch = state.input.charCodeAt(++state.position); }
2459         while (ch !== 0 && !is_EOL(ch));
2460         break;
2461       }
2463       if (is_EOL(ch)) break;
2465       _position = state.position;
2467       while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2468         ch = state.input.charCodeAt(++state.position);
2469       }
2471       directiveArgs.push(state.input.slice(_position, state.position));
2472     }
2474     if (ch !== 0) readLineBreak(state);
2476     if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2477       directiveHandlers[directiveName](state, directiveName, directiveArgs);
2478     } else {
2479       throwWarning(state, 'unknown document directive "' + directiveName + '"');
2480     }
2481   }
2483   skipSeparationSpace(state, true, -1);
2485   if (state.lineIndent === 0 &&
2486       state.input.charCodeAt(state.position)     === 0x2D/* - */ &&
2487       state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
2488       state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
2489     state.position += 3;
2490     skipSeparationSpace(state, true, -1);
2492   } else if (hasDirectives) {
2493     throwError(state, 'directives end mark is expected');
2494   }
2496   composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2497   skipSeparationSpace(state, true, -1);
2499   if (state.checkLineBreaks &&
2500       PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2501     throwWarning(state, 'non-ASCII line breaks are interpreted as content');
2502   }
2504   state.documents.push(state.result);
2506   if (state.position === state.lineStart && testDocumentSeparator(state)) {
2508     if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
2509       state.position += 3;
2510       skipSeparationSpace(state, true, -1);
2511     }
2512     return;
2513   }
2515   if (state.position < (state.length - 1)) {
2516     throwError(state, 'end of the stream or a document separator is expected');
2517   } else {
2518     return;
2519   }
2523 function loadDocuments(input, options) {
2524   input = String(input);
2525   options = options || {};
2527   if (input.length !== 0) {
2529     // Add tailing `\n` if not exists
2530     if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
2531         input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
2532       input += '\n';
2533     }
2535     // Strip BOM
2536     if (input.charCodeAt(0) === 0xFEFF) {
2537       input = input.slice(1);
2538     }
2539   }
2541   var state = new State(input, options);
2543   // Use 0 as string terminator. That significantly simplifies bounds check.
2544   state.input += '\0';
2546   while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
2547     state.lineIndent += 1;
2548     state.position += 1;
2549   }
2551   while (state.position < (state.length - 1)) {
2552     readDocument(state);
2553   }
2555   return state.documents;
2559 function loadAll(input, iterator, options) {
2560   var documents = loadDocuments(input, options), index, length;
2562   if (typeof iterator !== 'function') {
2563     return documents;
2564   }
2566   for (index = 0, length = documents.length; index < length; index += 1) {
2567     iterator(documents[index]);
2568   }
2572 function load(input, options) {
2573   var documents = loadDocuments(input, options);
2575   if (documents.length === 0) {
2576     /*eslint-disable no-undefined*/
2577     return undefined;
2578   } else if (documents.length === 1) {
2579     return documents[0];
2580   }
2581   throw new YAMLException('expected a single document in the stream, but found more');
2585 function safeLoadAll(input, output, options) {
2586   if (typeof output === 'function') {
2587     loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2588   } else {
2589     return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2590   }
2594 function safeLoad(input, options) {
2595   return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2599 module.exports.loadAll     = loadAll;
2600 module.exports.load        = load;
2601 module.exports.safeLoadAll = safeLoadAll;
2602 module.exports.safeLoad    = safeLoad;
2604 },{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){
2605 'use strict';
2608 var common = require('./common');
2611 function Mark(name, buffer, position, line, column) {
2612   this.name     = name;
2613   this.buffer   = buffer;
2614   this.position = position;
2615   this.line     = line;
2616   this.column   = column;
2620 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2621   var head, start, tail, end, snippet;
2623   if (!this.buffer) return null;
2625   indent = indent || 4;
2626   maxLength = maxLength || 75;
2628   head = '';
2629   start = this.position;
2631   while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
2632     start -= 1;
2633     if (this.position - start > (maxLength / 2 - 1)) {
2634       head = ' ... ';
2635       start += 5;
2636       break;
2637     }
2638   }
2640   tail = '';
2641   end = this.position;
2643   while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
2644     end += 1;
2645     if (end - this.position > (maxLength / 2 - 1)) {
2646       tail = ' ... ';
2647       end -= 5;
2648       break;
2649     }
2650   }
2652   snippet = this.buffer.slice(start, end);
2654   return common.repeat(' ', indent) + head + snippet + tail + '\n' +
2655          common.repeat(' ', indent + this.position - start + head.length) + '^';
2659 Mark.prototype.toString = function toString(compact) {
2660   var snippet, where = '';
2662   if (this.name) {
2663     where += 'in "' + this.name + '" ';
2664   }
2666   where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
2668   if (!compact) {
2669     snippet = this.getSnippet();
2671     if (snippet) {
2672       where += ':\n' + snippet;
2673     }
2674   }
2676   return where;
2680 module.exports = Mark;
2682 },{"./common":2}],7:[function(require,module,exports){
2683 'use strict';
2685 /*eslint-disable max-len*/
2687 var common        = require('./common');
2688 var YAMLException = require('./exception');
2689 var Type          = require('./type');
2692 function compileList(schema, name, result) {
2693   var exclude = [];
2695   schema.include.forEach(function (includedSchema) {
2696     result = compileList(includedSchema, name, result);
2697   });
2699   schema[name].forEach(function (currentType) {
2700     result.forEach(function (previousType, previousIndex) {
2701       if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
2702         exclude.push(previousIndex);
2703       }
2704     });
2706     result.push(currentType);
2707   });
2709   return result.filter(function (type, index) {
2710     return exclude.indexOf(index) === -1;
2711   });
2715 function compileMap(/* lists... */) {
2716   var result = {
2717         scalar: {},
2718         sequence: {},
2719         mapping: {},
2720         fallback: {}
2721       }, index, length;
2723   function collectType(type) {
2724     result[type.kind][type.tag] = result['fallback'][type.tag] = type;
2725   }
2727   for (index = 0, length = arguments.length; index < length; index += 1) {
2728     arguments[index].forEach(collectType);
2729   }
2730   return result;
2734 function Schema(definition) {
2735   this.include  = definition.include  || [];
2736   this.implicit = definition.implicit || [];
2737   this.explicit = definition.explicit || [];
2739   this.implicit.forEach(function (type) {
2740     if (type.loadKind && type.loadKind !== 'scalar') {
2741       throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
2742     }
2743   });
2745   this.compiledImplicit = compileList(this, 'implicit', []);
2746   this.compiledExplicit = compileList(this, 'explicit', []);
2747   this.compiledTypeMap  = compileMap(this.compiledImplicit, this.compiledExplicit);
2751 Schema.DEFAULT = null;
2754 Schema.create = function createSchema() {
2755   var schemas, types;
2757   switch (arguments.length) {
2758     case 1:
2759       schemas = Schema.DEFAULT;
2760       types = arguments[0];
2761       break;
2763     case 2:
2764       schemas = arguments[0];
2765       types = arguments[1];
2766       break;
2768     default:
2769       throw new YAMLException('Wrong number of arguments for Schema.create function');
2770   }
2772   schemas = common.toArray(schemas);
2773   types = common.toArray(types);
2775   if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
2776     throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
2777   }
2779   if (!types.every(function (type) { return type instanceof Type; })) {
2780     throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
2781   }
2783   return new Schema({
2784     include: schemas,
2785     explicit: types
2786   });
2790 module.exports = Schema;
2792 },{"./common":2,"./exception":4,"./type":13}],8:[function(require,module,exports){
2793 // Standard YAML's Core schema.
2794 // http://www.yaml.org/spec/1.2/spec.html#id2804923
2796 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2797 // So, Core schema has no distinctions from JSON schema is JS-YAML.
2800 'use strict';
2803 var Schema = require('../schema');
2806 module.exports = new Schema({
2807   include: [
2808     require('./json')
2809   ]
2812 },{"../schema":7,"./json":12}],9:[function(require,module,exports){
2813 // JS-YAML's default schema for `load` function.
2814 // It is not described in the YAML specification.
2816 // This schema is based on JS-YAML's default safe schema and includes
2817 // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
2819 // Also this schema is used as default base schema at `Schema.create` function.
2822 'use strict';
2825 var Schema = require('../schema');
2828 module.exports = Schema.DEFAULT = new Schema({
2829   include: [
2830     require('./default_safe')
2831   ],
2832   explicit: [
2833     require('../type/js/undefined'),
2834     require('../type/js/regexp'),
2835     require('../type/js/function')
2836   ]
2839 },{"../schema":7,"../type/js/function":18,"../type/js/regexp":19,"../type/js/undefined":20,"./default_safe":10}],10:[function(require,module,exports){
2840 // JS-YAML's default schema for `safeLoad` function.
2841 // It is not described in the YAML specification.
2843 // This schema is based on standard YAML's Core schema and includes most of
2844 // extra types described at YAML tag repository. (http://yaml.org/type/)
2847 'use strict';
2850 var Schema = require('../schema');
2853 module.exports = new Schema({
2854   include: [
2855     require('./core')
2856   ],
2857   implicit: [
2858     require('../type/timestamp'),
2859     require('../type/merge')
2860   ],
2861   explicit: [
2862     require('../type/binary'),
2863     require('../type/omap'),
2864     require('../type/pairs'),
2865     require('../type/set')
2866   ]
2869 },{"../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){
2870 // Standard YAML's Failsafe schema.
2871 // http://www.yaml.org/spec/1.2/spec.html#id2802346
2874 'use strict';
2877 var Schema = require('../schema');
2880 module.exports = new Schema({
2881   explicit: [
2882     require('../type/str'),
2883     require('../type/seq'),
2884     require('../type/map')
2885   ]
2888 },{"../schema":7,"../type/map":21,"../type/seq":26,"../type/str":28}],12:[function(require,module,exports){
2889 // Standard YAML's JSON schema.
2890 // http://www.yaml.org/spec/1.2/spec.html#id2803231
2892 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2893 // So, this schema is not such strict as defined in the YAML specification.
2894 // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
2897 'use strict';
2900 var Schema = require('../schema');
2903 module.exports = new Schema({
2904   include: [
2905     require('./failsafe')
2906   ],
2907   implicit: [
2908     require('../type/null'),
2909     require('../type/bool'),
2910     require('../type/int'),
2911     require('../type/float')
2912   ]
2915 },{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){
2916 'use strict';
2918 var YAMLException = require('./exception');
2920 var TYPE_CONSTRUCTOR_OPTIONS = [
2921   'kind',
2922   'resolve',
2923   'construct',
2924   'instanceOf',
2925   'predicate',
2926   'represent',
2927   'defaultStyle',
2928   'styleAliases'
2931 var YAML_NODE_KINDS = [
2932   'scalar',
2933   'sequence',
2934   'mapping'
2937 function compileStyleAliases(map) {
2938   var result = {};
2940   if (map !== null) {
2941     Object.keys(map).forEach(function (style) {
2942       map[style].forEach(function (alias) {
2943         result[String(alias)] = style;
2944       });
2945     });
2946   }
2948   return result;
2951 function Type(tag, options) {
2952   options = options || {};
2954   Object.keys(options).forEach(function (name) {
2955     if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
2956       throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
2957     }
2958   });
2960   // TODO: Add tag format check.
2961   this.tag          = tag;
2962   this.kind         = options['kind']         || null;
2963   this.resolve      = options['resolve']      || function () { return true; };
2964   this.construct    = options['construct']    || function (data) { return data; };
2965   this.instanceOf   = options['instanceOf']   || null;
2966   this.predicate    = options['predicate']    || null;
2967   this.represent    = options['represent']    || null;
2968   this.defaultStyle = options['defaultStyle'] || null;
2969   this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
2971   if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
2972     throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
2973   }
2976 module.exports = Type;
2978 },{"./exception":4}],14:[function(require,module,exports){
2979 'use strict';
2981 /*eslint-disable no-bitwise*/
2983 var NodeBuffer;
2985 try {
2986   // A trick for browserified version, to not include `Buffer` shim
2987   var _require = require;
2988   NodeBuffer = _require('buffer').Buffer;
2989 } catch (__) {}
2991 var Type       = require('../type');
2994 // [ 64, 65, 66 ] -> [ padding, CR, LF ]
2995 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
2998 function resolveYamlBinary(data) {
2999   if (data === null) return false;
3001   var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
3003   // Convert one by one.
3004   for (idx = 0; idx < max; idx++) {
3005     code = map.indexOf(data.charAt(idx));
3007     // Skip CR/LF
3008     if (code > 64) continue;
3010     // Fail on illegal characters
3011     if (code < 0) return false;
3013     bitlen += 6;
3014   }
3016   // If there are any bits left, source was corrupted
3017   return (bitlen % 8) === 0;
3020 function constructYamlBinary(data) {
3021   var idx, tailbits,
3022       input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
3023       max = input.length,
3024       map = BASE64_MAP,
3025       bits = 0,
3026       result = [];
3028   // Collect by 6*4 bits (3 bytes)
3030   for (idx = 0; idx < max; idx++) {
3031     if ((idx % 4 === 0) && idx) {
3032       result.push((bits >> 16) & 0xFF);
3033       result.push((bits >> 8) & 0xFF);
3034       result.push(bits & 0xFF);
3035     }
3037     bits = (bits << 6) | map.indexOf(input.charAt(idx));
3038   }
3040   // Dump tail
3042   tailbits = (max % 4) * 6;
3044   if (tailbits === 0) {
3045     result.push((bits >> 16) & 0xFF);
3046     result.push((bits >> 8) & 0xFF);
3047     result.push(bits & 0xFF);
3048   } else if (tailbits === 18) {
3049     result.push((bits >> 10) & 0xFF);
3050     result.push((bits >> 2) & 0xFF);
3051   } else if (tailbits === 12) {
3052     result.push((bits >> 4) & 0xFF);
3053   }
3055   // Wrap into Buffer for NodeJS and leave Array for browser
3056   if (NodeBuffer) {
3057     // Support node 6.+ Buffer API when available
3058     return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
3059   }
3061   return result;
3064 function representYamlBinary(object /*, style*/) {
3065   var result = '', bits = 0, idx, tail,
3066       max = object.length,
3067       map = BASE64_MAP;
3069   // Convert every three bytes to 4 ASCII characters.
3071   for (idx = 0; idx < max; idx++) {
3072     if ((idx % 3 === 0) && idx) {
3073       result += map[(bits >> 18) & 0x3F];
3074       result += map[(bits >> 12) & 0x3F];
3075       result += map[(bits >> 6) & 0x3F];
3076       result += map[bits & 0x3F];
3077     }
3079     bits = (bits << 8) + object[idx];
3080   }
3082   // Dump tail
3084   tail = max % 3;
3086   if (tail === 0) {
3087     result += map[(bits >> 18) & 0x3F];
3088     result += map[(bits >> 12) & 0x3F];
3089     result += map[(bits >> 6) & 0x3F];
3090     result += map[bits & 0x3F];
3091   } else if (tail === 2) {
3092     result += map[(bits >> 10) & 0x3F];
3093     result += map[(bits >> 4) & 0x3F];
3094     result += map[(bits << 2) & 0x3F];
3095     result += map[64];
3096   } else if (tail === 1) {
3097     result += map[(bits >> 2) & 0x3F];
3098     result += map[(bits << 4) & 0x3F];
3099     result += map[64];
3100     result += map[64];
3101   }
3103   return result;
3106 function isBinary(object) {
3107   return NodeBuffer && NodeBuffer.isBuffer(object);
3110 module.exports = new Type('tag:yaml.org,2002:binary', {
3111   kind: 'scalar',
3112   resolve: resolveYamlBinary,
3113   construct: constructYamlBinary,
3114   predicate: isBinary,
3115   represent: representYamlBinary
3118 },{"../type":13}],15:[function(require,module,exports){
3119 'use strict';
3121 var Type = require('../type');
3123 function resolveYamlBoolean(data) {
3124   if (data === null) return false;
3126   var max = data.length;
3128   return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
3129          (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
3132 function constructYamlBoolean(data) {
3133   return data === 'true' ||
3134          data === 'True' ||
3135          data === 'TRUE';
3138 function isBoolean(object) {
3139   return Object.prototype.toString.call(object) === '[object Boolean]';
3142 module.exports = new Type('tag:yaml.org,2002:bool', {
3143   kind: 'scalar',
3144   resolve: resolveYamlBoolean,
3145   construct: constructYamlBoolean,
3146   predicate: isBoolean,
3147   represent: {
3148     lowercase: function (object) { return object ? 'true' : 'false'; },
3149     uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
3150     camelcase: function (object) { return object ? 'True' : 'False'; }
3151   },
3152   defaultStyle: 'lowercase'
3155 },{"../type":13}],16:[function(require,module,exports){
3156 'use strict';
3158 var common = require('../common');
3159 var Type   = require('../type');
3161 var YAML_FLOAT_PATTERN = new RegExp(
3162   // 2.5e4, 2.5 and integers
3163   '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
3164   // .2e4, .2
3165   // special case, seems not from spec
3166   '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
3167   // 20:59
3168   '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
3169   // .inf
3170   '|[-+]?\\.(?:inf|Inf|INF)' +
3171   // .nan
3172   '|\\.(?:nan|NaN|NAN))$');
3174 function resolveYamlFloat(data) {
3175   if (data === null) return false;
3177   if (!YAML_FLOAT_PATTERN.test(data) ||
3178       // Quick hack to not allow integers end with `_`
3179       // Probably should update regexp & check speed
3180       data[data.length - 1] === '_') {
3181     return false;
3182   }
3184   return true;
3187 function constructYamlFloat(data) {
3188   var value, sign, base, digits;
3190   value  = data.replace(/_/g, '').toLowerCase();
3191   sign   = value[0] === '-' ? -1 : 1;
3192   digits = [];
3194   if ('+-'.indexOf(value[0]) >= 0) {
3195     value = value.slice(1);
3196   }
3198   if (value === '.inf') {
3199     return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
3201   } else if (value === '.nan') {
3202     return NaN;
3204   } else if (value.indexOf(':') >= 0) {
3205     value.split(':').forEach(function (v) {
3206       digits.unshift(parseFloat(v, 10));
3207     });
3209     value = 0.0;
3210     base = 1;
3212     digits.forEach(function (d) {
3213       value += d * base;
3214       base *= 60;
3215     });
3217     return sign * value;
3219   }
3220   return sign * parseFloat(value, 10);
3224 var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
3226 function representYamlFloat(object, style) {
3227   var res;
3229   if (isNaN(object)) {
3230     switch (style) {
3231       case 'lowercase': return '.nan';
3232       case 'uppercase': return '.NAN';
3233       case 'camelcase': return '.NaN';
3234     }
3235   } else if (Number.POSITIVE_INFINITY === object) {
3236     switch (style) {
3237       case 'lowercase': return '.inf';
3238       case 'uppercase': return '.INF';
3239       case 'camelcase': return '.Inf';
3240     }
3241   } else if (Number.NEGATIVE_INFINITY === object) {
3242     switch (style) {
3243       case 'lowercase': return '-.inf';
3244       case 'uppercase': return '-.INF';
3245       case 'camelcase': return '-.Inf';
3246     }
3247   } else if (common.isNegativeZero(object)) {
3248     return '-0.0';
3249   }
3251   res = object.toString(10);
3253   // JS stringifier can build scientific format without dots: 5e-100,
3254   // while YAML requres dot: 5.e-100. Fix it with simple hack
3256   return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
3259 function isFloat(object) {
3260   return (Object.prototype.toString.call(object) === '[object Number]') &&
3261          (object % 1 !== 0 || common.isNegativeZero(object));
3264 module.exports = new Type('tag:yaml.org,2002:float', {
3265   kind: 'scalar',
3266   resolve: resolveYamlFloat,
3267   construct: constructYamlFloat,
3268   predicate: isFloat,
3269   represent: representYamlFloat,
3270   defaultStyle: 'lowercase'
3273 },{"../common":2,"../type":13}],17:[function(require,module,exports){
3274 'use strict';
3276 var common = require('../common');
3277 var Type   = require('../type');
3279 function isHexCode(c) {
3280   return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
3281          ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
3282          ((0x61/* a */ <= c) && (c <= 0x66/* f */));
3285 function isOctCode(c) {
3286   return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
3289 function isDecCode(c) {
3290   return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
3293 function resolveYamlInteger(data) {
3294   if (data === null) return false;
3296   var max = data.length,
3297       index = 0,
3298       hasDigits = false,
3299       ch;
3301   if (!max) return false;
3303   ch = data[index];
3305   // sign
3306   if (ch === '-' || ch === '+') {
3307     ch = data[++index];
3308   }
3310   if (ch === '0') {
3311     // 0
3312     if (index + 1 === max) return true;
3313     ch = data[++index];
3315     // base 2, base 8, base 16
3317     if (ch === 'b') {
3318       // base 2
3319       index++;
3321       for (; index < max; index++) {
3322         ch = data[index];
3323         if (ch === '_') continue;
3324         if (ch !== '0' && ch !== '1') return false;
3325         hasDigits = true;
3326       }
3327       return hasDigits && ch !== '_';
3328     }
3331     if (ch === 'x') {
3332       // base 16
3333       index++;
3335       for (; index < max; index++) {
3336         ch = data[index];
3337         if (ch === '_') continue;
3338         if (!isHexCode(data.charCodeAt(index))) return false;
3339         hasDigits = true;
3340       }
3341       return hasDigits && ch !== '_';
3342     }
3344     // base 8
3345     for (; index < max; index++) {
3346       ch = data[index];
3347       if (ch === '_') continue;
3348       if (!isOctCode(data.charCodeAt(index))) return false;
3349       hasDigits = true;
3350     }
3351     return hasDigits && ch !== '_';
3352   }
3354   // base 10 (except 0) or base 60
3356   // value should not start with `_`;
3357   if (ch === '_') return false;
3359   for (; index < max; index++) {
3360     ch = data[index];
3361     if (ch === '_') continue;
3362     if (ch === ':') break;
3363     if (!isDecCode(data.charCodeAt(index))) {
3364       return false;
3365     }
3366     hasDigits = true;
3367   }
3369   // Should have digits and should not end with `_`
3370   if (!hasDigits || ch === '_') return false;
3372   // if !base60 - done;
3373   if (ch !== ':') return true;
3375   // base60 almost not used, no needs to optimize
3376   return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
3379 function constructYamlInteger(data) {
3380   var value = data, sign = 1, ch, base, digits = [];
3382   if (value.indexOf('_') !== -1) {
3383     value = value.replace(/_/g, '');
3384   }
3386   ch = value[0];
3388   if (ch === '-' || ch === '+') {
3389     if (ch === '-') sign = -1;
3390     value = value.slice(1);
3391     ch = value[0];
3392   }
3394   if (value === '0') return 0;
3396   if (ch === '0') {
3397     if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
3398     if (value[1] === 'x') return sign * parseInt(value, 16);
3399     return sign * parseInt(value, 8);
3400   }
3402   if (value.indexOf(':') !== -1) {
3403     value.split(':').forEach(function (v) {
3404       digits.unshift(parseInt(v, 10));
3405     });
3407     value = 0;
3408     base = 1;
3410     digits.forEach(function (d) {
3411       value += (d * base);
3412       base *= 60;
3413     });
3415     return sign * value;
3417   }
3419   return sign * parseInt(value, 10);
3422 function isInteger(object) {
3423   return (Object.prototype.toString.call(object)) === '[object Number]' &&
3424          (object % 1 === 0 && !common.isNegativeZero(object));
3427 module.exports = new Type('tag:yaml.org,2002:int', {
3428   kind: 'scalar',
3429   resolve: resolveYamlInteger,
3430   construct: constructYamlInteger,
3431   predicate: isInteger,
3432   represent: {
3433     binary:      function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
3434     octal:       function (obj) { return obj >= 0 ? '0'  + obj.toString(8) : '-0'  + obj.toString(8).slice(1); },
3435     decimal:     function (obj) { return obj.toString(10); },
3436     /* eslint-disable max-len */
3437     hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() :  '-0x' + obj.toString(16).toUpperCase().slice(1); }
3438   },
3439   defaultStyle: 'decimal',
3440   styleAliases: {
3441     binary:      [ 2,  'bin' ],
3442     octal:       [ 8,  'oct' ],
3443     decimal:     [ 10, 'dec' ],
3444     hexadecimal: [ 16, 'hex' ]
3445   }
3448 },{"../common":2,"../type":13}],18:[function(require,module,exports){
3449 'use strict';
3451 var esprima;
3453 // Browserified version does not have esprima
3455 // 1. For node.js just require module as deps
3456 // 2. For browser try to require mudule via external AMD system.
3457 //    If not found - try to fallback to window.esprima. If not
3458 //    found too - then fail to parse.
3460 try {
3461   // workaround to exclude package from browserify list.
3462   var _require = require;
3463   esprima = _require('esprima');
3464 } catch (_) {
3465   /*global window */
3466   if (typeof window !== 'undefined') esprima = window.esprima;
3469 var Type = require('../../type');
3471 function resolveJavascriptFunction(data) {
3472   if (data === null) return false;
3474   try {
3475     var source = '(' + data + ')',
3476         ast    = esprima.parse(source, { range: true });
3478     if (ast.type                    !== 'Program'             ||
3479         ast.body.length             !== 1                     ||
3480         ast.body[0].type            !== 'ExpressionStatement' ||
3481         (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
3482           ast.body[0].expression.type !== 'FunctionExpression')) {
3483       return false;
3484     }
3486     return true;
3487   } catch (err) {
3488     return false;
3489   }
3492 function constructJavascriptFunction(data) {
3493   /*jslint evil:true*/
3495   var source = '(' + data + ')',
3496       ast    = esprima.parse(source, { range: true }),
3497       params = [],
3498       body;
3500   if (ast.type                    !== 'Program'             ||
3501       ast.body.length             !== 1                     ||
3502       ast.body[0].type            !== 'ExpressionStatement' ||
3503       (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
3504         ast.body[0].expression.type !== 'FunctionExpression')) {
3505     throw new Error('Failed to resolve function');
3506   }
3508   ast.body[0].expression.params.forEach(function (param) {
3509     params.push(param.name);
3510   });
3512   body = ast.body[0].expression.body.range;
3514   // Esprima's ranges include the first '{' and the last '}' characters on
3515   // function expressions. So cut them out.
3516   if (ast.body[0].expression.body.type === 'BlockStatement') {
3517     /*eslint-disable no-new-func*/
3518     return new Function(params, source.slice(body[0] + 1, body[1] - 1));
3519   }
3520   // ES6 arrow functions can omit the BlockStatement. In that case, just return
3521   // the body.
3522   /*eslint-disable no-new-func*/
3523   return new Function(params, 'return ' + source.slice(body[0], body[1]));
3526 function representJavascriptFunction(object /*, style*/) {
3527   return object.toString();
3530 function isFunction(object) {
3531   return Object.prototype.toString.call(object) === '[object Function]';
3534 module.exports = new Type('tag:yaml.org,2002:js/function', {
3535   kind: 'scalar',
3536   resolve: resolveJavascriptFunction,
3537   construct: constructJavascriptFunction,
3538   predicate: isFunction,
3539   represent: representJavascriptFunction
3542 },{"../../type":13}],19:[function(require,module,exports){
3543 'use strict';
3545 var Type = require('../../type');
3547 function resolveJavascriptRegExp(data) {
3548   if (data === null) return false;
3549   if (data.length === 0) return false;
3551   var regexp = data,
3552       tail   = /\/([gim]*)$/.exec(data),
3553       modifiers = '';
3555   // if regexp starts with '/' it can have modifiers and must be properly closed
3556   // `/foo/gim` - modifiers tail can be maximum 3 chars
3557   if (regexp[0] === '/') {
3558     if (tail) modifiers = tail[1];
3560     if (modifiers.length > 3) return false;
3561     // if expression starts with /, is should be properly terminated
3562     if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
3563   }
3565   return true;
3568 function constructJavascriptRegExp(data) {
3569   var regexp = data,
3570       tail   = /\/([gim]*)$/.exec(data),
3571       modifiers = '';
3573   // `/foo/gim` - tail can be maximum 4 chars
3574   if (regexp[0] === '/') {
3575     if (tail) modifiers = tail[1];
3576     regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3577   }
3579   return new RegExp(regexp, modifiers);
3582 function representJavascriptRegExp(object /*, style*/) {
3583   var result = '/' + object.source + '/';
3585   if (object.global) result += 'g';
3586   if (object.multiline) result += 'm';
3587   if (object.ignoreCase) result += 'i';
3589   return result;
3592 function isRegExp(object) {
3593   return Object.prototype.toString.call(object) === '[object RegExp]';
3596 module.exports = new Type('tag:yaml.org,2002:js/regexp', {
3597   kind: 'scalar',
3598   resolve: resolveJavascriptRegExp,
3599   construct: constructJavascriptRegExp,
3600   predicate: isRegExp,
3601   represent: representJavascriptRegExp
3604 },{"../../type":13}],20:[function(require,module,exports){
3605 'use strict';
3607 var Type = require('../../type');
3609 function resolveJavascriptUndefined() {
3610   return true;
3613 function constructJavascriptUndefined() {
3614   /*eslint-disable no-undefined*/
3615   return undefined;
3618 function representJavascriptUndefined() {
3619   return '';
3622 function isUndefined(object) {
3623   return typeof object === 'undefined';
3626 module.exports = new Type('tag:yaml.org,2002:js/undefined', {
3627   kind: 'scalar',
3628   resolve: resolveJavascriptUndefined,
3629   construct: constructJavascriptUndefined,
3630   predicate: isUndefined,
3631   represent: representJavascriptUndefined
3634 },{"../../type":13}],21:[function(require,module,exports){
3635 'use strict';
3637 var Type = require('../type');
3639 module.exports = new Type('tag:yaml.org,2002:map', {
3640   kind: 'mapping',
3641   construct: function (data) { return data !== null ? data : {}; }
3644 },{"../type":13}],22:[function(require,module,exports){
3645 'use strict';
3647 var Type = require('../type');
3649 function resolveYamlMerge(data) {
3650   return data === '<<' || data === null;
3653 module.exports = new Type('tag:yaml.org,2002:merge', {
3654   kind: 'scalar',
3655   resolve: resolveYamlMerge
3658 },{"../type":13}],23:[function(require,module,exports){
3659 'use strict';
3661 var Type = require('../type');
3663 function resolveYamlNull(data) {
3664   if (data === null) return true;
3666   var max = data.length;
3668   return (max === 1 && data === '~') ||
3669          (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
3672 function constructYamlNull() {
3673   return null;
3676 function isNull(object) {
3677   return object === null;
3680 module.exports = new Type('tag:yaml.org,2002:null', {
3681   kind: 'scalar',
3682   resolve: resolveYamlNull,
3683   construct: constructYamlNull,
3684   predicate: isNull,
3685   represent: {
3686     canonical: function () { return '~';    },
3687     lowercase: function () { return 'null'; },
3688     uppercase: function () { return 'NULL'; },
3689     camelcase: function () { return 'Null'; }
3690   },
3691   defaultStyle: 'lowercase'
3694 },{"../type":13}],24:[function(require,module,exports){
3695 'use strict';
3697 var Type = require('../type');
3699 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3700 var _toString       = Object.prototype.toString;
3702 function resolveYamlOmap(data) {
3703   if (data === null) return true;
3705   var objectKeys = [], index, length, pair, pairKey, pairHasKey,
3706       object = data;
3708   for (index = 0, length = object.length; index < length; index += 1) {
3709     pair = object[index];
3710     pairHasKey = false;
3712     if (_toString.call(pair) !== '[object Object]') return false;
3714     for (pairKey in pair) {
3715       if (_hasOwnProperty.call(pair, pairKey)) {
3716         if (!pairHasKey) pairHasKey = true;
3717         else return false;
3718       }
3719     }
3721     if (!pairHasKey) return false;
3723     if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
3724     else return false;
3725   }
3727   return true;
3730 function constructYamlOmap(data) {
3731   return data !== null ? data : [];
3734 module.exports = new Type('tag:yaml.org,2002:omap', {
3735   kind: 'sequence',
3736   resolve: resolveYamlOmap,
3737   construct: constructYamlOmap
3740 },{"../type":13}],25:[function(require,module,exports){
3741 'use strict';
3743 var Type = require('../type');
3745 var _toString = Object.prototype.toString;
3747 function resolveYamlPairs(data) {
3748   if (data === null) return true;
3750   var index, length, pair, keys, result,
3751       object = data;
3753   result = new Array(object.length);
3755   for (index = 0, length = object.length; index < length; index += 1) {
3756     pair = object[index];
3758     if (_toString.call(pair) !== '[object Object]') return false;
3760     keys = Object.keys(pair);
3762     if (keys.length !== 1) return false;
3764     result[index] = [ keys[0], pair[keys[0]] ];
3765   }
3767   return true;
3770 function constructYamlPairs(data) {
3771   if (data === null) return [];
3773   var index, length, pair, keys, result,
3774       object = data;
3776   result = new Array(object.length);
3778   for (index = 0, length = object.length; index < length; index += 1) {
3779     pair = object[index];
3781     keys = Object.keys(pair);
3783     result[index] = [ keys[0], pair[keys[0]] ];
3784   }
3786   return result;
3789 module.exports = new Type('tag:yaml.org,2002:pairs', {
3790   kind: 'sequence',
3791   resolve: resolveYamlPairs,
3792   construct: constructYamlPairs
3795 },{"../type":13}],26:[function(require,module,exports){
3796 'use strict';
3798 var Type = require('../type');
3800 module.exports = new Type('tag:yaml.org,2002:seq', {
3801   kind: 'sequence',
3802   construct: function (data) { return data !== null ? data : []; }
3805 },{"../type":13}],27:[function(require,module,exports){
3806 'use strict';
3808 var Type = require('../type');
3810 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3812 function resolveYamlSet(data) {
3813   if (data === null) return true;
3815   var key, object = data;
3817   for (key in object) {
3818     if (_hasOwnProperty.call(object, key)) {
3819       if (object[key] !== null) return false;
3820     }
3821   }
3823   return true;
3826 function constructYamlSet(data) {
3827   return data !== null ? data : {};
3830 module.exports = new Type('tag:yaml.org,2002:set', {
3831   kind: 'mapping',
3832   resolve: resolveYamlSet,
3833   construct: constructYamlSet
3836 },{"../type":13}],28:[function(require,module,exports){
3837 'use strict';
3839 var Type = require('../type');
3841 module.exports = new Type('tag:yaml.org,2002:str', {
3842   kind: 'scalar',
3843   construct: function (data) { return data !== null ? data : ''; }
3846 },{"../type":13}],29:[function(require,module,exports){
3847 'use strict';
3849 var Type = require('../type');
3851 var YAML_DATE_REGEXP = new RegExp(
3852   '^([0-9][0-9][0-9][0-9])'          + // [1] year
3853   '-([0-9][0-9])'                    + // [2] month
3854   '-([0-9][0-9])$');                   // [3] day
3856 var YAML_TIMESTAMP_REGEXP = new RegExp(
3857   '^([0-9][0-9][0-9][0-9])'          + // [1] year
3858   '-([0-9][0-9]?)'                   + // [2] month
3859   '-([0-9][0-9]?)'                   + // [3] day
3860   '(?:[Tt]|[ \\t]+)'                 + // ...
3861   '([0-9][0-9]?)'                    + // [4] hour
3862   ':([0-9][0-9])'                    + // [5] minute
3863   ':([0-9][0-9])'                    + // [6] second
3864   '(?:\\.([0-9]*))?'                 + // [7] fraction
3865   '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
3866   '(?::([0-9][0-9]))?))?$');           // [11] tz_minute
3868 function resolveYamlTimestamp(data) {
3869   if (data === null) return false;
3870   if (YAML_DATE_REGEXP.exec(data) !== null) return true;
3871   if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
3872   return false;
3875 function constructYamlTimestamp(data) {
3876   var match, year, month, day, hour, minute, second, fraction = 0,
3877       delta = null, tz_hour, tz_minute, date;
3879   match = YAML_DATE_REGEXP.exec(data);
3880   if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
3882   if (match === null) throw new Error('Date resolve error');
3884   // match: [1] year [2] month [3] day
3886   year = +(match[1]);
3887   month = +(match[2]) - 1; // JS month starts with 0
3888   day = +(match[3]);
3890   if (!match[4]) { // no hour
3891     return new Date(Date.UTC(year, month, day));
3892   }
3894   // match: [4] hour [5] minute [6] second [7] fraction
3896   hour = +(match[4]);
3897   minute = +(match[5]);
3898   second = +(match[6]);
3900   if (match[7]) {
3901     fraction = match[7].slice(0, 3);
3902     while (fraction.length < 3) { // milli-seconds
3903       fraction += '0';
3904     }
3905     fraction = +fraction;
3906   }
3908   // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
3910   if (match[9]) {
3911     tz_hour = +(match[10]);
3912     tz_minute = +(match[11] || 0);
3913     delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
3914     if (match[9] === '-') delta = -delta;
3915   }
3917   date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
3919   if (delta) date.setTime(date.getTime() - delta);
3921   return date;
3924 function representYamlTimestamp(object /*, style*/) {
3925   return object.toISOString();
3928 module.exports = new Type('tag:yaml.org,2002:timestamp', {
3929   kind: 'scalar',
3930   resolve: resolveYamlTimestamp,
3931   construct: constructYamlTimestamp,
3932   instanceOf: Date,
3933   represent: representYamlTimestamp
3936 },{"../type":13}],"/":[function(require,module,exports){
3937 'use strict';
3940 var yaml = require('./lib/js-yaml.js');
3943 module.exports = yaml;
3945 },{"./lib/js-yaml.js":1}]},{},[])("/")