1 /* js-yaml 3.14.0 https://github.com/nodeca/js-yaml */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
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_EQUALS = 0x3D; /* = */
131 var CHAR_GREATER_THAN = 0x3E; /* > */
132 var CHAR_QUESTION = 0x3F; /* ? */
133 var CHAR_COMMERCIAL_AT = 0x40; /* @ */
134 var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
135 var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
136 var CHAR_GRAVE_ACCENT = 0x60; /* ` */
137 var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
138 var CHAR_VERTICAL_LINE = 0x7C; /* | */
139 var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
141 var ESCAPE_SEQUENCES = {};
143 ESCAPE_SEQUENCES[0x00] = '\\0';
144 ESCAPE_SEQUENCES[0x07] = '\\a';
145 ESCAPE_SEQUENCES[0x08] = '\\b';
146 ESCAPE_SEQUENCES[0x09] = '\\t';
147 ESCAPE_SEQUENCES[0x0A] = '\\n';
148 ESCAPE_SEQUENCES[0x0B] = '\\v';
149 ESCAPE_SEQUENCES[0x0C] = '\\f';
150 ESCAPE_SEQUENCES[0x0D] = '\\r';
151 ESCAPE_SEQUENCES[0x1B] = '\\e';
152 ESCAPE_SEQUENCES[0x22] = '\\"';
153 ESCAPE_SEQUENCES[0x5C] = '\\\\';
154 ESCAPE_SEQUENCES[0x85] = '\\N';
155 ESCAPE_SEQUENCES[0xA0] = '\\_';
156 ESCAPE_SEQUENCES[0x2028] = '\\L';
157 ESCAPE_SEQUENCES[0x2029] = '\\P';
159 var DEPRECATED_BOOLEANS_SYNTAX = [
160 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
161 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
164 function compileStyleMap(schema, map) {
165 var result, keys, index, length, tag, style, type;
167 if (map === null) return {};
170 keys = Object.keys(map);
172 for (index = 0, length = keys.length; index < length; index += 1) {
174 style = String(map[tag]);
176 if (tag.slice(0, 2) === '!!') {
177 tag = 'tag:yaml.org,2002:' + tag.slice(2);
179 type = schema.compiledTypeMap['fallback'][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.noArrayIndent = options['noArrayIndent'] || false;
216 this.skipInvalid = options['skipInvalid'] || false;
217 this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
218 this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
219 this.sortKeys = options['sortKeys'] || false;
220 this.lineWidth = options['lineWidth'] || 80;
221 this.noRefs = options['noRefs'] || false;
222 this.noCompatMode = options['noCompatMode'] || false;
223 this.condenseFlow = options['condenseFlow'] || false;
225 this.implicitTypes = this.schema.compiledImplicit;
226 this.explicitTypes = this.schema.compiledExplicit;
231 this.duplicates = [];
232 this.usedDuplicates = null;
235 // Indents every line in a string. Empty lines (\n only) are not indented.
236 function indentString(string, spaces) {
237 var ind = common.repeat(' ', spaces),
242 length = string.length;
244 while (position < length) {
245 next = string.indexOf('\n', position);
247 line = string.slice(position);
250 line = string.slice(position, next + 1);
254 if (line.length && line !== '\n') result += ind;
262 function generateNextLine(state, level) {
263 return '\n' + common.repeat(' ', state.indent * level);
266 function testImplicitResolving(state, str) {
267 var index, length, type;
269 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
270 type = state.implicitTypes[index];
272 if (type.resolve(str)) {
280 // [33] s-white ::= s-space | s-tab
281 function isWhitespace(c) {
282 return c === CHAR_SPACE || c === CHAR_TAB;
285 // Returns true if the character can be printed without escaping.
286 // From YAML 1.2: "any allowed characters known to be non-printable
287 // should also be escaped. [However,] This isn’t mandatory"
288 // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
289 function isPrintable(c) {
290 return (0x00020 <= c && c <= 0x00007E)
291 || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
292 || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
293 || (0x10000 <= c && c <= 0x10FFFF);
296 // [34] ns-char ::= nb-char - s-white
297 // [27] nb-char ::= c-printable - b-char - c-byte-order-mark
298 // [26] b-char ::= b-line-feed | b-carriage-return
299 // [24] b-line-feed ::= #xA /* LF */
300 // [25] b-carriage-return ::= #xD /* CR */
301 // [3] c-byte-order-mark ::= #xFEFF
302 function isNsChar(c) {
303 return isPrintable(c) && !isWhitespace(c)
307 && c !== CHAR_CARRIAGE_RETURN
308 && c !== CHAR_LINE_FEED;
311 // Simplified test for values allowed after the first character in plain style.
312 function isPlainSafe(c, prev) {
313 // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
314 // where nb-char ::= c-printable - b-char - c-byte-order-mark.
315 return isPrintable(c) && c !== 0xFEFF
316 // - c-flow-indicator
318 && c !== CHAR_LEFT_SQUARE_BRACKET
319 && c !== CHAR_RIGHT_SQUARE_BRACKET
320 && c !== CHAR_LEFT_CURLY_BRACKET
321 && c !== CHAR_RIGHT_CURLY_BRACKET
323 // /* An ns-char preceding */ "#"
325 && ((c !== CHAR_SHARP) || (prev && isNsChar(prev)));
328 // Simplified test for values allowed as the first character in plain style.
329 function isPlainSafeFirst(c) {
330 // Uses a subset of ns-char - c-indicator
331 // where ns-char = nb-char - s-white.
332 return isPrintable(c) && c !== 0xFEFF
333 && !isWhitespace(c) // - s-white
334 // - (c-indicator ::=
335 // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
337 && c !== CHAR_QUESTION
340 && c !== CHAR_LEFT_SQUARE_BRACKET
341 && c !== CHAR_RIGHT_SQUARE_BRACKET
342 && c !== CHAR_LEFT_CURLY_BRACKET
343 && c !== CHAR_RIGHT_CURLY_BRACKET
344 // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
346 && c !== CHAR_AMPERSAND
347 && c !== CHAR_ASTERISK
348 && c !== CHAR_EXCLAMATION
349 && c !== CHAR_VERTICAL_LINE
351 && c !== CHAR_GREATER_THAN
352 && c !== CHAR_SINGLE_QUOTE
353 && c !== CHAR_DOUBLE_QUOTE
354 // | “%” | “@” | “`”)
355 && c !== CHAR_PERCENT
356 && c !== CHAR_COMMERCIAL_AT
357 && c !== CHAR_GRAVE_ACCENT;
360 // Determines whether block indentation indicator is required.
361 function needIndentIndicator(string) {
362 var leadingSpaceRe = /^\n* /;
363 return leadingSpaceRe.test(string);
372 // Determines which scalar styles are possible and returns the preferred style.
373 // lineWidth = -1 => no limit.
374 // Pre-conditions: str.length > 0.
376 // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
377 // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
378 // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
379 function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
382 var hasLineBreak = false;
383 var hasFoldableLine = false; // only checked if shouldTrackWidth
384 var shouldTrackWidth = lineWidth !== -1;
385 var previousLineBreak = -1; // count the first line correctly
386 var plain = isPlainSafeFirst(string.charCodeAt(0))
387 && !isWhitespace(string.charCodeAt(string.length - 1));
389 if (singleLineOnly) {
390 // Case: no block styles.
391 // Check for disallowed characters to rule out plain and single.
392 for (i = 0; i < string.length; i++) {
393 char = string.charCodeAt(i);
394 if (!isPrintable(char)) {
397 prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
398 plain = plain && isPlainSafe(char, prev_char);
401 // Case: block styles permitted.
402 for (i = 0; i < string.length; i++) {
403 char = string.charCodeAt(i);
404 if (char === CHAR_LINE_FEED) {
406 // Check if any line can be folded.
407 if (shouldTrackWidth) {
408 hasFoldableLine = hasFoldableLine ||
409 // Foldable line = too long, and not more-indented.
410 (i - previousLineBreak - 1 > lineWidth &&
411 string[previousLineBreak + 1] !== ' ');
412 previousLineBreak = i;
414 } else if (!isPrintable(char)) {
417 prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
418 plain = plain && isPlainSafe(char, prev_char);
420 // in case the end is missing a \n
421 hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
422 (i - previousLineBreak - 1 > lineWidth &&
423 string[previousLineBreak + 1] !== ' '));
425 // Although every style can represent \n without escaping, prefer block styles
426 // for multiline, since they're more readable and they don't add empty lines.
427 // Also prefer folding a super-long line.
428 if (!hasLineBreak && !hasFoldableLine) {
429 // Strings interpretable as another type have to be quoted;
430 // e.g. the string 'true' vs. the boolean true.
431 return plain && !testAmbiguousType(string)
432 ? STYLE_PLAIN : STYLE_SINGLE;
434 // Edge case: block indentation indicator can only have one digit.
435 if (indentPerLevel > 9 && needIndentIndicator(string)) {
438 // At this point we know block styles are valid.
439 // Prefer literal style unless we want to fold.
440 return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
443 // Note: line breaking/folding is implemented for only the folded style.
444 // NB. We drop the last trailing newline (if any) of a returned block scalar
445 // since the dumper adds its own newline. This always works:
446 // • No ending newline => unaffected; already using strip "-" chomping.
447 // • Ending newline => removed then restored.
448 // Importantly, this keeps the "+" chomp indicator from gaining an extra line.
449 function writeScalar(state, string, level, iskey) {
450 state.dump = (function () {
451 if (string.length === 0) {
454 if (!state.noCompatMode &&
455 DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
456 return "'" + string + "'";
459 var indent = state.indent * Math.max(1, level); // no 0-indent scalars
460 // As indentation gets deeper, let the width decrease monotonically
461 // to the lower bound min(state.lineWidth, 40).
462 // Note that this implies
463 // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
464 // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
465 // This behaves better than a constant minimum width which disallows narrower options,
466 // or an indent threshold which causes the width to suddenly increase.
467 var lineWidth = state.lineWidth === -1
468 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
470 // Without knowing if keys are implicit/explicit, assume implicit for safety.
471 var singleLineOnly = iskey
472 // No block styles in flow mode.
473 || (state.flowLevel > -1 && level >= state.flowLevel);
474 function testAmbiguity(string) {
475 return testImplicitResolving(state, string);
478 switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
482 return "'" + string.replace(/'/g, "''") + "'";
484 return '|' + blockHeader(string, state.indent)
485 + dropEndingNewline(indentString(string, indent));
487 return '>' + blockHeader(string, state.indent)
488 + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
490 return '"' + escapeString(string, lineWidth) + '"';
492 throw new YAMLException('impossible error: invalid scalar style');
497 // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
498 function blockHeader(string, indentPerLevel) {
499 var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
501 // note the special case: the string '\n' counts as a "trailing" empty line.
502 var clip = string[string.length - 1] === '\n';
503 var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
504 var chomp = keep ? '+' : (clip ? '' : '-');
506 return indentIndicator + chomp + '\n';
509 // (See the note for writeScalar.)
510 function dropEndingNewline(string) {
511 return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
514 // Note: a long line without a suitable break point will exceed the width limit.
515 // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
516 function foldString(string, width) {
517 // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
518 // unless they're before or after a more-indented line, or at the very
519 // beginning or end, in which case $k$ maps to $k$.
520 // Therefore, parse each chunk as newline(s) followed by a content line.
521 var lineRe = /(\n+)([^\n]*)/g;
523 // first line (possibly an empty line)
524 var result = (function () {
525 var nextLF = string.indexOf('\n');
526 nextLF = nextLF !== -1 ? nextLF : string.length;
527 lineRe.lastIndex = nextLF;
528 return foldLine(string.slice(0, nextLF), width);
530 // If we haven't reached the first content line yet, don't add an extra \n.
531 var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
536 while ((match = lineRe.exec(string))) {
537 var prefix = match[1], line = match[2];
538 moreIndented = (line[0] === ' ');
540 + (!prevMoreIndented && !moreIndented && line !== ''
542 + foldLine(line, width);
543 prevMoreIndented = moreIndented;
549 // Greedy line breaking.
550 // Picks the longest line under the limit each time,
551 // otherwise settles for the shortest line over the limit.
552 // NB. More-indented lines *cannot* be folded, as that would add an extra \n.
553 function foldLine(line, width) {
554 if (line === '' || line[0] === ' ') return line;
556 // Since a more-indented line adds a \n, breaks can't be followed by a space.
557 var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
559 // start is an inclusive index. end, curr, and next are exclusive.
560 var start = 0, end, curr = 0, next = 0;
563 // Invariants: 0 <= start <= length-1.
564 // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
566 // A match implies length >= 2, so curr and next are <= length-2.
567 while ((match = breakRe.exec(line))) {
569 // maintain invariant: curr - start <= width
570 if (next - start > width) {
571 end = (curr > start) ? curr : next; // derive end <= length-2
572 result += '\n' + line.slice(start, end);
573 // skip the space that was output as \n
574 start = end + 1; // derive start <= length-1
579 // By the invariants, start <= length-1, so there is something left over.
580 // It is either the whole string or a part starting from non-whitespace.
582 // Insert a break if the remainder is too long and there is a break available.
583 if (line.length - start > width && curr > start) {
584 result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
586 result += line.slice(start);
589 return result.slice(1); // drop extra \n joiner
592 // Escapes a double-quoted string.
593 function escapeString(string) {
598 for (var i = 0; i < string.length; i++) {
599 char = string.charCodeAt(i);
600 // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
601 if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) {
602 nextChar = string.charCodeAt(i + 1);
603 if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) {
604 // Combine the surrogate pair and store it escaped.
605 result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
606 // Advance index one extra since we already used that char here.
610 escapeSeq = ESCAPE_SEQUENCES[char];
611 result += !escapeSeq && isPrintable(char)
613 : escapeSeq || encodeHex(char);
619 function writeFlowSequence(state, level, object) {
625 for (index = 0, length = object.length; index < length; index += 1) {
626 // Write only valid elements.
627 if (writeNode(state, level, object[index], false, false)) {
628 if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
629 _result += state.dump;
634 state.dump = '[' + _result + ']';
637 function writeBlockSequence(state, level, object, compact) {
643 for (index = 0, length = object.length; index < length; index += 1) {
644 // Write only valid elements.
645 if (writeNode(state, level + 1, object[index], true, true)) {
646 if (!compact || index !== 0) {
647 _result += generateNextLine(state, level);
650 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
656 _result += state.dump;
661 state.dump = _result || '[]'; // Empty sequence if no valid values.
664 function writeFlowMapping(state, level, object) {
667 objectKeyList = Object.keys(object),
674 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
677 if (index !== 0) pairBuffer += ', ';
679 if (state.condenseFlow) pairBuffer += '"';
681 objectKey = objectKeyList[index];
682 objectValue = object[objectKey];
684 if (!writeNode(state, level, objectKey, false, false)) {
685 continue; // Skip this pair because of invalid key;
688 if (state.dump.length > 1024) pairBuffer += '? ';
690 pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
692 if (!writeNode(state, level, objectValue, false, false)) {
693 continue; // Skip this pair because of invalid value.
696 pairBuffer += state.dump;
698 // Both key and value are valid.
699 _result += pairBuffer;
703 state.dump = '{' + _result + '}';
706 function writeBlockMapping(state, level, object, compact) {
709 objectKeyList = Object.keys(object),
717 // Allow sorting keys so that the output file is deterministic
718 if (state.sortKeys === true) {
720 objectKeyList.sort();
721 } else if (typeof state.sortKeys === 'function') {
722 // Custom sort function
723 objectKeyList.sort(state.sortKeys);
724 } else if (state.sortKeys) {
725 // Something is wrong
726 throw new YAMLException('sortKeys must be a boolean or a function');
729 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
732 if (!compact || index !== 0) {
733 pairBuffer += generateNextLine(state, level);
736 objectKey = objectKeyList[index];
737 objectValue = object[objectKey];
739 if (!writeNode(state, level + 1, objectKey, true, true, true)) {
740 continue; // Skip this pair because of invalid key.
743 explicitPair = (state.tag !== null && state.tag !== '?') ||
744 (state.dump && state.dump.length > 1024);
747 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
754 pairBuffer += state.dump;
757 pairBuffer += generateNextLine(state, level);
760 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
761 continue; // Skip this pair because of invalid value.
764 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
770 pairBuffer += state.dump;
772 // Both key and value are valid.
773 _result += pairBuffer;
777 state.dump = _result || '{}'; // Empty mapping if no valid pairs.
780 function detectType(state, object, explicit) {
781 var _result, typeList, index, length, type, style;
783 typeList = explicit ? state.explicitTypes : state.implicitTypes;
785 for (index = 0, length = typeList.length; index < length; index += 1) {
786 type = typeList[index];
788 if ((type.instanceOf || type.predicate) &&
789 (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
790 (!type.predicate || type.predicate(object))) {
792 state.tag = explicit ? type.tag : '?';
794 if (type.represent) {
795 style = state.styleMap[type.tag] || type.defaultStyle;
797 if (_toString.call(type.represent) === '[object Function]') {
798 _result = type.represent(object, style);
799 } else if (_hasOwnProperty.call(type.represent, style)) {
800 _result = type.represent[style](object, style);
802 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
805 state.dump = _result;
815 // Serializes `object` and writes it to global `result`.
816 // Returns true on success, or false on invalid object.
818 function writeNode(state, level, object, block, compact, iskey) {
822 if (!detectType(state, object, false)) {
823 detectType(state, object, true);
826 var type = _toString.call(state.dump);
829 block = (state.flowLevel < 0 || state.flowLevel > level);
832 var objectOrArray = type === '[object Object]' || type === '[object Array]',
837 duplicateIndex = state.duplicates.indexOf(object);
838 duplicate = duplicateIndex !== -1;
841 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
845 if (duplicate && state.usedDuplicates[duplicateIndex]) {
846 state.dump = '*ref_' + duplicateIndex;
848 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
849 state.usedDuplicates[duplicateIndex] = true;
851 if (type === '[object Object]') {
852 if (block && (Object.keys(state.dump).length !== 0)) {
853 writeBlockMapping(state, level, state.dump, compact);
855 state.dump = '&ref_' + duplicateIndex + state.dump;
858 writeFlowMapping(state, level, state.dump);
860 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
863 } else if (type === '[object Array]') {
864 var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level;
865 if (block && (state.dump.length !== 0)) {
866 writeBlockSequence(state, arrayLevel, state.dump, compact);
868 state.dump = '&ref_' + duplicateIndex + state.dump;
871 writeFlowSequence(state, arrayLevel, state.dump);
873 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
876 } else if (type === '[object String]') {
877 if (state.tag !== '?') {
878 writeScalar(state, state.dump, level, iskey);
881 if (state.skipInvalid) return false;
882 throw new YAMLException('unacceptable kind of an object to dump ' + type);
885 if (state.tag !== null && state.tag !== '?') {
886 state.dump = '!<' + state.tag + '> ' + state.dump;
893 function getDuplicateReferences(object, state) {
895 duplicatesIndexes = [],
899 inspectNode(object, objects, duplicatesIndexes);
901 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
902 state.duplicates.push(objects[duplicatesIndexes[index]]);
904 state.usedDuplicates = new Array(length);
907 function inspectNode(object, objects, duplicatesIndexes) {
912 if (object !== null && typeof object === 'object') {
913 index = objects.indexOf(object);
915 if (duplicatesIndexes.indexOf(index) === -1) {
916 duplicatesIndexes.push(index);
919 objects.push(object);
921 if (Array.isArray(object)) {
922 for (index = 0, length = object.length; index < length; index += 1) {
923 inspectNode(object[index], objects, duplicatesIndexes);
926 objectKeyList = Object.keys(object);
928 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
929 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
936 function dump(input, options) {
937 options = options || {};
939 var state = new State(options);
941 if (!state.noRefs) getDuplicateReferences(input, state);
943 if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
948 function safeDump(input, options) {
949 return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
952 module.exports.dump = dump;
953 module.exports.safeDump = safeDump;
955 },{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){
956 // YAML error class. http://stackoverflow.com/questions/8458984
960 function YAMLException(reason, mark) {
964 this.name = 'YAMLException';
965 this.reason = reason;
967 this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
969 // Include stack trace in error object
970 if (Error.captureStackTrace) {
972 Error.captureStackTrace(this, this.constructor);
974 // FF, IE 10+ and Safari 6+. Fallback for others
975 this.stack = (new Error()).stack || '';
980 // Inherit from Error
981 YAMLException.prototype = Object.create(Error.prototype);
982 YAMLException.prototype.constructor = YAMLException;
985 YAMLException.prototype.toString = function toString(compact) {
986 var result = this.name + ': ';
988 result += this.reason || '(unknown reason)';
990 if (!compact && this.mark) {
991 result += ' ' + this.mark.toString();
998 module.exports = YAMLException;
1000 },{}],5:[function(require,module,exports){
1003 /*eslint-disable max-len,no-use-before-define*/
1005 var common = require('./common');
1006 var YAMLException = require('./exception');
1007 var Mark = require('./mark');
1008 var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
1009 var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
1012 var _hasOwnProperty = Object.prototype.hasOwnProperty;
1015 var CONTEXT_FLOW_IN = 1;
1016 var CONTEXT_FLOW_OUT = 2;
1017 var CONTEXT_BLOCK_IN = 3;
1018 var CONTEXT_BLOCK_OUT = 4;
1021 var CHOMPING_CLIP = 1;
1022 var CHOMPING_STRIP = 2;
1023 var CHOMPING_KEEP = 3;
1026 var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1027 var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1028 var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
1029 var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
1030 var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1033 function _class(obj) { return Object.prototype.toString.call(obj); }
1035 function is_EOL(c) {
1036 return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
1039 function is_WHITE_SPACE(c) {
1040 return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
1043 function is_WS_OR_EOL(c) {
1044 return (c === 0x09/* Tab */) ||
1045 (c === 0x20/* Space */) ||
1046 (c === 0x0A/* LF */) ||
1047 (c === 0x0D/* CR */);
1050 function is_FLOW_INDICATOR(c) {
1051 return c === 0x2C/* , */ ||
1052 c === 0x5B/* [ */ ||
1053 c === 0x5D/* ] */ ||
1054 c === 0x7B/* { */ ||
1058 function fromHexCode(c) {
1061 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1065 /*eslint-disable no-bitwise*/
1068 if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
1069 return lc - 0x61 + 10;
1075 function escapedHexLen(c) {
1076 if (c === 0x78/* x */) { return 2; }
1077 if (c === 0x75/* u */) { return 4; }
1078 if (c === 0x55/* U */) { return 8; }
1082 function fromDecimalCode(c) {
1083 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1090 function simpleEscapeSequence(c) {
1091 /* eslint-disable indent */
1092 return (c === 0x30/* 0 */) ? '\x00' :
1093 (c === 0x61/* a */) ? '\x07' :
1094 (c === 0x62/* b */) ? '\x08' :
1095 (c === 0x74/* t */) ? '\x09' :
1096 (c === 0x09/* Tab */) ? '\x09' :
1097 (c === 0x6E/* n */) ? '\x0A' :
1098 (c === 0x76/* v */) ? '\x0B' :
1099 (c === 0x66/* f */) ? '\x0C' :
1100 (c === 0x72/* r */) ? '\x0D' :
1101 (c === 0x65/* e */) ? '\x1B' :
1102 (c === 0x20/* Space */) ? ' ' :
1103 (c === 0x22/* " */) ? '\x22' :
1104 (c === 0x2F/* / */) ? '/' :
1105 (c === 0x5C/* \ */) ? '\x5C' :
1106 (c === 0x4E/* N */) ? '\x85' :
1107 (c === 0x5F/* _ */) ? '\xA0' :
1108 (c === 0x4C/* L */) ? '\u2028' :
1109 (c === 0x50/* P */) ? '\u2029' : '';
1112 function charFromCodepoint(c) {
1114 return String.fromCharCode(c);
1116 // Encode UTF-16 surrogate pair
1117 // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
1118 return String.fromCharCode(
1119 ((c - 0x010000) >> 10) + 0xD800,
1120 ((c - 0x010000) & 0x03FF) + 0xDC00
1124 var simpleEscapeCheck = new Array(256); // integer, for fast access
1125 var simpleEscapeMap = new Array(256);
1126 for (var i = 0; i < 256; i++) {
1127 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1128 simpleEscapeMap[i] = simpleEscapeSequence(i);
1132 function State(input, options) {
1135 this.filename = options['filename'] || null;
1136 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
1137 this.onWarning = options['onWarning'] || null;
1138 this.legacy = options['legacy'] || false;
1139 this.json = options['json'] || false;
1140 this.listener = options['listener'] || null;
1142 this.implicitTypes = this.schema.compiledImplicit;
1143 this.typeMap = this.schema.compiledTypeMap;
1145 this.length = input.length;
1149 this.lineIndent = 0;
1151 this.documents = [];
1155 this.checkLineBreaks;
1166 function generateError(state, message) {
1167 return new YAMLException(
1169 new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
1172 function throwError(state, message) {
1173 throw generateError(state, message);
1176 function throwWarning(state, message) {
1177 if (state.onWarning) {
1178 state.onWarning.call(null, generateError(state, message));
1183 var directiveHandlers = {
1185 YAML: function handleYamlDirective(state, name, args) {
1187 var match, major, minor;
1189 if (state.version !== null) {
1190 throwError(state, 'duplication of %YAML directive');
1193 if (args.length !== 1) {
1194 throwError(state, 'YAML directive accepts exactly one argument');
1197 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1199 if (match === null) {
1200 throwError(state, 'ill-formed argument of the YAML directive');
1203 major = parseInt(match[1], 10);
1204 minor = parseInt(match[2], 10);
1207 throwError(state, 'unacceptable YAML version of the document');
1210 state.version = args[0];
1211 state.checkLineBreaks = (minor < 2);
1213 if (minor !== 1 && minor !== 2) {
1214 throwWarning(state, 'unsupported YAML version of the document');
1218 TAG: function handleTagDirective(state, name, args) {
1222 if (args.length !== 2) {
1223 throwError(state, 'TAG directive accepts exactly two arguments');
1229 if (!PATTERN_TAG_HANDLE.test(handle)) {
1230 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
1233 if (_hasOwnProperty.call(state.tagMap, handle)) {
1234 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1237 if (!PATTERN_TAG_URI.test(prefix)) {
1238 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
1241 state.tagMap[handle] = prefix;
1246 function captureSegment(state, start, end, checkJson) {
1247 var _position, _length, _character, _result;
1250 _result = state.input.slice(start, end);
1253 for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1254 _character = _result.charCodeAt(_position);
1255 if (!(_character === 0x09 ||
1256 (0x20 <= _character && _character <= 0x10FFFF))) {
1257 throwError(state, 'expected valid JSON character');
1260 } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1261 throwError(state, 'the stream contains non-printable characters');
1264 state.result += _result;
1268 function mergeMappings(state, destination, source, overridableKeys) {
1269 var sourceKeys, key, index, quantity;
1271 if (!common.isObject(source)) {
1272 throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
1275 sourceKeys = Object.keys(source);
1277 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1278 key = sourceKeys[index];
1280 if (!_hasOwnProperty.call(destination, key)) {
1281 destination[key] = source[key];
1282 overridableKeys[key] = true;
1287 function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
1288 var index, quantity;
1290 // The output is a plain object here, so keys can only be strings.
1291 // We need to convert keyNode to a string, but doing so can hang the process
1292 // (deeply nested arrays that explode exponentially using aliases).
1293 if (Array.isArray(keyNode)) {
1294 keyNode = Array.prototype.slice.call(keyNode);
1296 for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1297 if (Array.isArray(keyNode[index])) {
1298 throwError(state, 'nested arrays are not supported inside keys');
1301 if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
1302 keyNode[index] = '[object Object]';
1307 // Avoid code execution in load() via toString property
1308 // (still use its own toString for arrays, timestamps,
1309 // and whatever user schema extensions happen to have @@toStringTag)
1310 if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
1311 keyNode = '[object Object]';
1315 keyNode = String(keyNode);
1317 if (_result === null) {
1321 if (keyTag === 'tag:yaml.org,2002:merge') {
1322 if (Array.isArray(valueNode)) {
1323 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1324 mergeMappings(state, _result, valueNode[index], overridableKeys);
1327 mergeMappings(state, _result, valueNode, overridableKeys);
1331 !_hasOwnProperty.call(overridableKeys, keyNode) &&
1332 _hasOwnProperty.call(_result, keyNode)) {
1333 state.line = startLine || state.line;
1334 state.position = startPos || state.position;
1335 throwError(state, 'duplicated mapping key');
1337 _result[keyNode] = valueNode;
1338 delete overridableKeys[keyNode];
1344 function readLineBreak(state) {
1347 ch = state.input.charCodeAt(state.position);
1349 if (ch === 0x0A/* LF */) {
1351 } else if (ch === 0x0D/* CR */) {
1353 if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
1357 throwError(state, 'a line break is expected');
1361 state.lineStart = state.position;
1364 function skipSeparationSpace(state, allowComments, checkIndent) {
1366 ch = state.input.charCodeAt(state.position);
1369 while (is_WHITE_SPACE(ch)) {
1370 ch = state.input.charCodeAt(++state.position);
1373 if (allowComments && ch === 0x23/* # */) {
1375 ch = state.input.charCodeAt(++state.position);
1376 } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
1380 readLineBreak(state);
1382 ch = state.input.charCodeAt(state.position);
1384 state.lineIndent = 0;
1386 while (ch === 0x20/* Space */) {
1388 ch = state.input.charCodeAt(++state.position);
1395 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1396 throwWarning(state, 'deficient indentation');
1402 function testDocumentSeparator(state) {
1403 var _position = state.position,
1406 ch = state.input.charCodeAt(_position);
1408 // Condition state.position === state.lineStart is tested
1409 // in parent on each call, for efficiency. No needs to test here again.
1410 if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
1411 ch === state.input.charCodeAt(_position + 1) &&
1412 ch === state.input.charCodeAt(_position + 2)) {
1416 ch = state.input.charCodeAt(_position);
1418 if (ch === 0 || is_WS_OR_EOL(ch)) {
1426 function writeFoldedLines(state, count) {
1428 state.result += ' ';
1429 } else if (count > 1) {
1430 state.result += common.repeat('\n', count - 1);
1435 function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1445 _result = state.result,
1448 ch = state.input.charCodeAt(state.position);
1450 if (is_WS_OR_EOL(ch) ||
1451 is_FLOW_INDICATOR(ch) ||
1452 ch === 0x23/* # */ ||
1453 ch === 0x26/* & */ ||
1454 ch === 0x2A/* * */ ||
1455 ch === 0x21/* ! */ ||
1456 ch === 0x7C/* | */ ||
1457 ch === 0x3E/* > */ ||
1458 ch === 0x27/* ' */ ||
1459 ch === 0x22/* " */ ||
1460 ch === 0x25/* % */ ||
1461 ch === 0x40/* @ */ ||
1462 ch === 0x60/* ` */) {
1466 if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
1467 following = state.input.charCodeAt(state.position + 1);
1469 if (is_WS_OR_EOL(following) ||
1470 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1475 state.kind = 'scalar';
1477 captureStart = captureEnd = state.position;
1478 hasPendingContent = false;
1481 if (ch === 0x3A/* : */) {
1482 following = state.input.charCodeAt(state.position + 1);
1484 if (is_WS_OR_EOL(following) ||
1485 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1489 } else if (ch === 0x23/* # */) {
1490 preceding = state.input.charCodeAt(state.position - 1);
1492 if (is_WS_OR_EOL(preceding)) {
1496 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
1497 withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1500 } else if (is_EOL(ch)) {
1502 _lineStart = state.lineStart;
1503 _lineIndent = state.lineIndent;
1504 skipSeparationSpace(state, false, -1);
1506 if (state.lineIndent >= nodeIndent) {
1507 hasPendingContent = true;
1508 ch = state.input.charCodeAt(state.position);
1511 state.position = captureEnd;
1513 state.lineStart = _lineStart;
1514 state.lineIndent = _lineIndent;
1519 if (hasPendingContent) {
1520 captureSegment(state, captureStart, captureEnd, false);
1521 writeFoldedLines(state, state.line - _line);
1522 captureStart = captureEnd = state.position;
1523 hasPendingContent = false;
1526 if (!is_WHITE_SPACE(ch)) {
1527 captureEnd = state.position + 1;
1530 ch = state.input.charCodeAt(++state.position);
1533 captureSegment(state, captureStart, captureEnd, false);
1540 state.result = _result;
1544 function readSingleQuotedScalar(state, nodeIndent) {
1546 captureStart, captureEnd;
1548 ch = state.input.charCodeAt(state.position);
1550 if (ch !== 0x27/* ' */) {
1554 state.kind = 'scalar';
1557 captureStart = captureEnd = state.position;
1559 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1560 if (ch === 0x27/* ' */) {
1561 captureSegment(state, captureStart, state.position, true);
1562 ch = state.input.charCodeAt(++state.position);
1564 if (ch === 0x27/* ' */) {
1565 captureStart = state.position;
1567 captureEnd = state.position;
1572 } else if (is_EOL(ch)) {
1573 captureSegment(state, captureStart, captureEnd, true);
1574 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1575 captureStart = captureEnd = state.position;
1577 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1578 throwError(state, 'unexpected end of the document within a single quoted scalar');
1582 captureEnd = state.position;
1586 throwError(state, 'unexpected end of the stream within a single quoted scalar');
1589 function readDoubleQuotedScalar(state, nodeIndent) {
1597 ch = state.input.charCodeAt(state.position);
1599 if (ch !== 0x22/* " */) {
1603 state.kind = 'scalar';
1606 captureStart = captureEnd = state.position;
1608 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1609 if (ch === 0x22/* " */) {
1610 captureSegment(state, captureStart, state.position, true);
1614 } else if (ch === 0x5C/* \ */) {
1615 captureSegment(state, captureStart, state.position, true);
1616 ch = state.input.charCodeAt(++state.position);
1619 skipSeparationSpace(state, false, nodeIndent);
1621 // TODO: rework to inline fn with no type cast?
1622 } else if (ch < 256 && simpleEscapeCheck[ch]) {
1623 state.result += simpleEscapeMap[ch];
1626 } else if ((tmp = escapedHexLen(ch)) > 0) {
1630 for (; hexLength > 0; hexLength--) {
1631 ch = state.input.charCodeAt(++state.position);
1633 if ((tmp = fromHexCode(ch)) >= 0) {
1634 hexResult = (hexResult << 4) + tmp;
1637 throwError(state, 'expected hexadecimal character');
1641 state.result += charFromCodepoint(hexResult);
1646 throwError(state, 'unknown escape sequence');
1649 captureStart = captureEnd = state.position;
1651 } else if (is_EOL(ch)) {
1652 captureSegment(state, captureStart, captureEnd, true);
1653 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1654 captureStart = captureEnd = state.position;
1656 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1657 throwError(state, 'unexpected end of the document within a double quoted scalar');
1661 captureEnd = state.position;
1665 throwError(state, 'unexpected end of the stream within a double quoted scalar');
1668 function readFlowCollection(state, nodeIndent) {
1669 var readNext = true,
1673 _anchor = state.anchor,
1679 overridableKeys = {},
1685 ch = state.input.charCodeAt(state.position);
1687 if (ch === 0x5B/* [ */) {
1688 terminator = 0x5D;/* ] */
1691 } else if (ch === 0x7B/* { */) {
1692 terminator = 0x7D;/* } */
1699 if (state.anchor !== null) {
1700 state.anchorMap[state.anchor] = _result;
1703 ch = state.input.charCodeAt(++state.position);
1706 skipSeparationSpace(state, true, nodeIndent);
1708 ch = state.input.charCodeAt(state.position);
1710 if (ch === terminator) {
1713 state.anchor = _anchor;
1714 state.kind = isMapping ? 'mapping' : 'sequence';
1715 state.result = _result;
1717 } else if (!readNext) {
1718 throwError(state, 'missed comma between flow collection entries');
1721 keyTag = keyNode = valueNode = null;
1722 isPair = isExplicitPair = false;
1724 if (ch === 0x3F/* ? */) {
1725 following = state.input.charCodeAt(state.position + 1);
1727 if (is_WS_OR_EOL(following)) {
1728 isPair = isExplicitPair = true;
1730 skipSeparationSpace(state, true, nodeIndent);
1735 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1737 keyNode = state.result;
1738 skipSeparationSpace(state, true, nodeIndent);
1740 ch = state.input.charCodeAt(state.position);
1742 if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
1744 ch = state.input.charCodeAt(++state.position);
1745 skipSeparationSpace(state, true, nodeIndent);
1746 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1747 valueNode = state.result;
1751 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
1752 } else if (isPair) {
1753 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
1755 _result.push(keyNode);
1758 skipSeparationSpace(state, true, nodeIndent);
1760 ch = state.input.charCodeAt(state.position);
1762 if (ch === 0x2C/* , */) {
1764 ch = state.input.charCodeAt(++state.position);
1770 throwError(state, 'unexpected end of the stream within a flow collection');
1773 function readBlockScalar(state, nodeIndent) {
1776 chomping = CHOMPING_CLIP,
1777 didReadContent = false,
1778 detectedIndent = false,
1779 textIndent = nodeIndent,
1781 atMoreIndented = false,
1785 ch = state.input.charCodeAt(state.position);
1787 if (ch === 0x7C/* | */) {
1789 } else if (ch === 0x3E/* > */) {
1795 state.kind = 'scalar';
1799 ch = state.input.charCodeAt(++state.position);
1801 if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
1802 if (CHOMPING_CLIP === chomping) {
1803 chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
1805 throwError(state, 'repeat of a chomping mode identifier');
1808 } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1810 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
1811 } else if (!detectedIndent) {
1812 textIndent = nodeIndent + tmp - 1;
1813 detectedIndent = true;
1815 throwError(state, 'repeat of an indentation width identifier');
1823 if (is_WHITE_SPACE(ch)) {
1824 do { ch = state.input.charCodeAt(++state.position); }
1825 while (is_WHITE_SPACE(ch));
1827 if (ch === 0x23/* # */) {
1828 do { ch = state.input.charCodeAt(++state.position); }
1829 while (!is_EOL(ch) && (ch !== 0));
1834 readLineBreak(state);
1835 state.lineIndent = 0;
1837 ch = state.input.charCodeAt(state.position);
1839 while ((!detectedIndent || state.lineIndent < textIndent) &&
1840 (ch === 0x20/* Space */)) {
1842 ch = state.input.charCodeAt(++state.position);
1845 if (!detectedIndent && state.lineIndent > textIndent) {
1846 textIndent = state.lineIndent;
1854 // End of the scalar.
1855 if (state.lineIndent < textIndent) {
1857 // Perform the chomping.
1858 if (chomping === CHOMPING_KEEP) {
1859 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1860 } else if (chomping === CHOMPING_CLIP) {
1861 if (didReadContent) { // i.e. only if the scalar is not empty.
1862 state.result += '\n';
1866 // Break this `while` cycle and go to the funciton's epilogue.
1870 // Folded style: use fancy rules to handle line breaks.
1873 // Lines starting with white space characters (more-indented lines) are not folded.
1874 if (is_WHITE_SPACE(ch)) {
1875 atMoreIndented = true;
1876 // except for the first content line (cf. Example 8.1)
1877 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1879 // End of more-indented block.
1880 } else if (atMoreIndented) {
1881 atMoreIndented = false;
1882 state.result += common.repeat('\n', emptyLines + 1);
1884 // Just one line break - perceive as the same line.
1885 } else if (emptyLines === 0) {
1886 if (didReadContent) { // i.e. only if we have already read some scalar content.
1887 state.result += ' ';
1890 // Several line breaks - perceive as different lines.
1892 state.result += common.repeat('\n', emptyLines);
1895 // Literal style: just add exact number of line breaks between content lines.
1897 // Keep all line breaks except the header line break.
1898 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1901 didReadContent = true;
1902 detectedIndent = true;
1904 captureStart = state.position;
1906 while (!is_EOL(ch) && (ch !== 0)) {
1907 ch = state.input.charCodeAt(++state.position);
1910 captureSegment(state, captureStart, state.position, false);
1916 function readBlockSequence(state, nodeIndent) {
1919 _anchor = state.anchor,
1925 if (state.anchor !== null) {
1926 state.anchorMap[state.anchor] = _result;
1929 ch = state.input.charCodeAt(state.position);
1933 if (ch !== 0x2D/* - */) {
1937 following = state.input.charCodeAt(state.position + 1);
1939 if (!is_WS_OR_EOL(following)) {
1946 if (skipSeparationSpace(state, true, -1)) {
1947 if (state.lineIndent <= nodeIndent) {
1949 ch = state.input.charCodeAt(state.position);
1955 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1956 _result.push(state.result);
1957 skipSeparationSpace(state, true, -1);
1959 ch = state.input.charCodeAt(state.position);
1961 if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
1962 throwError(state, 'bad indentation of a sequence entry');
1963 } else if (state.lineIndent < nodeIndent) {
1970 state.anchor = _anchor;
1971 state.kind = 'sequence';
1972 state.result = _result;
1978 function readBlockMapping(state, nodeIndent, flowIndent) {
1984 _anchor = state.anchor,
1986 overridableKeys = {},
1990 atExplicitKey = false,
1994 if (state.anchor !== null) {
1995 state.anchorMap[state.anchor] = _result;
1998 ch = state.input.charCodeAt(state.position);
2001 following = state.input.charCodeAt(state.position + 1);
2002 _line = state.line; // Save the current line.
2003 _pos = state.position;
2006 // Explicit notation case. There are two separate blocks:
2007 // first for the key (denoted by "?") and second for the value (denoted by ":")
2009 if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
2011 if (ch === 0x3F/* ? */) {
2012 if (atExplicitKey) {
2013 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2014 keyTag = keyNode = valueNode = null;
2018 atExplicitKey = true;
2019 allowCompact = true;
2021 } else if (atExplicitKey) {
2022 // i.e. 0x3A/* : */ === character after the explicit key.
2023 atExplicitKey = false;
2024 allowCompact = true;
2027 throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
2030 state.position += 1;
2034 // Implicit notation case. Flow-style node as the key first, then ":", and the value.
2036 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
2038 if (state.line === _line) {
2039 ch = state.input.charCodeAt(state.position);
2041 while (is_WHITE_SPACE(ch)) {
2042 ch = state.input.charCodeAt(++state.position);
2045 if (ch === 0x3A/* : */) {
2046 ch = state.input.charCodeAt(++state.position);
2048 if (!is_WS_OR_EOL(ch)) {
2049 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
2052 if (atExplicitKey) {
2053 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2054 keyTag = keyNode = valueNode = null;
2058 atExplicitKey = false;
2059 allowCompact = false;
2061 keyNode = state.result;
2063 } else if (detected) {
2064 throwError(state, 'can not read an implicit mapping pair; a colon is missed');
2068 state.anchor = _anchor;
2069 return true; // Keep the result of `composeNode`.
2072 } else if (detected) {
2073 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
2077 state.anchor = _anchor;
2078 return true; // Keep the result of `composeNode`.
2082 break; // Reading is done. Go to the epilogue.
2086 // Common reading code for both explicit and implicit notations.
2088 if (state.line === _line || state.lineIndent > nodeIndent) {
2089 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
2090 if (atExplicitKey) {
2091 keyNode = state.result;
2093 valueNode = state.result;
2097 if (!atExplicitKey) {
2098 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
2099 keyTag = keyNode = valueNode = null;
2102 skipSeparationSpace(state, true, -1);
2103 ch = state.input.charCodeAt(state.position);
2106 if (state.lineIndent > nodeIndent && (ch !== 0)) {
2107 throwError(state, 'bad indentation of a mapping entry');
2108 } else if (state.lineIndent < nodeIndent) {
2117 // Special case: last mapping's node contains only the key in explicit notation.
2118 if (atExplicitKey) {
2119 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2122 // Expose the resulting mapping.
2125 state.anchor = _anchor;
2126 state.kind = 'mapping';
2127 state.result = _result;
2133 function readTagProperty(state) {
2141 ch = state.input.charCodeAt(state.position);
2143 if (ch !== 0x21/* ! */) return false;
2145 if (state.tag !== null) {
2146 throwError(state, 'duplication of a tag property');
2149 ch = state.input.charCodeAt(++state.position);
2151 if (ch === 0x3C/* < */) {
2153 ch = state.input.charCodeAt(++state.position);
2155 } else if (ch === 0x21/* ! */) {
2158 ch = state.input.charCodeAt(++state.position);
2164 _position = state.position;
2167 do { ch = state.input.charCodeAt(++state.position); }
2168 while (ch !== 0 && ch !== 0x3E/* > */);
2170 if (state.position < state.length) {
2171 tagName = state.input.slice(_position, state.position);
2172 ch = state.input.charCodeAt(++state.position);
2174 throwError(state, 'unexpected end of the stream within a verbatim tag');
2177 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2179 if (ch === 0x21/* ! */) {
2181 tagHandle = state.input.slice(_position - 1, state.position + 1);
2183 if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2184 throwError(state, 'named tag handle cannot contain such characters');
2188 _position = state.position + 1;
2190 throwError(state, 'tag suffix cannot contain exclamation marks');
2194 ch = state.input.charCodeAt(++state.position);
2197 tagName = state.input.slice(_position, state.position);
2199 if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2200 throwError(state, 'tag suffix cannot contain flow indicator characters');
2204 if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2205 throwError(state, 'tag name cannot contain such characters: ' + tagName);
2209 state.tag = tagName;
2211 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
2212 state.tag = state.tagMap[tagHandle] + tagName;
2214 } else if (tagHandle === '!') {
2215 state.tag = '!' + tagName;
2217 } else if (tagHandle === '!!') {
2218 state.tag = 'tag:yaml.org,2002:' + tagName;
2221 throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2227 function readAnchorProperty(state) {
2231 ch = state.input.charCodeAt(state.position);
2233 if (ch !== 0x26/* & */) return false;
2235 if (state.anchor !== null) {
2236 throwError(state, 'duplication of an anchor property');
2239 ch = state.input.charCodeAt(++state.position);
2240 _position = state.position;
2242 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2243 ch = state.input.charCodeAt(++state.position);
2246 if (state.position === _position) {
2247 throwError(state, 'name of an anchor node must contain at least one character');
2250 state.anchor = state.input.slice(_position, state.position);
2254 function readAlias(state) {
2255 var _position, alias,
2258 ch = state.input.charCodeAt(state.position);
2260 if (ch !== 0x2A/* * */) return false;
2262 ch = state.input.charCodeAt(++state.position);
2263 _position = state.position;
2265 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2266 ch = state.input.charCodeAt(++state.position);
2269 if (state.position === _position) {
2270 throwError(state, 'name of an alias node must contain at least one character');
2273 alias = state.input.slice(_position, state.position);
2275 if (!state.anchorMap.hasOwnProperty(alias)) {
2276 throwError(state, 'unidentified alias "' + alias + '"');
2279 state.result = state.anchorMap[alias];
2280 skipSeparationSpace(state, true, -1);
2284 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2285 var allowBlockStyles,
2287 allowBlockCollections,
2288 indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
2297 if (state.listener !== null) {
2298 state.listener('open', state);
2302 state.anchor = null;
2304 state.result = null;
2306 allowBlockStyles = allowBlockScalars = allowBlockCollections =
2307 CONTEXT_BLOCK_OUT === nodeContext ||
2308 CONTEXT_BLOCK_IN === nodeContext;
2311 if (skipSeparationSpace(state, true, -1)) {
2314 if (state.lineIndent > parentIndent) {
2316 } else if (state.lineIndent === parentIndent) {
2318 } else if (state.lineIndent < parentIndent) {
2324 if (indentStatus === 1) {
2325 while (readTagProperty(state) || readAnchorProperty(state)) {
2326 if (skipSeparationSpace(state, true, -1)) {
2328 allowBlockCollections = allowBlockStyles;
2330 if (state.lineIndent > parentIndent) {
2332 } else if (state.lineIndent === parentIndent) {
2334 } else if (state.lineIndent < parentIndent) {
2338 allowBlockCollections = false;
2343 if (allowBlockCollections) {
2344 allowBlockCollections = atNewLine || allowCompact;
2347 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2348 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2349 flowIndent = parentIndent;
2351 flowIndent = parentIndent + 1;
2354 blockIndent = state.position - state.lineStart;
2356 if (indentStatus === 1) {
2357 if (allowBlockCollections &&
2358 (readBlockSequence(state, blockIndent) ||
2359 readBlockMapping(state, blockIndent, flowIndent)) ||
2360 readFlowCollection(state, flowIndent)) {
2363 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
2364 readSingleQuotedScalar(state, flowIndent) ||
2365 readDoubleQuotedScalar(state, flowIndent)) {
2368 } else if (readAlias(state)) {
2371 if (state.tag !== null || state.anchor !== null) {
2372 throwError(state, 'alias node should not have any properties');
2375 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2378 if (state.tag === null) {
2383 if (state.anchor !== null) {
2384 state.anchorMap[state.anchor] = state.result;
2387 } else if (indentStatus === 0) {
2388 // Special case: block sequences are allowed to have same indentation level as the parent.
2389 // http://www.yaml.org/spec/1.2/spec.html#id2799784
2390 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2394 if (state.tag !== null && state.tag !== '!') {
2395 if (state.tag === '?') {
2396 // Implicit resolving is not allowed for non-scalar types, and '?'
2397 // non-specific tag is only automatically assigned to plain scalars.
2399 // We only need to check kind conformity in case user explicitly assigns '?'
2400 // tag, for example like this: "!<?> [0]"
2402 if (state.result !== null && state.kind !== 'scalar') {
2403 throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
2406 for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
2407 type = state.implicitTypes[typeIndex];
2409 if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
2410 state.result = type.construct(state.result);
2411 state.tag = type.tag;
2412 if (state.anchor !== null) {
2413 state.anchorMap[state.anchor] = state.result;
2418 } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
2419 type = state.typeMap[state.kind || 'fallback'][state.tag];
2421 if (state.result !== null && type.kind !== state.kind) {
2422 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2425 if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
2426 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
2428 state.result = type.construct(state.result);
2429 if (state.anchor !== null) {
2430 state.anchorMap[state.anchor] = state.result;
2434 throwError(state, 'unknown tag !<' + state.tag + '>');
2438 if (state.listener !== null) {
2439 state.listener('close', state);
2441 return state.tag !== null || state.anchor !== null || hasContent;
2444 function readDocument(state) {
2445 var documentStart = state.position,
2449 hasDirectives = false,
2452 state.version = null;
2453 state.checkLineBreaks = state.legacy;
2455 state.anchorMap = {};
2457 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2458 skipSeparationSpace(state, true, -1);
2460 ch = state.input.charCodeAt(state.position);
2462 if (state.lineIndent > 0 || ch !== 0x25/* % */) {
2466 hasDirectives = true;
2467 ch = state.input.charCodeAt(++state.position);
2468 _position = state.position;
2470 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2471 ch = state.input.charCodeAt(++state.position);
2474 directiveName = state.input.slice(_position, state.position);
2477 if (directiveName.length < 1) {
2478 throwError(state, 'directive name must not be less than one character in length');
2482 while (is_WHITE_SPACE(ch)) {
2483 ch = state.input.charCodeAt(++state.position);
2486 if (ch === 0x23/* # */) {
2487 do { ch = state.input.charCodeAt(++state.position); }
2488 while (ch !== 0 && !is_EOL(ch));
2492 if (is_EOL(ch)) break;
2494 _position = state.position;
2496 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2497 ch = state.input.charCodeAt(++state.position);
2500 directiveArgs.push(state.input.slice(_position, state.position));
2503 if (ch !== 0) readLineBreak(state);
2505 if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2506 directiveHandlers[directiveName](state, directiveName, directiveArgs);
2508 throwWarning(state, 'unknown document directive "' + directiveName + '"');
2512 skipSeparationSpace(state, true, -1);
2514 if (state.lineIndent === 0 &&
2515 state.input.charCodeAt(state.position) === 0x2D/* - */ &&
2516 state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
2517 state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
2518 state.position += 3;
2519 skipSeparationSpace(state, true, -1);
2521 } else if (hasDirectives) {
2522 throwError(state, 'directives end mark is expected');
2525 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2526 skipSeparationSpace(state, true, -1);
2528 if (state.checkLineBreaks &&
2529 PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2530 throwWarning(state, 'non-ASCII line breaks are interpreted as content');
2533 state.documents.push(state.result);
2535 if (state.position === state.lineStart && testDocumentSeparator(state)) {
2537 if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
2538 state.position += 3;
2539 skipSeparationSpace(state, true, -1);
2544 if (state.position < (state.length - 1)) {
2545 throwError(state, 'end of the stream or a document separator is expected');
2552 function loadDocuments(input, options) {
2553 input = String(input);
2554 options = options || {};
2556 if (input.length !== 0) {
2558 // Add tailing `\n` if not exists
2559 if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
2560 input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
2565 if (input.charCodeAt(0) === 0xFEFF) {
2566 input = input.slice(1);
2570 var state = new State(input, options);
2572 var nullpos = input.indexOf('\0');
2574 if (nullpos !== -1) {
2575 state.position = nullpos;
2576 throwError(state, 'null byte is not allowed in input');
2579 // Use 0 as string terminator. That significantly simplifies bounds check.
2580 state.input += '\0';
2582 while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
2583 state.lineIndent += 1;
2584 state.position += 1;
2587 while (state.position < (state.length - 1)) {
2588 readDocument(state);
2591 return state.documents;
2595 function loadAll(input, iterator, options) {
2596 if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
2601 var documents = loadDocuments(input, options);
2603 if (typeof iterator !== 'function') {
2607 for (var index = 0, length = documents.length; index < length; index += 1) {
2608 iterator(documents[index]);
2613 function load(input, options) {
2614 var documents = loadDocuments(input, options);
2616 if (documents.length === 0) {
2617 /*eslint-disable no-undefined*/
2619 } else if (documents.length === 1) {
2620 return documents[0];
2622 throw new YAMLException('expected a single document in the stream, but found more');
2626 function safeLoadAll(input, iterator, options) {
2627 if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
2632 return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2636 function safeLoad(input, options) {
2637 return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2641 module.exports.loadAll = loadAll;
2642 module.exports.load = load;
2643 module.exports.safeLoadAll = safeLoadAll;
2644 module.exports.safeLoad = safeLoad;
2646 },{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){
2650 var common = require('./common');
2653 function Mark(name, buffer, position, line, column) {
2655 this.buffer = buffer;
2656 this.position = position;
2658 this.column = column;
2662 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2663 var head, start, tail, end, snippet;
2665 if (!this.buffer) return null;
2667 indent = indent || 4;
2668 maxLength = maxLength || 75;
2671 start = this.position;
2673 while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
2675 if (this.position - start > (maxLength / 2 - 1)) {
2683 end = this.position;
2685 while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
2687 if (end - this.position > (maxLength / 2 - 1)) {
2694 snippet = this.buffer.slice(start, end);
2696 return common.repeat(' ', indent) + head + snippet + tail + '\n' +
2697 common.repeat(' ', indent + this.position - start + head.length) + '^';
2701 Mark.prototype.toString = function toString(compact) {
2702 var snippet, where = '';
2705 where += 'in "' + this.name + '" ';
2708 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
2711 snippet = this.getSnippet();
2714 where += ':\n' + snippet;
2722 module.exports = Mark;
2724 },{"./common":2}],7:[function(require,module,exports){
2727 /*eslint-disable max-len*/
2729 var common = require('./common');
2730 var YAMLException = require('./exception');
2731 var Type = require('./type');
2734 function compileList(schema, name, result) {
2737 schema.include.forEach(function (includedSchema) {
2738 result = compileList(includedSchema, name, result);
2741 schema[name].forEach(function (currentType) {
2742 result.forEach(function (previousType, previousIndex) {
2743 if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
2744 exclude.push(previousIndex);
2748 result.push(currentType);
2751 return result.filter(function (type, index) {
2752 return exclude.indexOf(index) === -1;
2757 function compileMap(/* lists... */) {
2765 function collectType(type) {
2766 result[type.kind][type.tag] = result['fallback'][type.tag] = type;
2769 for (index = 0, length = arguments.length; index < length; index += 1) {
2770 arguments[index].forEach(collectType);
2776 function Schema(definition) {
2777 this.include = definition.include || [];
2778 this.implicit = definition.implicit || [];
2779 this.explicit = definition.explicit || [];
2781 this.implicit.forEach(function (type) {
2782 if (type.loadKind && type.loadKind !== 'scalar') {
2783 throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
2787 this.compiledImplicit = compileList(this, 'implicit', []);
2788 this.compiledExplicit = compileList(this, 'explicit', []);
2789 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
2793 Schema.DEFAULT = null;
2796 Schema.create = function createSchema() {
2799 switch (arguments.length) {
2801 schemas = Schema.DEFAULT;
2802 types = arguments[0];
2806 schemas = arguments[0];
2807 types = arguments[1];
2811 throw new YAMLException('Wrong number of arguments for Schema.create function');
2814 schemas = common.toArray(schemas);
2815 types = common.toArray(types);
2817 if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
2818 throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
2821 if (!types.every(function (type) { return type instanceof Type; })) {
2822 throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
2832 module.exports = Schema;
2834 },{"./common":2,"./exception":4,"./type":13}],8:[function(require,module,exports){
2835 // Standard YAML's Core schema.
2836 // http://www.yaml.org/spec/1.2/spec.html#id2804923
2838 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2839 // So, Core schema has no distinctions from JSON schema is JS-YAML.
2845 var Schema = require('../schema');
2848 module.exports = new Schema({
2854 },{"../schema":7,"./json":12}],9:[function(require,module,exports){
2855 // JS-YAML's default schema for `load` function.
2856 // It is not described in the YAML specification.
2858 // This schema is based on JS-YAML's default safe schema and includes
2859 // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
2861 // Also this schema is used as default base schema at `Schema.create` function.
2867 var Schema = require('../schema');
2870 module.exports = Schema.DEFAULT = new Schema({
2872 require('./default_safe')
2875 require('../type/js/undefined'),
2876 require('../type/js/regexp'),
2877 require('../type/js/function')
2881 },{"../schema":7,"../type/js/function":18,"../type/js/regexp":19,"../type/js/undefined":20,"./default_safe":10}],10:[function(require,module,exports){
2882 // JS-YAML's default schema for `safeLoad` function.
2883 // It is not described in the YAML specification.
2885 // This schema is based on standard YAML's Core schema and includes most of
2886 // extra types described at YAML tag repository. (http://yaml.org/type/)
2892 var Schema = require('../schema');
2895 module.exports = new Schema({
2900 require('../type/timestamp'),
2901 require('../type/merge')
2904 require('../type/binary'),
2905 require('../type/omap'),
2906 require('../type/pairs'),
2907 require('../type/set')
2911 },{"../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){
2912 // Standard YAML's Failsafe schema.
2913 // http://www.yaml.org/spec/1.2/spec.html#id2802346
2919 var Schema = require('../schema');
2922 module.exports = new Schema({
2924 require('../type/str'),
2925 require('../type/seq'),
2926 require('../type/map')
2930 },{"../schema":7,"../type/map":21,"../type/seq":26,"../type/str":28}],12:[function(require,module,exports){
2931 // Standard YAML's JSON schema.
2932 // http://www.yaml.org/spec/1.2/spec.html#id2803231
2934 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2935 // So, this schema is not such strict as defined in the YAML specification.
2936 // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
2942 var Schema = require('../schema');
2945 module.exports = new Schema({
2947 require('./failsafe')
2950 require('../type/null'),
2951 require('../type/bool'),
2952 require('../type/int'),
2953 require('../type/float')
2957 },{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){
2960 var YAMLException = require('./exception');
2962 var TYPE_CONSTRUCTOR_OPTIONS = [
2973 var YAML_NODE_KINDS = [
2979 function compileStyleAliases(map) {
2983 Object.keys(map).forEach(function (style) {
2984 map[style].forEach(function (alias) {
2985 result[String(alias)] = style;
2993 function Type(tag, options) {
2994 options = options || {};
2996 Object.keys(options).forEach(function (name) {
2997 if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
2998 throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
3002 // TODO: Add tag format check.
3004 this.kind = options['kind'] || null;
3005 this.resolve = options['resolve'] || function () { return true; };
3006 this.construct = options['construct'] || function (data) { return data; };
3007 this.instanceOf = options['instanceOf'] || null;
3008 this.predicate = options['predicate'] || null;
3009 this.represent = options['represent'] || null;
3010 this.defaultStyle = options['defaultStyle'] || null;
3011 this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
3013 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
3014 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
3018 module.exports = Type;
3020 },{"./exception":4}],14:[function(require,module,exports){
3023 /*eslint-disable no-bitwise*/
3028 // A trick for browserified version, to not include `Buffer` shim
3029 var _require = require;
3030 NodeBuffer = _require('buffer').Buffer;
3033 var Type = require('../type');
3036 // [ 64, 65, 66 ] -> [ padding, CR, LF ]
3037 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
3040 function resolveYamlBinary(data) {
3041 if (data === null) return false;
3043 var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
3045 // Convert one by one.
3046 for (idx = 0; idx < max; idx++) {
3047 code = map.indexOf(data.charAt(idx));
3050 if (code > 64) continue;
3052 // Fail on illegal characters
3053 if (code < 0) return false;
3058 // If there are any bits left, source was corrupted
3059 return (bitlen % 8) === 0;
3062 function constructYamlBinary(data) {
3064 input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
3070 // Collect by 6*4 bits (3 bytes)
3072 for (idx = 0; idx < max; idx++) {
3073 if ((idx % 4 === 0) && idx) {
3074 result.push((bits >> 16) & 0xFF);
3075 result.push((bits >> 8) & 0xFF);
3076 result.push(bits & 0xFF);
3079 bits = (bits << 6) | map.indexOf(input.charAt(idx));
3084 tailbits = (max % 4) * 6;
3086 if (tailbits === 0) {
3087 result.push((bits >> 16) & 0xFF);
3088 result.push((bits >> 8) & 0xFF);
3089 result.push(bits & 0xFF);
3090 } else if (tailbits === 18) {
3091 result.push((bits >> 10) & 0xFF);
3092 result.push((bits >> 2) & 0xFF);
3093 } else if (tailbits === 12) {
3094 result.push((bits >> 4) & 0xFF);
3097 // Wrap into Buffer for NodeJS and leave Array for browser
3099 // Support node 6.+ Buffer API when available
3100 return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
3106 function representYamlBinary(object /*, style*/) {
3107 var result = '', bits = 0, idx, tail,
3108 max = object.length,
3111 // Convert every three bytes to 4 ASCII characters.
3113 for (idx = 0; idx < max; idx++) {
3114 if ((idx % 3 === 0) && idx) {
3115 result += map[(bits >> 18) & 0x3F];
3116 result += map[(bits >> 12) & 0x3F];
3117 result += map[(bits >> 6) & 0x3F];
3118 result += map[bits & 0x3F];
3121 bits = (bits << 8) + object[idx];
3129 result += map[(bits >> 18) & 0x3F];
3130 result += map[(bits >> 12) & 0x3F];
3131 result += map[(bits >> 6) & 0x3F];
3132 result += map[bits & 0x3F];
3133 } else if (tail === 2) {
3134 result += map[(bits >> 10) & 0x3F];
3135 result += map[(bits >> 4) & 0x3F];
3136 result += map[(bits << 2) & 0x3F];
3138 } else if (tail === 1) {
3139 result += map[(bits >> 2) & 0x3F];
3140 result += map[(bits << 4) & 0x3F];
3148 function isBinary(object) {
3149 return NodeBuffer && NodeBuffer.isBuffer(object);
3152 module.exports = new Type('tag:yaml.org,2002:binary', {
3154 resolve: resolveYamlBinary,
3155 construct: constructYamlBinary,
3156 predicate: isBinary,
3157 represent: representYamlBinary
3160 },{"../type":13}],15:[function(require,module,exports){
3163 var Type = require('../type');
3165 function resolveYamlBoolean(data) {
3166 if (data === null) return false;
3168 var max = data.length;
3170 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
3171 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
3174 function constructYamlBoolean(data) {
3175 return data === 'true' ||
3180 function isBoolean(object) {
3181 return Object.prototype.toString.call(object) === '[object Boolean]';
3184 module.exports = new Type('tag:yaml.org,2002:bool', {
3186 resolve: resolveYamlBoolean,
3187 construct: constructYamlBoolean,
3188 predicate: isBoolean,
3190 lowercase: function (object) { return object ? 'true' : 'false'; },
3191 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
3192 camelcase: function (object) { return object ? 'True' : 'False'; }
3194 defaultStyle: 'lowercase'
3197 },{"../type":13}],16:[function(require,module,exports){
3200 var common = require('../common');
3201 var Type = require('../type');
3203 var YAML_FLOAT_PATTERN = new RegExp(
3204 // 2.5e4, 2.5 and integers
3205 '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
3207 // special case, seems not from spec
3208 '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
3210 '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
3212 '|[-+]?\\.(?:inf|Inf|INF)' +
3214 '|\\.(?:nan|NaN|NAN))$');
3216 function resolveYamlFloat(data) {
3217 if (data === null) return false;
3219 if (!YAML_FLOAT_PATTERN.test(data) ||
3220 // Quick hack to not allow integers end with `_`
3221 // Probably should update regexp & check speed
3222 data[data.length - 1] === '_') {
3229 function constructYamlFloat(data) {
3230 var value, sign, base, digits;
3232 value = data.replace(/_/g, '').toLowerCase();
3233 sign = value[0] === '-' ? -1 : 1;
3236 if ('+-'.indexOf(value[0]) >= 0) {
3237 value = value.slice(1);
3240 if (value === '.inf') {
3241 return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
3243 } else if (value === '.nan') {
3246 } else if (value.indexOf(':') >= 0) {
3247 value.split(':').forEach(function (v) {
3248 digits.unshift(parseFloat(v, 10));
3254 digits.forEach(function (d) {
3259 return sign * value;
3262 return sign * parseFloat(value, 10);
3266 var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
3268 function representYamlFloat(object, style) {
3271 if (isNaN(object)) {
3273 case 'lowercase': return '.nan';
3274 case 'uppercase': return '.NAN';
3275 case 'camelcase': return '.NaN';
3277 } else if (Number.POSITIVE_INFINITY === object) {
3279 case 'lowercase': return '.inf';
3280 case 'uppercase': return '.INF';
3281 case 'camelcase': return '.Inf';
3283 } else if (Number.NEGATIVE_INFINITY === object) {
3285 case 'lowercase': return '-.inf';
3286 case 'uppercase': return '-.INF';
3287 case 'camelcase': return '-.Inf';
3289 } else if (common.isNegativeZero(object)) {
3293 res = object.toString(10);
3295 // JS stringifier can build scientific format without dots: 5e-100,
3296 // while YAML requres dot: 5.e-100. Fix it with simple hack
3298 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
3301 function isFloat(object) {
3302 return (Object.prototype.toString.call(object) === '[object Number]') &&
3303 (object % 1 !== 0 || common.isNegativeZero(object));
3306 module.exports = new Type('tag:yaml.org,2002:float', {
3308 resolve: resolveYamlFloat,
3309 construct: constructYamlFloat,
3311 represent: representYamlFloat,
3312 defaultStyle: 'lowercase'
3315 },{"../common":2,"../type":13}],17:[function(require,module,exports){
3318 var common = require('../common');
3319 var Type = require('../type');
3321 function isHexCode(c) {
3322 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
3323 ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
3324 ((0x61/* a */ <= c) && (c <= 0x66/* f */));
3327 function isOctCode(c) {
3328 return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
3331 function isDecCode(c) {
3332 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
3335 function resolveYamlInteger(data) {
3336 if (data === null) return false;
3338 var max = data.length,
3343 if (!max) return false;
3348 if (ch === '-' || ch === '+') {
3354 if (index + 1 === max) return true;
3357 // base 2, base 8, base 16
3363 for (; index < max; index++) {
3365 if (ch === '_') continue;
3366 if (ch !== '0' && ch !== '1') return false;
3369 return hasDigits && ch !== '_';
3377 for (; index < max; index++) {
3379 if (ch === '_') continue;
3380 if (!isHexCode(data.charCodeAt(index))) return false;
3383 return hasDigits && ch !== '_';
3387 for (; index < max; index++) {
3389 if (ch === '_') continue;
3390 if (!isOctCode(data.charCodeAt(index))) return false;
3393 return hasDigits && ch !== '_';
3396 // base 10 (except 0) or base 60
3398 // value should not start with `_`;
3399 if (ch === '_') return false;
3401 for (; index < max; index++) {
3403 if (ch === '_') continue;
3404 if (ch === ':') break;
3405 if (!isDecCode(data.charCodeAt(index))) {
3411 // Should have digits and should not end with `_`
3412 if (!hasDigits || ch === '_') return false;
3414 // if !base60 - done;
3415 if (ch !== ':') return true;
3417 // base60 almost not used, no needs to optimize
3418 return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
3421 function constructYamlInteger(data) {
3422 var value = data, sign = 1, ch, base, digits = [];
3424 if (value.indexOf('_') !== -1) {
3425 value = value.replace(/_/g, '');
3430 if (ch === '-' || ch === '+') {
3431 if (ch === '-') sign = -1;
3432 value = value.slice(1);
3436 if (value === '0') return 0;
3439 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
3440 if (value[1] === 'x') return sign * parseInt(value, 16);
3441 return sign * parseInt(value, 8);
3444 if (value.indexOf(':') !== -1) {
3445 value.split(':').forEach(function (v) {
3446 digits.unshift(parseInt(v, 10));
3452 digits.forEach(function (d) {
3453 value += (d * base);
3457 return sign * value;
3461 return sign * parseInt(value, 10);
3464 function isInteger(object) {
3465 return (Object.prototype.toString.call(object)) === '[object Number]' &&
3466 (object % 1 === 0 && !common.isNegativeZero(object));
3469 module.exports = new Type('tag:yaml.org,2002:int', {
3471 resolve: resolveYamlInteger,
3472 construct: constructYamlInteger,
3473 predicate: isInteger,
3475 binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
3476 octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
3477 decimal: function (obj) { return obj.toString(10); },
3478 /* eslint-disable max-len */
3479 hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
3481 defaultStyle: 'decimal',
3483 binary: [ 2, 'bin' ],
3484 octal: [ 8, 'oct' ],
3485 decimal: [ 10, 'dec' ],
3486 hexadecimal: [ 16, 'hex' ]
3490 },{"../common":2,"../type":13}],18:[function(require,module,exports){
3495 // Browserified version does not have esprima
3497 // 1. For node.js just require module as deps
3498 // 2. For browser try to require mudule via external AMD system.
3499 // If not found - try to fallback to window.esprima. If not
3500 // found too - then fail to parse.
3503 // workaround to exclude package from browserify list.
3504 var _require = require;
3505 esprima = _require('esprima');
3507 /* eslint-disable no-redeclare */
3509 if (typeof window !== 'undefined') esprima = window.esprima;
3512 var Type = require('../../type');
3514 function resolveJavascriptFunction(data) {
3515 if (data === null) return false;
3518 var source = '(' + data + ')',
3519 ast = esprima.parse(source, { range: true });
3521 if (ast.type !== 'Program' ||
3522 ast.body.length !== 1 ||
3523 ast.body[0].type !== 'ExpressionStatement' ||
3524 (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
3525 ast.body[0].expression.type !== 'FunctionExpression')) {
3535 function constructJavascriptFunction(data) {
3536 /*jslint evil:true*/
3538 var source = '(' + data + ')',
3539 ast = esprima.parse(source, { range: true }),
3543 if (ast.type !== 'Program' ||
3544 ast.body.length !== 1 ||
3545 ast.body[0].type !== 'ExpressionStatement' ||
3546 (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
3547 ast.body[0].expression.type !== 'FunctionExpression')) {
3548 throw new Error('Failed to resolve function');
3551 ast.body[0].expression.params.forEach(function (param) {
3552 params.push(param.name);
3555 body = ast.body[0].expression.body.range;
3557 // Esprima's ranges include the first '{' and the last '}' characters on
3558 // function expressions. So cut them out.
3559 if (ast.body[0].expression.body.type === 'BlockStatement') {
3560 /*eslint-disable no-new-func*/
3561 return new Function(params, source.slice(body[0] + 1, body[1] - 1));
3563 // ES6 arrow functions can omit the BlockStatement. In that case, just return
3565 /*eslint-disable no-new-func*/
3566 return new Function(params, 'return ' + source.slice(body[0], body[1]));
3569 function representJavascriptFunction(object /*, style*/) {
3570 return object.toString();
3573 function isFunction(object) {
3574 return Object.prototype.toString.call(object) === '[object Function]';
3577 module.exports = new Type('tag:yaml.org,2002:js/function', {
3579 resolve: resolveJavascriptFunction,
3580 construct: constructJavascriptFunction,
3581 predicate: isFunction,
3582 represent: representJavascriptFunction
3585 },{"../../type":13}],19:[function(require,module,exports){
3588 var Type = require('../../type');
3590 function resolveJavascriptRegExp(data) {
3591 if (data === null) return false;
3592 if (data.length === 0) return false;
3595 tail = /\/([gim]*)$/.exec(data),
3598 // if regexp starts with '/' it can have modifiers and must be properly closed
3599 // `/foo/gim` - modifiers tail can be maximum 3 chars
3600 if (regexp[0] === '/') {
3601 if (tail) modifiers = tail[1];
3603 if (modifiers.length > 3) return false;
3604 // if expression starts with /, is should be properly terminated
3605 if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
3611 function constructJavascriptRegExp(data) {
3613 tail = /\/([gim]*)$/.exec(data),
3616 // `/foo/gim` - tail can be maximum 4 chars
3617 if (regexp[0] === '/') {
3618 if (tail) modifiers = tail[1];
3619 regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3622 return new RegExp(regexp, modifiers);
3625 function representJavascriptRegExp(object /*, style*/) {
3626 var result = '/' + object.source + '/';
3628 if (object.global) result += 'g';
3629 if (object.multiline) result += 'm';
3630 if (object.ignoreCase) result += 'i';
3635 function isRegExp(object) {
3636 return Object.prototype.toString.call(object) === '[object RegExp]';
3639 module.exports = new Type('tag:yaml.org,2002:js/regexp', {
3641 resolve: resolveJavascriptRegExp,
3642 construct: constructJavascriptRegExp,
3643 predicate: isRegExp,
3644 represent: representJavascriptRegExp
3647 },{"../../type":13}],20:[function(require,module,exports){
3650 var Type = require('../../type');
3652 function resolveJavascriptUndefined() {
3656 function constructJavascriptUndefined() {
3657 /*eslint-disable no-undefined*/
3661 function representJavascriptUndefined() {
3665 function isUndefined(object) {
3666 return typeof object === 'undefined';
3669 module.exports = new Type('tag:yaml.org,2002:js/undefined', {
3671 resolve: resolveJavascriptUndefined,
3672 construct: constructJavascriptUndefined,
3673 predicate: isUndefined,
3674 represent: representJavascriptUndefined
3677 },{"../../type":13}],21:[function(require,module,exports){
3680 var Type = require('../type');
3682 module.exports = new Type('tag:yaml.org,2002:map', {
3684 construct: function (data) { return data !== null ? data : {}; }
3687 },{"../type":13}],22:[function(require,module,exports){
3690 var Type = require('../type');
3692 function resolveYamlMerge(data) {
3693 return data === '<<' || data === null;
3696 module.exports = new Type('tag:yaml.org,2002:merge', {
3698 resolve: resolveYamlMerge
3701 },{"../type":13}],23:[function(require,module,exports){
3704 var Type = require('../type');
3706 function resolveYamlNull(data) {
3707 if (data === null) return true;
3709 var max = data.length;
3711 return (max === 1 && data === '~') ||
3712 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
3715 function constructYamlNull() {
3719 function isNull(object) {
3720 return object === null;
3723 module.exports = new Type('tag:yaml.org,2002:null', {
3725 resolve: resolveYamlNull,
3726 construct: constructYamlNull,
3729 canonical: function () { return '~'; },
3730 lowercase: function () { return 'null'; },
3731 uppercase: function () { return 'NULL'; },
3732 camelcase: function () { return 'Null'; }
3734 defaultStyle: 'lowercase'
3737 },{"../type":13}],24:[function(require,module,exports){
3740 var Type = require('../type');
3742 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3743 var _toString = Object.prototype.toString;
3745 function resolveYamlOmap(data) {
3746 if (data === null) return true;
3748 var objectKeys = [], index, length, pair, pairKey, pairHasKey,
3751 for (index = 0, length = object.length; index < length; index += 1) {
3752 pair = object[index];
3755 if (_toString.call(pair) !== '[object Object]') return false;
3757 for (pairKey in pair) {
3758 if (_hasOwnProperty.call(pair, pairKey)) {
3759 if (!pairHasKey) pairHasKey = true;
3764 if (!pairHasKey) return false;
3766 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
3773 function constructYamlOmap(data) {
3774 return data !== null ? data : [];
3777 module.exports = new Type('tag:yaml.org,2002:omap', {
3779 resolve: resolveYamlOmap,
3780 construct: constructYamlOmap
3783 },{"../type":13}],25:[function(require,module,exports){
3786 var Type = require('../type');
3788 var _toString = Object.prototype.toString;
3790 function resolveYamlPairs(data) {
3791 if (data === null) return true;
3793 var index, length, pair, keys, result,
3796 result = new Array(object.length);
3798 for (index = 0, length = object.length; index < length; index += 1) {
3799 pair = object[index];
3801 if (_toString.call(pair) !== '[object Object]') return false;
3803 keys = Object.keys(pair);
3805 if (keys.length !== 1) return false;
3807 result[index] = [ keys[0], pair[keys[0]] ];
3813 function constructYamlPairs(data) {
3814 if (data === null) return [];
3816 var index, length, pair, keys, result,
3819 result = new Array(object.length);
3821 for (index = 0, length = object.length; index < length; index += 1) {
3822 pair = object[index];
3824 keys = Object.keys(pair);
3826 result[index] = [ keys[0], pair[keys[0]] ];
3832 module.exports = new Type('tag:yaml.org,2002:pairs', {
3834 resolve: resolveYamlPairs,
3835 construct: constructYamlPairs
3838 },{"../type":13}],26:[function(require,module,exports){
3841 var Type = require('../type');
3843 module.exports = new Type('tag:yaml.org,2002:seq', {
3845 construct: function (data) { return data !== null ? data : []; }
3848 },{"../type":13}],27:[function(require,module,exports){
3851 var Type = require('../type');
3853 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3855 function resolveYamlSet(data) {
3856 if (data === null) return true;
3858 var key, object = data;
3860 for (key in object) {
3861 if (_hasOwnProperty.call(object, key)) {
3862 if (object[key] !== null) return false;
3869 function constructYamlSet(data) {
3870 return data !== null ? data : {};
3873 module.exports = new Type('tag:yaml.org,2002:set', {
3875 resolve: resolveYamlSet,
3876 construct: constructYamlSet
3879 },{"../type":13}],28:[function(require,module,exports){
3882 var Type = require('../type');
3884 module.exports = new Type('tag:yaml.org,2002:str', {
3886 construct: function (data) { return data !== null ? data : ''; }
3889 },{"../type":13}],29:[function(require,module,exports){
3892 var Type = require('../type');
3894 var YAML_DATE_REGEXP = new RegExp(
3895 '^([0-9][0-9][0-9][0-9])' + // [1] year
3896 '-([0-9][0-9])' + // [2] month
3897 '-([0-9][0-9])$'); // [3] day
3899 var YAML_TIMESTAMP_REGEXP = new RegExp(
3900 '^([0-9][0-9][0-9][0-9])' + // [1] year
3901 '-([0-9][0-9]?)' + // [2] month
3902 '-([0-9][0-9]?)' + // [3] day
3903 '(?:[Tt]|[ \\t]+)' + // ...
3904 '([0-9][0-9]?)' + // [4] hour
3905 ':([0-9][0-9])' + // [5] minute
3906 ':([0-9][0-9])' + // [6] second
3907 '(?:\\.([0-9]*))?' + // [7] fraction
3908 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
3909 '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
3911 function resolveYamlTimestamp(data) {
3912 if (data === null) return false;
3913 if (YAML_DATE_REGEXP.exec(data) !== null) return true;
3914 if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
3918 function constructYamlTimestamp(data) {
3919 var match, year, month, day, hour, minute, second, fraction = 0,
3920 delta = null, tz_hour, tz_minute, date;
3922 match = YAML_DATE_REGEXP.exec(data);
3923 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
3925 if (match === null) throw new Error('Date resolve error');
3927 // match: [1] year [2] month [3] day
3930 month = +(match[2]) - 1; // JS month starts with 0
3933 if (!match[4]) { // no hour
3934 return new Date(Date.UTC(year, month, day));
3937 // match: [4] hour [5] minute [6] second [7] fraction
3940 minute = +(match[5]);
3941 second = +(match[6]);
3944 fraction = match[7].slice(0, 3);
3945 while (fraction.length < 3) { // milli-seconds
3948 fraction = +fraction;
3951 // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
3954 tz_hour = +(match[10]);
3955 tz_minute = +(match[11] || 0);
3956 delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
3957 if (match[9] === '-') delta = -delta;
3960 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
3962 if (delta) date.setTime(date.getTime() - delta);
3967 function representYamlTimestamp(object /*, style*/) {
3968 return object.toISOString();
3971 module.exports = new Type('tag:yaml.org,2002:timestamp', {
3973 resolve: resolveYamlTimestamp,
3974 construct: constructYamlTimestamp,
3976 represent: representYamlTimestamp
3979 },{"../type":13}],"/":[function(require,module,exports){
3983 var yaml = require('./lib/js-yaml.js');
3986 module.exports = yaml;
3988 },{"./lib/js-yaml.js":1}]},{},[])("/")