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){
5 var loader = require('./js-yaml/loader');
6 var dumper = require('./js-yaml/dumper');
9 function deprecated(name) {
11 throw new Error('Function ' + name + ' is deprecated and cannot be used.');
16 module.exports.Type = require('./js-yaml/type');
17 module.exports.Schema = require('./js-yaml/schema');
18 module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
19 module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
20 module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
21 module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
22 module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
23 module.exports.load = loader.load;
24 module.exports.loadAll = loader.loadAll;
25 module.exports.safeLoad = loader.safeLoad;
26 module.exports.safeLoadAll = loader.safeLoadAll;
27 module.exports.dump = dumper.dump;
28 module.exports.safeDump = dumper.safeDump;
29 module.exports.YAMLException = require('./js-yaml/exception');
31 // Deprecated schema names from JS-YAML 2.0.x
32 module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
33 module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
34 module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
36 // Deprecated functions from JS-YAML 1.x.x
37 module.exports.scan = deprecated('scan');
38 module.exports.parse = deprecated('parse');
39 module.exports.compose = deprecated('compose');
40 module.exports.addConstructor = deprecated('addConstructor');
42 },{"./js-yaml/dumper":3,"./js-yaml/exception":4,"./js-yaml/loader":5,"./js-yaml/schema":7,"./js-yaml/schema/core":8,"./js-yaml/schema/default_full":9,"./js-yaml/schema/default_safe":10,"./js-yaml/schema/failsafe":11,"./js-yaml/schema/json":12,"./js-yaml/type":13}],2:[function(require,module,exports){
46 function isNothing(subject) {
47 return (typeof subject === 'undefined') || (subject === null);
51 function isObject(subject) {
52 return (typeof subject === 'object') && (subject !== null);
56 function toArray(sequence) {
57 if (Array.isArray(sequence)) return sequence;
58 else if (isNothing(sequence)) return [];
64 function extend(target, source) {
65 var index, length, key, sourceKeys;
68 sourceKeys = Object.keys(source);
70 for (index = 0, length = sourceKeys.length; index < length; index += 1) {
71 key = sourceKeys[index];
72 target[key] = source[key];
80 function repeat(string, count) {
81 var result = '', cycle;
83 for (cycle = 0; cycle < count; cycle += 1) {
91 function isNegativeZero(number) {
92 return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
96 module.exports.isNothing = isNothing;
97 module.exports.isObject = isObject;
98 module.exports.toArray = toArray;
99 module.exports.repeat = repeat;
100 module.exports.isNegativeZero = isNegativeZero;
101 module.exports.extend = extend;
103 },{}],3:[function(require,module,exports){
106 /*eslint-disable no-use-before-define*/
108 var common = require('./common');
109 var YAMLException = require('./exception');
110 var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
111 var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
113 var _toString = Object.prototype.toString;
114 var _hasOwnProperty = Object.prototype.hasOwnProperty;
116 var CHAR_TAB = 0x09; /* Tab */
117 var CHAR_LINE_FEED = 0x0A; /* LF */
118 var CHAR_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; /* } */
140 var ESCAPE_SEQUENCES = {};
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';
158 var DEPRECATED_BOOLEANS_SYNTAX = [
159 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
160 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
163 function compileStyleMap(schema, map) {
164 var result, keys, index, length, tag, style, type;
166 if (map === null) return {};
169 keys = Object.keys(map);
171 for (index = 0, length = keys.length; index < length; index += 1) {
173 style = String(map[tag]);
175 if (tag.slice(0, 2) === '!!') {
176 tag = 'tag:yaml.org,2002:' + tag.slice(2);
179 type = schema.compiledTypeMap[tag];
181 if (type && _hasOwnProperty.call(type.styleAliases, style)) {
182 style = type.styleAliases[style];
191 function encodeHex(character) {
192 var string, handle, length;
194 string = character.toString(16).toUpperCase();
196 if (character <= 0xFF) {
199 } else if (character <= 0xFFFF) {
202 } else if (character <= 0xFFFFFFFF) {
206 throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
209 return '\\' + handle + common.repeat('0', length - string.length) + string;
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;
223 this.implicitTypes = this.schema.compiledImplicit;
224 this.explicitTypes = this.schema.compiledExplicit;
229 this.duplicates = [];
230 this.usedDuplicates = null;
233 function indentString(string, spaces) {
234 var ind = common.repeat(' ', spaces),
239 length = string.length;
241 while (position < length) {
242 next = string.indexOf('\n', position);
244 line = string.slice(position);
247 line = string.slice(position, next + 1);
251 if (line.length && line !== '\n') result += ind;
259 function generateNextLine(state, level) {
260 return '\n' + common.repeat(' ', state.indent * level);
263 function testImplicitResolving(state, str) {
264 var index, length, type;
266 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
267 type = state.implicitTypes[index];
269 if (type.resolve(str)) {
277 function StringBuilder(source) {
278 this.source = source;
283 StringBuilder.prototype.takeUpTo = function (position) {
286 if (position < this.checkpoint) {
287 er = new Error('position should be > checkpoint');
288 er.position = position;
289 er.checkpoint = this.checkpoint;
293 this.result += this.source.slice(this.checkpoint, position);
294 this.checkpoint = position;
298 StringBuilder.prototype.escapeChar = function () {
301 character = this.source.charCodeAt(this.checkpoint);
302 esc = ESCAPE_SEQUENCES[character] || encodeHex(character);
304 this.checkpoint += 1;
309 StringBuilder.prototype.finish = function () {
310 if (this.source.length > this.checkpoint) {
311 this.takeUpTo(this.source.length);
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;
321 if (object.length === 0) {
326 if (!state.noCompatMode &&
327 DEPRECATED_BOOLEANS_SYNTAX.indexOf(object) !== -1) {
328 state.dump = "'" + object + "'";
333 first = object.length ? object.charCodeAt(0) : 0;
334 spaceWrap = (CHAR_SPACE === first ||
335 CHAR_SPACE === object.charCodeAt(object.length - 1));
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) {
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;
359 double = new StringBuilder(object);
365 indent = state.indent * level;
366 max = state.lineWidth;
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;
372 if (indent < 40) max -= indent;
375 for (position = 0; position < object.length; position++) {
376 character = object.charCodeAt(position);
378 // Characters that can never appear in the simple scalar
379 if (!simpleChar(character)) {
382 // Still simple. If we make it all the way through like
383 // this, then we can just dump the string as-is.
388 if (single && character === CHAR_SINGLE_QUOTE) {
392 escapeSeq = ESCAPE_SEQUENCES[character];
393 hexEsc = needsHexEscape(character);
395 if (!escapeSeq && !hexEsc) {
399 if (character !== CHAR_LINE_FEED &&
400 character !== CHAR_DOUBLE_QUOTE &&
401 character !== CHAR_SINGLE_QUOTE) {
404 } else if (character === CHAR_LINE_FEED) {
408 previous = object.charCodeAt(position - 1);
409 if (previous === CHAR_SPACE) {
415 lineLength = position - linePosition;
416 linePosition = position;
417 if (lineLength > longestLine) longestLine = lineLength;
421 if (character !== CHAR_DOUBLE_QUOTE) single = false;
423 double.takeUpTo(position);
427 if (simple && testImplicitResolving(state, object)) simple = false;
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;
439 if (trailingLineBreaks === 0) modifier = '-';
440 else if (trailingLineBreaks === 2) modifier = '+';
443 if (literal && longestLine < max || state.tag !== null) {
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;
454 state.dump = '\'' + object + '\'';
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);
463 state.dump = '"' + double.result + '"';
465 throw new Error('Failed to dump scalar value');
471 // The `trailing` var is a regexp match of any trailing `\n` characters.
473 // There are three cases we care about:
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 `>+`.
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) {
486 length = object.length,
487 trailing = /\n+$/.exec(object),
491 length = trailing.index + 1;
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);
502 if (result) result += '\n\n';
503 result += foldLine(object.slice(position, newLine), max);
504 position = newLine + 1;
508 if (trailing && trailing[0] !== '\n') result += trailing[0];
513 function foldLine(line, max) {
514 if (line === '') return line;
516 var foldRe = /[^\s] [^\s]/g,
520 match = foldRe.exec(line),
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;
535 if (result) result += '\n';
536 folded = line.slice(foldStart, foldEnd);
538 foldStart = foldEnd + 1;
540 prevMatch = index + 1;
541 match = foldRe.exec(line);
544 if (result) result += '\n';
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);
552 result += line.slice(foldStart);
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);
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));
591 function writeFlowSequence(state, level, object) {
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;
606 state.dump = '[' + _result + ']';
609 function writeBlockSequence(state, level, object, compact) {
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);
621 _result += '- ' + state.dump;
626 state.dump = _result || '[]'; // Empty sequence if no valid values.
629 function writeFlowMapping(state, level, object) {
632 objectKeyList = Object.keys(object),
639 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
642 if (index !== 0) pairBuffer += ', ';
644 objectKey = objectKeyList[index];
645 objectValue = object[objectKey];
647 if (!writeNode(state, level, objectKey, false, false)) {
648 continue; // Skip this pair because of invalid key;
651 if (state.dump.length > 1024) pairBuffer += '? ';
653 pairBuffer += state.dump + ': ';
655 if (!writeNode(state, level, objectValue, false, false)) {
656 continue; // Skip this pair because of invalid value.
659 pairBuffer += state.dump;
661 // Both key and value are valid.
662 _result += pairBuffer;
666 state.dump = '{' + _result + '}';
669 function writeBlockMapping(state, level, object, compact) {
672 objectKeyList = Object.keys(object),
680 // Allow sorting keys so that the output file is deterministic
681 if (state.sortKeys === true) {
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');
692 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
695 if (!compact || index !== 0) {
696 pairBuffer += generateNextLine(state, level);
699 objectKey = objectKeyList[index];
700 objectValue = object[objectKey];
702 if (!writeNode(state, level + 1, objectKey, true, true, true)) {
703 continue; // Skip this pair because of invalid key.
706 explicitPair = (state.tag !== null && state.tag !== '?') ||
707 (state.dump && state.dump.length > 1024);
710 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
717 pairBuffer += state.dump;
720 pairBuffer += generateNextLine(state, level);
723 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
724 continue; // Skip this pair because of invalid value.
727 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
733 pairBuffer += state.dump;
735 // Both key and value are valid.
736 _result += pairBuffer;
740 state.dump = _result || '{}'; // Empty mapping if no valid pairs.
743 function detectType(state, object, explicit) {
744 var _result, typeList, index, length, type, style;
746 typeList = explicit ? state.explicitTypes : state.implicitTypes;
748 for (index = 0, length = typeList.length; index < length; index += 1) {
749 type = typeList[index];
751 if ((type.instanceOf || type.predicate) &&
752 (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
753 (!type.predicate || type.predicate(object))) {
755 state.tag = explicit ? type.tag : '?';
757 if (type.represent) {
758 style = state.styleMap[type.tag] || type.defaultStyle;
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);
765 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
768 state.dump = _result;
778 // Serializes `object` and writes it to global `result`.
779 // Returns true on success, or false on invalid object.
781 function writeNode(state, level, object, block, compact, iskey) {
785 if (!detectType(state, object, false)) {
786 detectType(state, object, true);
789 var type = _toString.call(state.dump);
792 block = (state.flowLevel < 0 || state.flowLevel > level);
795 var objectOrArray = type === '[object Object]' || type === '[object Array]',
800 duplicateIndex = state.duplicates.indexOf(object);
801 duplicate = duplicateIndex !== -1;
804 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
808 if (duplicate && state.usedDuplicates[duplicateIndex]) {
809 state.dump = '*ref_' + duplicateIndex;
811 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
812 state.usedDuplicates[duplicateIndex] = true;
814 if (type === '[object Object]') {
815 if (block && (Object.keys(state.dump).length !== 0)) {
816 writeBlockMapping(state, level, state.dump, compact);
818 state.dump = '&ref_' + duplicateIndex + state.dump;
821 writeFlowMapping(state, level, state.dump);
823 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
826 } else if (type === '[object Array]') {
827 if (block && (state.dump.length !== 0)) {
828 writeBlockSequence(state, level, state.dump, compact);
830 state.dump = '&ref_' + duplicateIndex + state.dump;
833 writeFlowSequence(state, level, state.dump);
835 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
838 } else if (type === '[object String]') {
839 if (state.tag !== '?') {
840 writeScalar(state, state.dump, level, iskey);
843 if (state.skipInvalid) return false;
844 throw new YAMLException('unacceptable kind of an object to dump ' + type);
847 if (state.tag !== null && state.tag !== '?') {
848 state.dump = '!<' + state.tag + '> ' + state.dump;
855 function getDuplicateReferences(object, state) {
857 duplicatesIndexes = [],
861 inspectNode(object, objects, duplicatesIndexes);
863 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
864 state.duplicates.push(objects[duplicatesIndexes[index]]);
866 state.usedDuplicates = new Array(length);
869 function inspectNode(object, objects, duplicatesIndexes) {
874 if (object !== null && typeof object === 'object') {
875 index = objects.indexOf(object);
877 if (duplicatesIndexes.indexOf(index) === -1) {
878 duplicatesIndexes.push(index);
881 objects.push(object);
883 if (Array.isArray(object)) {
884 for (index = 0, length = object.length; index < length; index += 1) {
885 inspectNode(object[index], objects, duplicatesIndexes);
888 objectKeyList = Object.keys(object);
890 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
891 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
898 function dump(input, options) {
899 options = options || {};
901 var state = new State(options);
903 if (!state.noRefs) getDuplicateReferences(input, state);
905 if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
910 function safeDump(input, options) {
911 return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
914 module.exports.dump = dump;
915 module.exports.safeDump = safeDump;
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
922 function YAMLException(reason, mark) {
926 // Include stack trace in error object
927 if (Error.captureStackTrace) {
929 Error.captureStackTrace(this, this.constructor);
931 // FF, IE 10+ and Safari 6+. Fallback for others
932 this.stack = (new Error()).stack || '';
935 this.name = 'YAMLException';
936 this.reason = reason;
938 this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
942 // Inherit from Error
943 YAMLException.prototype = Object.create(Error.prototype);
944 YAMLException.prototype.constructor = YAMLException;
947 YAMLException.prototype.toString = function toString(compact) {
948 var result = this.name + ': ';
950 result += this.reason || '(unknown reason)';
952 if (!compact && this.mark) {
953 result += ' ' + this.mark.toString();
960 module.exports = YAMLException;
962 },{}],5:[function(require,module,exports){
965 /*eslint-disable max-len,no-use-before-define*/
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');
974 var _hasOwnProperty = Object.prototype.hasOwnProperty;
977 var CONTEXT_FLOW_IN = 1;
978 var CONTEXT_FLOW_OUT = 2;
979 var CONTEXT_BLOCK_IN = 3;
980 var CONTEXT_BLOCK_OUT = 4;
983 var CHOMPING_CLIP = 1;
984 var CHOMPING_STRIP = 2;
985 var CHOMPING_KEEP = 3;
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;
996 return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
999 function is_WHITE_SPACE(c) {
1000 return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
1003 function is_WS_OR_EOL(c) {
1004 return (c === 0x09/* Tab */) ||
1005 (c === 0x20/* Space */) ||
1006 (c === 0x0A/* LF */) ||
1007 (c === 0x0D/* CR */);
1010 function is_FLOW_INDICATOR(c) {
1011 return c === 0x2C/* , */ ||
1012 c === 0x5B/* [ */ ||
1013 c === 0x5D/* ] */ ||
1014 c === 0x7B/* { */ ||
1018 function fromHexCode(c) {
1021 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1025 /*eslint-disable no-bitwise*/
1028 if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
1029 return lc - 0x61 + 10;
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; }
1042 function fromDecimalCode(c) {
1043 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
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' : '';
1071 function charFromCodepoint(c) {
1073 return String.fromCharCode(c);
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);
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);
1089 function State(input, options) {
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;
1099 this.implicitTypes = this.schema.compiledImplicit;
1100 this.typeMap = this.schema.compiledTypeMap;
1102 this.length = input.length;
1106 this.lineIndent = 0;
1108 this.documents = [];
1112 this.checkLineBreaks;
1123 function generateError(state, message) {
1124 return new YAMLException(
1126 new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
1129 function throwError(state, message) {
1130 throw generateError(state, message);
1133 function throwWarning(state, message) {
1134 if (state.onWarning) {
1135 state.onWarning.call(null, generateError(state, message));
1140 var directiveHandlers = {
1142 YAML: function handleYamlDirective(state, name, args) {
1144 var match, major, minor;
1146 if (state.version !== null) {
1147 throwError(state, 'duplication of %YAML directive');
1150 if (args.length !== 1) {
1151 throwError(state, 'YAML directive accepts exactly one argument');
1154 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1156 if (match === null) {
1157 throwError(state, 'ill-formed argument of the YAML directive');
1160 major = parseInt(match[1], 10);
1161 minor = parseInt(match[2], 10);
1164 throwError(state, 'unacceptable YAML version of the document');
1167 state.version = args[0];
1168 state.checkLineBreaks = (minor < 2);
1170 if (minor !== 1 && minor !== 2) {
1171 throwWarning(state, 'unsupported YAML version of the document');
1175 TAG: function handleTagDirective(state, name, args) {
1179 if (args.length !== 2) {
1180 throwError(state, 'TAG directive accepts exactly two arguments');
1186 if (!PATTERN_TAG_HANDLE.test(handle)) {
1187 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
1190 if (_hasOwnProperty.call(state.tagMap, handle)) {
1191 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1194 if (!PATTERN_TAG_URI.test(prefix)) {
1195 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
1198 state.tagMap[handle] = prefix;
1203 function captureSegment(state, start, end, checkJson) {
1204 var _position, _length, _character, _result;
1207 _result = state.input.slice(start, end);
1210 for (_position = 0, _length = _result.length;
1211 _position < _length;
1213 _character = _result.charCodeAt(_position);
1214 if (!(_character === 0x09 ||
1215 (0x20 <= _character && _character <= 0x10FFFF))) {
1216 throwError(state, 'expected valid JSON character');
1219 } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1220 throwError(state, 'the stream contains non-printable characters');
1223 state.result += _result;
1227 function mergeMappings(state, destination, source, overridableKeys) {
1228 var sourceKeys, key, index, quantity;
1230 if (!common.isObject(source)) {
1231 throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
1234 sourceKeys = Object.keys(source);
1236 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1237 key = sourceKeys[index];
1239 if (!_hasOwnProperty.call(destination, key)) {
1240 destination[key] = source[key];
1241 overridableKeys[key] = true;
1246 function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode) {
1247 var index, quantity;
1249 keyNode = String(keyNode);
1251 if (_result === null) {
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);
1261 mergeMappings(state, _result, valueNode, overridableKeys);
1265 !_hasOwnProperty.call(overridableKeys, keyNode) &&
1266 _hasOwnProperty.call(_result, keyNode)) {
1267 throwError(state, 'duplicated mapping key');
1269 _result[keyNode] = valueNode;
1270 delete overridableKeys[keyNode];
1276 function readLineBreak(state) {
1279 ch = state.input.charCodeAt(state.position);
1281 if (ch === 0x0A/* LF */) {
1283 } else if (ch === 0x0D/* CR */) {
1285 if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
1289 throwError(state, 'a line break is expected');
1293 state.lineStart = state.position;
1296 function skipSeparationSpace(state, allowComments, checkIndent) {
1298 ch = state.input.charCodeAt(state.position);
1301 while (is_WHITE_SPACE(ch)) {
1302 ch = state.input.charCodeAt(++state.position);
1305 if (allowComments && ch === 0x23/* # */) {
1307 ch = state.input.charCodeAt(++state.position);
1308 } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
1312 readLineBreak(state);
1314 ch = state.input.charCodeAt(state.position);
1316 state.lineIndent = 0;
1318 while (ch === 0x20/* Space */) {
1320 ch = state.input.charCodeAt(++state.position);
1327 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1328 throwWarning(state, 'deficient indentation');
1334 function testDocumentSeparator(state) {
1335 var _position = state.position,
1338 ch = state.input.charCodeAt(_position);
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)) {
1348 ch = state.input.charCodeAt(_position);
1350 if (ch === 0 || is_WS_OR_EOL(ch)) {
1358 function writeFoldedLines(state, count) {
1360 state.result += ' ';
1361 } else if (count > 1) {
1362 state.result += common.repeat('\n', count - 1);
1367 function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1377 _result = state.result,
1380 ch = state.input.charCodeAt(state.position);
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/* ` */) {
1398 if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
1399 following = state.input.charCodeAt(state.position + 1);
1401 if (is_WS_OR_EOL(following) ||
1402 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1407 state.kind = 'scalar';
1409 captureStart = captureEnd = state.position;
1410 hasPendingContent = false;
1413 if (ch === 0x3A/* : */) {
1414 following = state.input.charCodeAt(state.position + 1);
1416 if (is_WS_OR_EOL(following) ||
1417 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1421 } else if (ch === 0x23/* # */) {
1422 preceding = state.input.charCodeAt(state.position - 1);
1424 if (is_WS_OR_EOL(preceding)) {
1428 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
1429 withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1432 } else if (is_EOL(ch)) {
1434 _lineStart = state.lineStart;
1435 _lineIndent = state.lineIndent;
1436 skipSeparationSpace(state, false, -1);
1438 if (state.lineIndent >= nodeIndent) {
1439 hasPendingContent = true;
1440 ch = state.input.charCodeAt(state.position);
1443 state.position = captureEnd;
1445 state.lineStart = _lineStart;
1446 state.lineIndent = _lineIndent;
1451 if (hasPendingContent) {
1452 captureSegment(state, captureStart, captureEnd, false);
1453 writeFoldedLines(state, state.line - _line);
1454 captureStart = captureEnd = state.position;
1455 hasPendingContent = false;
1458 if (!is_WHITE_SPACE(ch)) {
1459 captureEnd = state.position + 1;
1462 ch = state.input.charCodeAt(++state.position);
1465 captureSegment(state, captureStart, captureEnd, false);
1472 state.result = _result;
1476 function readSingleQuotedScalar(state, nodeIndent) {
1478 captureStart, captureEnd;
1480 ch = state.input.charCodeAt(state.position);
1482 if (ch !== 0x27/* ' */) {
1486 state.kind = 'scalar';
1489 captureStart = captureEnd = state.position;
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);
1496 if (ch === 0x27/* ' */) {
1497 captureStart = captureEnd = state.position;
1503 } else if (is_EOL(ch)) {
1504 captureSegment(state, captureStart, captureEnd, true);
1505 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1506 captureStart = captureEnd = state.position;
1508 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1509 throwError(state, 'unexpected end of the document within a single quoted scalar');
1513 captureEnd = state.position;
1517 throwError(state, 'unexpected end of the stream within a single quoted scalar');
1520 function readDoubleQuotedScalar(state, nodeIndent) {
1528 ch = state.input.charCodeAt(state.position);
1530 if (ch !== 0x22/* " */) {
1534 state.kind = 'scalar';
1537 captureStart = captureEnd = state.position;
1539 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1540 if (ch === 0x22/* " */) {
1541 captureSegment(state, captureStart, state.position, true);
1545 } else if (ch === 0x5C/* \ */) {
1546 captureSegment(state, captureStart, state.position, true);
1547 ch = state.input.charCodeAt(++state.position);
1550 skipSeparationSpace(state, false, nodeIndent);
1552 // TODO: rework to inline fn with no type cast?
1553 } else if (ch < 256 && simpleEscapeCheck[ch]) {
1554 state.result += simpleEscapeMap[ch];
1557 } else if ((tmp = escapedHexLen(ch)) > 0) {
1561 for (; hexLength > 0; hexLength--) {
1562 ch = state.input.charCodeAt(++state.position);
1564 if ((tmp = fromHexCode(ch)) >= 0) {
1565 hexResult = (hexResult << 4) + tmp;
1568 throwError(state, 'expected hexadecimal character');
1572 state.result += charFromCodepoint(hexResult);
1577 throwError(state, 'unknown escape sequence');
1580 captureStart = captureEnd = state.position;
1582 } else if (is_EOL(ch)) {
1583 captureSegment(state, captureStart, captureEnd, true);
1584 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1585 captureStart = captureEnd = state.position;
1587 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1588 throwError(state, 'unexpected end of the document within a double quoted scalar');
1592 captureEnd = state.position;
1596 throwError(state, 'unexpected end of the stream within a double quoted scalar');
1599 function readFlowCollection(state, nodeIndent) {
1600 var readNext = true,
1604 _anchor = state.anchor,
1610 overridableKeys = {},
1616 ch = state.input.charCodeAt(state.position);
1618 if (ch === 0x5B/* [ */) {
1619 terminator = 0x5D;/* ] */
1622 } else if (ch === 0x7B/* { */) {
1623 terminator = 0x7D;/* } */
1630 if (state.anchor !== null) {
1631 state.anchorMap[state.anchor] = _result;
1634 ch = state.input.charCodeAt(++state.position);
1637 skipSeparationSpace(state, true, nodeIndent);
1639 ch = state.input.charCodeAt(state.position);
1641 if (ch === terminator) {
1644 state.anchor = _anchor;
1645 state.kind = isMapping ? 'mapping' : 'sequence';
1646 state.result = _result;
1648 } else if (!readNext) {
1649 throwError(state, 'missed comma between flow collection entries');
1652 keyTag = keyNode = valueNode = null;
1653 isPair = isExplicitPair = false;
1655 if (ch === 0x3F/* ? */) {
1656 following = state.input.charCodeAt(state.position + 1);
1658 if (is_WS_OR_EOL(following)) {
1659 isPair = isExplicitPair = true;
1661 skipSeparationSpace(state, true, nodeIndent);
1666 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1668 keyNode = state.result;
1669 skipSeparationSpace(state, true, nodeIndent);
1671 ch = state.input.charCodeAt(state.position);
1673 if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
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;
1682 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
1683 } else if (isPair) {
1684 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
1686 _result.push(keyNode);
1689 skipSeparationSpace(state, true, nodeIndent);
1691 ch = state.input.charCodeAt(state.position);
1693 if (ch === 0x2C/* , */) {
1695 ch = state.input.charCodeAt(++state.position);
1701 throwError(state, 'unexpected end of the stream within a flow collection');
1704 function readBlockScalar(state, nodeIndent) {
1707 chomping = CHOMPING_CLIP,
1708 detectedIndent = false,
1709 textIndent = nodeIndent,
1711 atMoreIndented = false,
1715 ch = state.input.charCodeAt(state.position);
1717 if (ch === 0x7C/* | */) {
1719 } else if (ch === 0x3E/* > */) {
1725 state.kind = 'scalar';
1729 ch = state.input.charCodeAt(++state.position);
1731 if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
1732 if (CHOMPING_CLIP === chomping) {
1733 chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
1735 throwError(state, 'repeat of a chomping mode identifier');
1738 } else if ((tmp = fromDecimalCode(ch)) >= 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;
1745 throwError(state, 'repeat of an indentation width identifier');
1753 if (is_WHITE_SPACE(ch)) {
1754 do { ch = state.input.charCodeAt(++state.position); }
1755 while (is_WHITE_SPACE(ch));
1757 if (ch === 0x23/* # */) {
1758 do { ch = state.input.charCodeAt(++state.position); }
1759 while (!is_EOL(ch) && (ch !== 0));
1764 readLineBreak(state);
1765 state.lineIndent = 0;
1767 ch = state.input.charCodeAt(state.position);
1769 while ((!detectedIndent || state.lineIndent < textIndent) &&
1770 (ch === 0x20/* Space */)) {
1772 ch = state.input.charCodeAt(++state.position);
1775 if (!detectedIndent && state.lineIndent > textIndent) {
1776 textIndent = state.lineIndent;
1784 // End of the scalar.
1785 if (state.lineIndent < textIndent) {
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';
1796 // Break this `while` cycle and go to the funciton's epilogue.
1800 // Folded style: use fancy rules to handle line breaks.
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);
1808 // End of more-indented block.
1809 } else if (atMoreIndented) {
1810 atMoreIndented = false;
1811 state.result += common.repeat('\n', emptyLines + 1);
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 += ' ';
1819 // Several line breaks - perceive as different lines.
1821 state.result += common.repeat('\n', emptyLines);
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);
1829 // In case of the first content line - count only empty lines.
1830 state.result += common.repeat('\n', emptyLines);
1833 detectedIndent = true;
1835 captureStart = state.position;
1837 while (!is_EOL(ch) && (ch !== 0)) {
1838 ch = state.input.charCodeAt(++state.position);
1841 captureSegment(state, captureStart, state.position, false);
1847 function readBlockSequence(state, nodeIndent) {
1850 _anchor = state.anchor,
1856 if (state.anchor !== null) {
1857 state.anchorMap[state.anchor] = _result;
1860 ch = state.input.charCodeAt(state.position);
1864 if (ch !== 0x2D/* - */) {
1868 following = state.input.charCodeAt(state.position + 1);
1870 if (!is_WS_OR_EOL(following)) {
1877 if (skipSeparationSpace(state, true, -1)) {
1878 if (state.lineIndent <= nodeIndent) {
1880 ch = state.input.charCodeAt(state.position);
1886 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1887 _result.push(state.result);
1888 skipSeparationSpace(state, true, -1);
1890 ch = state.input.charCodeAt(state.position);
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) {
1901 state.anchor = _anchor;
1902 state.kind = 'sequence';
1903 state.result = _result;
1909 function readBlockMapping(state, nodeIndent, flowIndent) {
1914 _anchor = state.anchor,
1916 overridableKeys = {},
1920 atExplicitKey = false,
1924 if (state.anchor !== null) {
1925 state.anchorMap[state.anchor] = _result;
1928 ch = state.input.charCodeAt(state.position);
1931 following = state.input.charCodeAt(state.position + 1);
1932 _line = state.line; // Save the current line.
1935 // Explicit notation case. There are two separate blocks:
1936 // first for the key (denoted by "?") and second for the value (denoted by ":")
1938 if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
1940 if (ch === 0x3F/* ? */) {
1941 if (atExplicitKey) {
1942 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1943 keyTag = keyNode = valueNode = null;
1947 atExplicitKey = true;
1948 allowCompact = true;
1950 } else if (atExplicitKey) {
1951 // i.e. 0x3A/* : */ === character after the explicit key.
1952 atExplicitKey = false;
1953 allowCompact = true;
1956 throwError(state, 'incomplete explicit mapping pair; a key node is missed');
1959 state.position += 1;
1963 // Implicit notation case. Flow-style node as the key first, then ":", and the value.
1965 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1967 if (state.line === _line) {
1968 ch = state.input.charCodeAt(state.position);
1970 while (is_WHITE_SPACE(ch)) {
1971 ch = state.input.charCodeAt(++state.position);
1974 if (ch === 0x3A/* : */) {
1975 ch = state.input.charCodeAt(++state.position);
1977 if (!is_WS_OR_EOL(ch)) {
1978 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
1981 if (atExplicitKey) {
1982 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1983 keyTag = keyNode = valueNode = null;
1987 atExplicitKey = false;
1988 allowCompact = false;
1990 keyNode = state.result;
1992 } else if (detected) {
1993 throwError(state, 'can not read an implicit mapping pair; a colon is missed');
1997 state.anchor = _anchor;
1998 return true; // Keep the result of `composeNode`.
2001 } else if (detected) {
2002 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
2006 state.anchor = _anchor;
2007 return true; // Keep the result of `composeNode`.
2011 break; // Reading is done. Go to the epilogue.
2015 // Common reading code for both explicit and implicit notations.
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;
2022 valueNode = state.result;
2026 if (!atExplicitKey) {
2027 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
2028 keyTag = keyNode = valueNode = null;
2031 skipSeparationSpace(state, true, -1);
2032 ch = state.input.charCodeAt(state.position);
2035 if (state.lineIndent > nodeIndent && (ch !== 0)) {
2036 throwError(state, 'bad indentation of a mapping entry');
2037 } else if (state.lineIndent < nodeIndent) {
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);
2051 // Expose the resulting mapping.
2054 state.anchor = _anchor;
2055 state.kind = 'mapping';
2056 state.result = _result;
2062 function readTagProperty(state) {
2070 ch = state.input.charCodeAt(state.position);
2072 if (ch !== 0x21/* ! */) return false;
2074 if (state.tag !== null) {
2075 throwError(state, 'duplication of a tag property');
2078 ch = state.input.charCodeAt(++state.position);
2080 if (ch === 0x3C/* < */) {
2082 ch = state.input.charCodeAt(++state.position);
2084 } else if (ch === 0x21/* ! */) {
2087 ch = state.input.charCodeAt(++state.position);
2093 _position = state.position;
2096 do { ch = state.input.charCodeAt(++state.position); }
2097 while (ch !== 0 && ch !== 0x3E/* > */);
2099 if (state.position < state.length) {
2100 tagName = state.input.slice(_position, state.position);
2101 ch = state.input.charCodeAt(++state.position);
2103 throwError(state, 'unexpected end of the stream within a verbatim tag');
2106 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2108 if (ch === 0x21/* ! */) {
2110 tagHandle = state.input.slice(_position - 1, state.position + 1);
2112 if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2113 throwError(state, 'named tag handle cannot contain such characters');
2117 _position = state.position + 1;
2119 throwError(state, 'tag suffix cannot contain exclamation marks');
2123 ch = state.input.charCodeAt(++state.position);
2126 tagName = state.input.slice(_position, state.position);
2128 if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2129 throwError(state, 'tag suffix cannot contain flow indicator characters');
2133 if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2134 throwError(state, 'tag name cannot contain such characters: ' + tagName);
2138 state.tag = tagName;
2140 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
2141 state.tag = state.tagMap[tagHandle] + tagName;
2143 } else if (tagHandle === '!') {
2144 state.tag = '!' + tagName;
2146 } else if (tagHandle === '!!') {
2147 state.tag = 'tag:yaml.org,2002:' + tagName;
2150 throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2156 function readAnchorProperty(state) {
2160 ch = state.input.charCodeAt(state.position);
2162 if (ch !== 0x26/* & */) return false;
2164 if (state.anchor !== null) {
2165 throwError(state, 'duplication of an anchor property');
2168 ch = state.input.charCodeAt(++state.position);
2169 _position = state.position;
2171 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2172 ch = state.input.charCodeAt(++state.position);
2175 if (state.position === _position) {
2176 throwError(state, 'name of an anchor node must contain at least one character');
2179 state.anchor = state.input.slice(_position, state.position);
2183 function readAlias(state) {
2184 var _position, alias,
2187 ch = state.input.charCodeAt(state.position);
2189 if (ch !== 0x2A/* * */) return false;
2191 ch = state.input.charCodeAt(++state.position);
2192 _position = state.position;
2194 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2195 ch = state.input.charCodeAt(++state.position);
2198 if (state.position === _position) {
2199 throwError(state, 'name of an alias node must contain at least one character');
2202 alias = state.input.slice(_position, state.position);
2204 if (!state.anchorMap.hasOwnProperty(alias)) {
2205 throwError(state, 'unidentified alias "' + alias + '"');
2208 state.result = state.anchorMap[alias];
2209 skipSeparationSpace(state, true, -1);
2213 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2214 var allowBlockStyles,
2216 allowBlockCollections,
2217 indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
2226 if (state.listener !== null) {
2227 state.listener('open', state);
2231 state.anchor = null;
2233 state.result = null;
2235 allowBlockStyles = allowBlockScalars = allowBlockCollections =
2236 CONTEXT_BLOCK_OUT === nodeContext ||
2237 CONTEXT_BLOCK_IN === nodeContext;
2240 if (skipSeparationSpace(state, true, -1)) {
2243 if (state.lineIndent > parentIndent) {
2245 } else if (state.lineIndent === parentIndent) {
2247 } else if (state.lineIndent < parentIndent) {
2253 if (indentStatus === 1) {
2254 while (readTagProperty(state) || readAnchorProperty(state)) {
2255 if (skipSeparationSpace(state, true, -1)) {
2257 allowBlockCollections = allowBlockStyles;
2259 if (state.lineIndent > parentIndent) {
2261 } else if (state.lineIndent === parentIndent) {
2263 } else if (state.lineIndent < parentIndent) {
2267 allowBlockCollections = false;
2272 if (allowBlockCollections) {
2273 allowBlockCollections = atNewLine || allowCompact;
2276 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2277 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2278 flowIndent = parentIndent;
2280 flowIndent = parentIndent + 1;
2283 blockIndent = state.position - state.lineStart;
2285 if (indentStatus === 1) {
2286 if (allowBlockCollections &&
2287 (readBlockSequence(state, blockIndent) ||
2288 readBlockMapping(state, blockIndent, flowIndent)) ||
2289 readFlowCollection(state, flowIndent)) {
2292 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
2293 readSingleQuotedScalar(state, flowIndent) ||
2294 readDoubleQuotedScalar(state, flowIndent)) {
2297 } else if (readAlias(state)) {
2300 if (state.tag !== null || state.anchor !== null) {
2301 throwError(state, 'alias node should not have any properties');
2304 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2307 if (state.tag === null) {
2312 if (state.anchor !== null) {
2313 state.anchorMap[state.anchor] = state.result;
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);
2323 if (state.tag !== null && state.tag !== '!') {
2324 if (state.tag === '?') {
2325 for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
2326 typeIndex < typeQuantity;
2328 type = state.implicitTypes[typeIndex];
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.
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;
2343 } else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
2344 type = state.typeMap[state.tag];
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 + '"');
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');
2353 state.result = type.construct(state.result);
2354 if (state.anchor !== null) {
2355 state.anchorMap[state.anchor] = state.result;
2359 throwError(state, 'unknown tag !<' + state.tag + '>');
2363 if (state.listener !== null) {
2364 state.listener('close', state);
2366 return state.tag !== null || state.anchor !== null || hasContent;
2369 function readDocument(state) {
2370 var documentStart = state.position,
2374 hasDirectives = false,
2377 state.version = null;
2378 state.checkLineBreaks = state.legacy;
2380 state.anchorMap = {};
2382 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2383 skipSeparationSpace(state, true, -1);
2385 ch = state.input.charCodeAt(state.position);
2387 if (state.lineIndent > 0 || ch !== 0x25/* % */) {
2391 hasDirectives = true;
2392 ch = state.input.charCodeAt(++state.position);
2393 _position = state.position;
2395 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2396 ch = state.input.charCodeAt(++state.position);
2399 directiveName = state.input.slice(_position, state.position);
2402 if (directiveName.length < 1) {
2403 throwError(state, 'directive name must not be less than one character in length');
2407 while (is_WHITE_SPACE(ch)) {
2408 ch = state.input.charCodeAt(++state.position);
2411 if (ch === 0x23/* # */) {
2412 do { ch = state.input.charCodeAt(++state.position); }
2413 while (ch !== 0 && !is_EOL(ch));
2417 if (is_EOL(ch)) break;
2419 _position = state.position;
2421 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2422 ch = state.input.charCodeAt(++state.position);
2425 directiveArgs.push(state.input.slice(_position, state.position));
2428 if (ch !== 0) readLineBreak(state);
2430 if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2431 directiveHandlers[directiveName](state, directiveName, directiveArgs);
2433 throwWarning(state, 'unknown document directive "' + directiveName + '"');
2437 skipSeparationSpace(state, true, -1);
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);
2446 } else if (hasDirectives) {
2447 throwError(state, 'directives end mark is expected');
2450 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2451 skipSeparationSpace(state, true, -1);
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');
2458 state.documents.push(state.result);
2460 if (state.position === state.lineStart && testDocumentSeparator(state)) {
2462 if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
2463 state.position += 3;
2464 skipSeparationSpace(state, true, -1);
2469 if (state.position < (state.length - 1)) {
2470 throwError(state, 'end of the stream or a document separator is expected');
2477 function loadDocuments(input, options) {
2478 input = String(input);
2479 options = options || {};
2481 if (input.length !== 0) {
2483 // Add tailing `\n` if not exists
2484 if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
2485 input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
2490 if (input.charCodeAt(0) === 0xFEFF) {
2491 input = input.slice(1);
2495 var state = new State(input, options);
2497 // Use 0 as string terminator. That significantly simplifies bounds check.
2498 state.input += '\0';
2500 while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
2501 state.lineIndent += 1;
2502 state.position += 1;
2505 while (state.position < (state.length - 1)) {
2506 readDocument(state);
2509 return state.documents;
2513 function loadAll(input, iterator, options) {
2514 var documents = loadDocuments(input, options), index, length;
2516 for (index = 0, length = documents.length; index < length; index += 1) {
2517 iterator(documents[index]);
2522 function load(input, options) {
2523 var documents = loadDocuments(input, options);
2525 if (documents.length === 0) {
2526 /*eslint-disable no-undefined*/
2528 } else if (documents.length === 1) {
2529 return documents[0];
2531 throw new YAMLException('expected a single document in the stream, but found more');
2535 function safeLoadAll(input, output, options) {
2536 loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2540 function safeLoad(input, options) {
2541 return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2545 module.exports.loadAll = loadAll;
2546 module.exports.load = load;
2547 module.exports.safeLoadAll = safeLoadAll;
2548 module.exports.safeLoad = safeLoad;
2550 },{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){
2554 var common = require('./common');
2557 function Mark(name, buffer, position, line, column) {
2559 this.buffer = buffer;
2560 this.position = position;
2562 this.column = column;
2566 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2567 var head, start, tail, end, snippet;
2569 if (!this.buffer) return null;
2571 indent = indent || 4;
2572 maxLength = maxLength || 75;
2575 start = this.position;
2577 while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
2579 if (this.position - start > (maxLength / 2 - 1)) {
2587 end = this.position;
2589 while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
2591 if (end - this.position > (maxLength / 2 - 1)) {
2598 snippet = this.buffer.slice(start, end);
2600 return common.repeat(' ', indent) + head + snippet + tail + '\n' +
2601 common.repeat(' ', indent + this.position - start + head.length) + '^';
2605 Mark.prototype.toString = function toString(compact) {
2606 var snippet, where = '';
2609 where += 'in "' + this.name + '" ';
2612 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
2615 snippet = this.getSnippet();
2618 where += ':\n' + snippet;
2626 module.exports = Mark;
2628 },{"./common":2}],7:[function(require,module,exports){
2631 /*eslint-disable max-len*/
2633 var common = require('./common');
2634 var YAMLException = require('./exception');
2635 var Type = require('./type');
2638 function compileList(schema, name, result) {
2641 schema.include.forEach(function (includedSchema) {
2642 result = compileList(includedSchema, name, result);
2645 schema[name].forEach(function (currentType) {
2646 result.forEach(function (previousType, previousIndex) {
2647 if (previousType.tag === currentType.tag) {
2648 exclude.push(previousIndex);
2652 result.push(currentType);
2655 return result.filter(function (type, index) {
2656 return exclude.indexOf(index) === -1;
2661 function compileMap(/* lists... */) {
2662 var result = {}, index, length;
2664 function collectType(type) {
2665 result[type.tag] = type;
2668 for (index = 0, length = arguments.length; index < length; index += 1) {
2669 arguments[index].forEach(collectType);
2676 function Schema(definition) {
2677 this.include = definition.include || [];
2678 this.implicit = definition.implicit || [];
2679 this.explicit = definition.explicit || [];
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.');
2687 this.compiledImplicit = compileList(this, 'implicit', []);
2688 this.compiledExplicit = compileList(this, 'explicit', []);
2689 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
2693 Schema.DEFAULT = null;
2696 Schema.create = function createSchema() {
2699 switch (arguments.length) {
2701 schemas = Schema.DEFAULT;
2702 types = arguments[0];
2706 schemas = arguments[0];
2707 types = arguments[1];
2711 throw new YAMLException('Wrong number of arguments for Schema.create function');
2714 schemas = common.toArray(schemas);
2715 types = common.toArray(types);
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.');
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.');
2732 module.exports = Schema;
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
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.
2745 var Schema = require('../schema');
2748 module.exports = new Schema({
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.
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.
2761 // Also this schema is used as default base schema at `Schema.create` function.
2767 var Schema = require('../schema');
2770 module.exports = Schema.DEFAULT = new Schema({
2772 require('./default_safe')
2775 require('../type/js/undefined'),
2776 require('../type/js/regexp'),
2777 require('../type/js/function')
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.
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/)
2792 var Schema = require('../schema');
2795 module.exports = new Schema({
2800 require('../type/timestamp'),
2801 require('../type/merge')
2804 require('../type/binary'),
2805 require('../type/omap'),
2806 require('../type/pairs'),
2807 require('../type/set')
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
2819 var Schema = require('../schema');
2822 module.exports = new Schema({
2824 require('../type/str'),
2825 require('../type/seq'),
2826 require('../type/map')
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
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.
2842 var Schema = require('../schema');
2845 module.exports = new Schema({
2847 require('./failsafe')
2850 require('../type/null'),
2851 require('../type/bool'),
2852 require('../type/int'),
2853 require('../type/float')
2857 },{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){
2860 var YAMLException = require('./exception');
2862 var TYPE_CONSTRUCTOR_OPTIONS = [
2873 var YAML_NODE_KINDS = [
2879 function compileStyleAliases(map) {
2883 Object.keys(map).forEach(function (style) {
2884 map[style].forEach(function (alias) {
2885 result[String(alias)] = style;
2893 function Type(tag, options) {
2894 options = options || {};
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.');
2902 // TODO: Add tag format check.
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);
2913 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
2914 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
2918 module.exports = Type;
2920 },{"./exception":4}],14:[function(require,module,exports){
2923 /*eslint-disable no-bitwise*/
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');
2931 // [ 64, 65, 66 ] -> [ padding, CR, LF ]
2932 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
2935 function resolveYamlBinary(data) {
2936 if (data === null) return false;
2938 var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
2940 // Convert one by one.
2941 for (idx = 0; idx < max; idx++) {
2942 code = map.indexOf(data.charAt(idx));
2945 if (code > 64) continue;
2947 // Fail on illegal characters
2948 if (code < 0) return false;
2953 // If there are any bits left, source was corrupted
2954 return (bitlen % 8) === 0;
2957 function constructYamlBinary(data) {
2959 input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
2965 // Collect by 6*4 bits (3 bytes)
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);
2974 bits = (bits << 6) | map.indexOf(input.charAt(idx));
2979 tailbits = (max % 4) * 6;
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);
2992 // Wrap into Buffer for NodeJS and leave Array for browser
2993 if (NodeBuffer) return new NodeBuffer(result);
2998 function representYamlBinary(object /*, style*/) {
2999 var result = '', bits = 0, idx, tail,
3000 max = object.length,
3003 // Convert every three bytes to 4 ASCII characters.
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];
3013 bits = (bits << 8) + object[idx];
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];
3030 } else if (tail === 1) {
3031 result += map[(bits >> 2) & 0x3F];
3032 result += map[(bits << 4) & 0x3F];
3040 function isBinary(object) {
3041 return NodeBuffer && NodeBuffer.isBuffer(object);
3044 module.exports = new Type('tag:yaml.org,2002:binary', {
3046 resolve: resolveYamlBinary,
3047 construct: constructYamlBinary,
3048 predicate: isBinary,
3049 represent: representYamlBinary
3052 },{"../type":13,"buffer":30}],15:[function(require,module,exports){
3055 var Type = require('../type');
3057 function resolveYamlBoolean(data) {
3058 if (data === null) return false;
3060 var max = data.length;
3062 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
3063 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
3066 function constructYamlBoolean(data) {
3067 return data === 'true' ||
3072 function isBoolean(object) {
3073 return Object.prototype.toString.call(object) === '[object Boolean]';
3076 module.exports = new Type('tag:yaml.org,2002:bool', {
3078 resolve: resolveYamlBoolean,
3079 construct: constructYamlBoolean,
3080 predicate: isBoolean,
3082 lowercase: function (object) { return object ? 'true' : 'false'; },
3083 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
3084 camelcase: function (object) { return object ? 'True' : 'False'; }
3086 defaultStyle: 'lowercase'
3089 },{"../type":13}],16:[function(require,module,exports){
3092 var common = require('../common');
3093 var Type = require('../type');
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))$');
3102 function resolveYamlFloat(data) {
3103 if (data === null) return false;
3105 if (!YAML_FLOAT_PATTERN.test(data)) return false;
3110 function constructYamlFloat(data) {
3111 var value, sign, base, digits;
3113 value = data.replace(/_/g, '').toLowerCase();
3114 sign = value[0] === '-' ? -1 : 1;
3117 if ('+-'.indexOf(value[0]) >= 0) {
3118 value = value.slice(1);
3121 if (value === '.inf') {
3122 return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
3124 } else if (value === '.nan') {
3127 } else if (value.indexOf(':') >= 0) {
3128 value.split(':').forEach(function (v) {
3129 digits.unshift(parseFloat(v, 10));
3135 digits.forEach(function (d) {
3140 return sign * value;
3143 return sign * parseFloat(value, 10);
3147 var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
3149 function representYamlFloat(object, style) {
3152 if (isNaN(object)) {
3154 case 'lowercase': return '.nan';
3155 case 'uppercase': return '.NAN';
3156 case 'camelcase': return '.NaN';
3158 } else if (Number.POSITIVE_INFINITY === object) {
3160 case 'lowercase': return '.inf';
3161 case 'uppercase': return '.INF';
3162 case 'camelcase': return '.Inf';
3164 } else if (Number.NEGATIVE_INFINITY === object) {
3166 case 'lowercase': return '-.inf';
3167 case 'uppercase': return '-.INF';
3168 case 'camelcase': return '-.Inf';
3170 } else if (common.isNegativeZero(object)) {
3174 res = object.toString(10);
3176 // JS stringifier can build scientific format without dots: 5e-100,
3177 // while YAML requres dot: 5.e-100. Fix it with simple hack
3179 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
3182 function isFloat(object) {
3183 return (Object.prototype.toString.call(object) === '[object Number]') &&
3184 (object % 1 !== 0 || common.isNegativeZero(object));
3187 module.exports = new Type('tag:yaml.org,2002:float', {
3189 resolve: resolveYamlFloat,
3190 construct: constructYamlFloat,
3192 represent: representYamlFloat,
3193 defaultStyle: 'lowercase'
3196 },{"../common":2,"../type":13}],17:[function(require,module,exports){
3199 var common = require('../common');
3200 var Type = require('../type');
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 */));
3208 function isOctCode(c) {
3209 return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
3212 function isDecCode(c) {
3213 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
3216 function resolveYamlInteger(data) {
3217 if (data === null) return false;
3219 var max = data.length,
3224 if (!max) return false;
3229 if (ch === '-' || ch === '+') {
3235 if (index + 1 === max) return true;
3238 // base 2, base 8, base 16
3244 for (; index < max; index++) {
3246 if (ch === '_') continue;
3247 if (ch !== '0' && ch !== '1') return false;
3258 for (; index < max; index++) {
3260 if (ch === '_') continue;
3261 if (!isHexCode(data.charCodeAt(index))) return false;
3268 for (; index < max; index++) {
3270 if (ch === '_') continue;
3271 if (!isOctCode(data.charCodeAt(index))) return false;
3277 // base 10 (except 0) or base 60
3279 for (; index < max; index++) {
3281 if (ch === '_') continue;
3282 if (ch === ':') break;
3283 if (!isDecCode(data.charCodeAt(index))) {
3289 if (!hasDigits) return false;
3291 // if !base60 - done;
3292 if (ch !== ':') return true;
3294 // base60 almost not used, no needs to optimize
3295 return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
3298 function constructYamlInteger(data) {
3299 var value = data, sign = 1, ch, base, digits = [];
3301 if (value.indexOf('_') !== -1) {
3302 value = value.replace(/_/g, '');
3307 if (ch === '-' || ch === '+') {
3308 if (ch === '-') sign = -1;
3309 value = value.slice(1);
3313 if (value === '0') return 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);
3321 if (value.indexOf(':') !== -1) {
3322 value.split(':').forEach(function (v) {
3323 digits.unshift(parseInt(v, 10));
3329 digits.forEach(function (d) {
3330 value += (d * base);
3334 return sign * value;
3338 return sign * parseInt(value, 10);
3341 function isInteger(object) {
3342 return (Object.prototype.toString.call(object)) === '[object Number]' &&
3343 (object % 1 === 0 && !common.isNegativeZero(object));
3346 module.exports = new Type('tag:yaml.org,2002:int', {
3348 resolve: resolveYamlInteger,
3349 construct: constructYamlInteger,
3350 predicate: isInteger,
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(); }
3357 defaultStyle: 'decimal',
3359 binary: [ 2, 'bin' ],
3360 octal: [ 8, 'oct' ],
3361 decimal: [ 10, 'dec' ],
3362 hexadecimal: [ 16, 'hex' ]
3366 },{"../common":2,"../type":13}],18:[function(require,module,exports){
3371 // Browserified version does not have esprima
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.
3379 // workaround to exclude package from browserify list.
3380 var _require = require;
3381 esprima = _require('esprima');
3384 if (typeof window !== 'undefined') esprima = window.esprima;
3387 var Type = require('../../type');
3389 function resolveJavascriptFunction(data) {
3390 if (data === null) return false;
3393 var source = '(' + data + ')',
3394 ast = esprima.parse(source, { range: true });
3396 if (ast.type !== 'Program' ||
3397 ast.body.length !== 1 ||
3398 ast.body[0].type !== 'ExpressionStatement' ||
3399 ast.body[0].expression.type !== 'FunctionExpression') {
3409 function constructJavascriptFunction(data) {
3410 /*jslint evil:true*/
3412 var source = '(' + data + ')',
3413 ast = esprima.parse(source, { range: true }),
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');
3424 ast.body[0].expression.params.forEach(function (param) {
3425 params.push(param.name);
3428 body = ast.body[0].expression.body.range;
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));
3436 function representJavascriptFunction(object /*, style*/) {
3437 return object.toString();
3440 function isFunction(object) {
3441 return Object.prototype.toString.call(object) === '[object Function]';
3444 module.exports = new Type('tag:yaml.org,2002:js/function', {
3446 resolve: resolveJavascriptFunction,
3447 construct: constructJavascriptFunction,
3448 predicate: isFunction,
3449 represent: representJavascriptFunction
3452 },{"../../type":13}],19:[function(require,module,exports){
3455 var Type = require('../../type');
3457 function resolveJavascriptRegExp(data) {
3458 if (data === null) return false;
3459 if (data.length === 0) return false;
3462 tail = /\/([gim]*)$/.exec(data),
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];
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;
3478 function constructJavascriptRegExp(data) {
3480 tail = /\/([gim]*)$/.exec(data),
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);
3489 return new RegExp(regexp, modifiers);
3492 function representJavascriptRegExp(object /*, style*/) {
3493 var result = '/' + object.source + '/';
3495 if (object.global) result += 'g';
3496 if (object.multiline) result += 'm';
3497 if (object.ignoreCase) result += 'i';
3502 function isRegExp(object) {
3503 return Object.prototype.toString.call(object) === '[object RegExp]';
3506 module.exports = new Type('tag:yaml.org,2002:js/regexp', {
3508 resolve: resolveJavascriptRegExp,
3509 construct: constructJavascriptRegExp,
3510 predicate: isRegExp,
3511 represent: representJavascriptRegExp
3514 },{"../../type":13}],20:[function(require,module,exports){
3517 var Type = require('../../type');
3519 function resolveJavascriptUndefined() {
3523 function constructJavascriptUndefined() {
3524 /*eslint-disable no-undefined*/
3528 function representJavascriptUndefined() {
3532 function isUndefined(object) {
3533 return typeof object === 'undefined';
3536 module.exports = new Type('tag:yaml.org,2002:js/undefined', {
3538 resolve: resolveJavascriptUndefined,
3539 construct: constructJavascriptUndefined,
3540 predicate: isUndefined,
3541 represent: representJavascriptUndefined
3544 },{"../../type":13}],21:[function(require,module,exports){
3547 var Type = require('../type');
3549 module.exports = new Type('tag:yaml.org,2002:map', {
3551 construct: function (data) { return data !== null ? data : {}; }
3554 },{"../type":13}],22:[function(require,module,exports){
3557 var Type = require('../type');
3559 function resolveYamlMerge(data) {
3560 return data === '<<' || data === null;
3563 module.exports = new Type('tag:yaml.org,2002:merge', {
3565 resolve: resolveYamlMerge
3568 },{"../type":13}],23:[function(require,module,exports){
3571 var Type = require('../type');
3573 function resolveYamlNull(data) {
3574 if (data === null) return true;
3576 var max = data.length;
3578 return (max === 1 && data === '~') ||
3579 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
3582 function constructYamlNull() {
3586 function isNull(object) {
3587 return object === null;
3590 module.exports = new Type('tag:yaml.org,2002:null', {
3592 resolve: resolveYamlNull,
3593 construct: constructYamlNull,
3596 canonical: function () { return '~'; },
3597 lowercase: function () { return 'null'; },
3598 uppercase: function () { return 'NULL'; },
3599 camelcase: function () { return 'Null'; }
3601 defaultStyle: 'lowercase'
3604 },{"../type":13}],24:[function(require,module,exports){
3607 var Type = require('../type');
3609 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3610 var _toString = Object.prototype.toString;
3612 function resolveYamlOmap(data) {
3613 if (data === null) return true;
3615 var objectKeys = [], index, length, pair, pairKey, pairHasKey,
3618 for (index = 0, length = object.length; index < length; index += 1) {
3619 pair = object[index];
3622 if (_toString.call(pair) !== '[object Object]') return false;
3624 for (pairKey in pair) {
3625 if (_hasOwnProperty.call(pair, pairKey)) {
3626 if (!pairHasKey) pairHasKey = true;
3631 if (!pairHasKey) return false;
3633 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
3640 function constructYamlOmap(data) {
3641 return data !== null ? data : [];
3644 module.exports = new Type('tag:yaml.org,2002:omap', {
3646 resolve: resolveYamlOmap,
3647 construct: constructYamlOmap
3650 },{"../type":13}],25:[function(require,module,exports){
3653 var Type = require('../type');
3655 var _toString = Object.prototype.toString;
3657 function resolveYamlPairs(data) {
3658 if (data === null) return true;
3660 var index, length, pair, keys, result,
3663 result = new Array(object.length);
3665 for (index = 0, length = object.length; index < length; index += 1) {
3666 pair = object[index];
3668 if (_toString.call(pair) !== '[object Object]') return false;
3670 keys = Object.keys(pair);
3672 if (keys.length !== 1) return false;
3674 result[index] = [ keys[0], pair[keys[0]] ];
3680 function constructYamlPairs(data) {
3681 if (data === null) return [];
3683 var index, length, pair, keys, result,
3686 result = new Array(object.length);
3688 for (index = 0, length = object.length; index < length; index += 1) {
3689 pair = object[index];
3691 keys = Object.keys(pair);
3693 result[index] = [ keys[0], pair[keys[0]] ];
3699 module.exports = new Type('tag:yaml.org,2002:pairs', {
3701 resolve: resolveYamlPairs,
3702 construct: constructYamlPairs
3705 },{"../type":13}],26:[function(require,module,exports){
3708 var Type = require('../type');
3710 module.exports = new Type('tag:yaml.org,2002:seq', {
3712 construct: function (data) { return data !== null ? data : []; }
3715 },{"../type":13}],27:[function(require,module,exports){
3718 var Type = require('../type');
3720 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3722 function resolveYamlSet(data) {
3723 if (data === null) return true;
3725 var key, object = data;
3727 for (key in object) {
3728 if (_hasOwnProperty.call(object, key)) {
3729 if (object[key] !== null) return false;
3736 function constructYamlSet(data) {
3737 return data !== null ? data : {};
3740 module.exports = new Type('tag:yaml.org,2002:set', {
3742 resolve: resolveYamlSet,
3743 construct: constructYamlSet
3746 },{"../type":13}],28:[function(require,module,exports){
3749 var Type = require('../type');
3751 module.exports = new Type('tag:yaml.org,2002:str', {
3753 construct: function (data) { return data !== null ? data : ''; }
3756 },{"../type":13}],29:[function(require,module,exports){
3759 var Type = require('../type');
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
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
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;
3785 function constructYamlTimestamp(data) {
3786 var match, year, month, day, hour, minute, second, fraction = 0,
3787 delta = null, tz_hour, tz_minute, date;
3789 match = YAML_DATE_REGEXP.exec(data);
3790 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
3792 if (match === null) throw new Error('Date resolve error');
3794 // match: [1] year [2] month [3] day
3797 month = +(match[2]) - 1; // JS month starts with 0
3800 if (!match[4]) { // no hour
3801 return new Date(Date.UTC(year, month, day));
3804 // match: [4] hour [5] minute [6] second [7] fraction
3807 minute = +(match[5]);
3808 second = +(match[6]);
3811 fraction = match[7].slice(0, 3);
3812 while (fraction.length < 3) { // milli-seconds
3815 fraction = +fraction;
3818 // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
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;
3827 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
3829 if (delta) date.setTime(date.getTime() - delta);
3834 function representYamlTimestamp(object /*, style*/) {
3835 return object.toISOString();
3838 module.exports = new Type('tag:yaml.org,2002:timestamp', {
3840 resolve: resolveYamlTimestamp,
3841 construct: constructYamlTimestamp,
3843 represent: representYamlTimestamp
3846 },{"../type":13}],30:[function(require,module,exports){
3848 },{}],"/":[function(require,module,exports){
3852 var yaml = require('./lib/js-yaml.js');
3855 module.exports = yaml;
3857 },{"./lib/js-yaml.js":1}]},{},[])("/")