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