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