1 /* js-yaml 3.2.7 https://github.com/nodeca/js-yaml */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jsyaml=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
5 var loader = require('./js-yaml/loader');
6 var dumper = require('./js-yaml/dumper');
9 function deprecated(name) {
11 throw new Error('Function ' + name + ' is deprecated and cannot be used.');
16 module.exports.Type = require('./js-yaml/type');
17 module.exports.Schema = require('./js-yaml/schema');
18 module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
19 module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
20 module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
21 module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
22 module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
23 module.exports.load = loader.load;
24 module.exports.loadAll = loader.loadAll;
25 module.exports.safeLoad = loader.safeLoad;
26 module.exports.safeLoadAll = loader.safeLoadAll;
27 module.exports.dump = dumper.dump;
28 module.exports.safeDump = dumper.safeDump;
29 module.exports.YAMLException = require('./js-yaml/exception');
31 // Deprecared 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 (undefined === subject) || (null === subject);
51 function isObject(subject) {
52 return ('object' === typeof subject) && (null !== subject);
56 function toArray(sequence) {
57 if (Array.isArray(sequence)) {
59 } else if (isNothing(sequence)) {
67 function extend(target, source) {
68 var index, length, key, sourceKeys;
71 sourceKeys = Object.keys(source);
73 for (index = 0, length = sourceKeys.length; index < length; index += 1) {
74 key = sourceKeys[index];
75 target[key] = source[key];
83 function repeat(string, count) {
84 var result = '', cycle;
86 for (cycle = 0; cycle < count; cycle += 1) {
94 function isNegativeZero(number) {
95 return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
99 module.exports.isNothing = isNothing;
100 module.exports.isObject = isObject;
101 module.exports.toArray = toArray;
102 module.exports.repeat = repeat;
103 module.exports.isNegativeZero = isNegativeZero;
104 module.exports.extend = extend;
106 },{}],3:[function(require,module,exports){
110 var common = require('./common');
111 var YAMLException = require('./exception');
112 var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
113 var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
116 var _toString = Object.prototype.toString;
117 var _hasOwnProperty = Object.prototype.hasOwnProperty;
120 var CHAR_TAB = 0x09; /* Tab */
121 var CHAR_LINE_FEED = 0x0A; /* LF */
122 var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
123 var CHAR_SPACE = 0x20; /* Space */
124 var CHAR_EXCLAMATION = 0x21; /* ! */
125 var CHAR_DOUBLE_QUOTE = 0x22; /* " */
126 var CHAR_SHARP = 0x23; /* # */
127 var CHAR_PERCENT = 0x25; /* % */
128 var CHAR_AMPERSAND = 0x26; /* & */
129 var CHAR_SINGLE_QUOTE = 0x27; /* ' */
130 var CHAR_ASTERISK = 0x2A; /* * */
131 var CHAR_COMMA = 0x2C; /* , */
132 var CHAR_MINUS = 0x2D; /* - */
133 var CHAR_COLON = 0x3A; /* : */
134 var CHAR_GREATER_THAN = 0x3E; /* > */
135 var CHAR_QUESTION = 0x3F; /* ? */
136 var CHAR_COMMERCIAL_AT = 0x40; /* @ */
137 var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
138 var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
139 var CHAR_GRAVE_ACCENT = 0x60; /* ` */
140 var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
141 var CHAR_VERTICAL_LINE = 0x7C; /* | */
142 var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
145 var ESCAPE_SEQUENCES = {};
147 ESCAPE_SEQUENCES[0x00] = '\\0';
148 ESCAPE_SEQUENCES[0x07] = '\\a';
149 ESCAPE_SEQUENCES[0x08] = '\\b';
150 ESCAPE_SEQUENCES[0x09] = '\\t';
151 ESCAPE_SEQUENCES[0x0A] = '\\n';
152 ESCAPE_SEQUENCES[0x0B] = '\\v';
153 ESCAPE_SEQUENCES[0x0C] = '\\f';
154 ESCAPE_SEQUENCES[0x0D] = '\\r';
155 ESCAPE_SEQUENCES[0x1B] = '\\e';
156 ESCAPE_SEQUENCES[0x22] = '\\"';
157 ESCAPE_SEQUENCES[0x5C] = '\\\\';
158 ESCAPE_SEQUENCES[0x85] = '\\N';
159 ESCAPE_SEQUENCES[0xA0] = '\\_';
160 ESCAPE_SEQUENCES[0x2028] = '\\L';
161 ESCAPE_SEQUENCES[0x2029] = '\\P';
164 var DEPRECATED_BOOLEANS_SYNTAX = [
165 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
166 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
170 function compileStyleMap(schema, map) {
171 var result, keys, index, length, tag, style, type;
178 keys = Object.keys(map);
180 for (index = 0, length = keys.length; index < length; index += 1) {
182 style = String(map[tag]);
184 if ('!!' === tag.slice(0, 2)) {
185 tag = 'tag:yaml.org,2002:' + tag.slice(2);
188 type = schema.compiledTypeMap[tag];
190 if (type && _hasOwnProperty.call(type.styleAliases, style)) {
191 style = type.styleAliases[style];
201 function encodeHex(character) {
202 var string, handle, length;
204 string = character.toString(16).toUpperCase();
206 if (character <= 0xFF) {
209 } else if (character <= 0xFFFF) {
212 } else if (character <= 0xFFFFFFFF) {
216 throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
219 return '\\' + handle + common.repeat('0', length - string.length) + string;
223 function State(options) {
224 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
225 this.indent = Math.max(1, (options['indent'] || 2));
226 this.skipInvalid = options['skipInvalid'] || false;
227 this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
228 this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
230 this.implicitTypes = this.schema.compiledImplicit;
231 this.explicitTypes = this.schema.compiledExplicit;
236 this.duplicates = [];
237 this.usedDuplicates = null;
241 function generateNextLine(state, level) {
242 return '\n' + common.repeat(' ', state.indent * level);
245 function testImplicitResolving(state, str) {
246 var index, length, type;
248 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
249 type = state.implicitTypes[index];
251 if (type.resolve(str)) {
259 function writeScalar(state, object) {
260 var isQuoted, checkpoint, position, length, character, first;
265 first = object.charCodeAt(0) || 0;
267 if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
268 // Ensure compatibility with YAML 1.0/1.1 loaders.
270 } else if (0 === object.length) {
271 // Quote empty string
273 } else if (CHAR_SPACE === first ||
274 CHAR_SPACE === object.charCodeAt(object.length - 1)) {
276 } else if (CHAR_MINUS === first ||
277 CHAR_QUESTION === first) {
278 // Don't check second symbol for simplicity
282 for (position = 0, length = object.length; position < length; position += 1) {
283 character = object.charCodeAt(position);
286 if (CHAR_TAB === character ||
287 CHAR_LINE_FEED === character ||
288 CHAR_CARRIAGE_RETURN === character ||
289 CHAR_COMMA === character ||
290 CHAR_LEFT_SQUARE_BRACKET === character ||
291 CHAR_RIGHT_SQUARE_BRACKET === character ||
292 CHAR_LEFT_CURLY_BRACKET === character ||
293 CHAR_RIGHT_CURLY_BRACKET === character ||
294 CHAR_SHARP === character ||
295 CHAR_AMPERSAND === character ||
296 CHAR_ASTERISK === character ||
297 CHAR_EXCLAMATION === character ||
298 CHAR_VERTICAL_LINE === character ||
299 CHAR_GREATER_THAN === character ||
300 CHAR_SINGLE_QUOTE === character ||
301 CHAR_DOUBLE_QUOTE === character ||
302 CHAR_PERCENT === character ||
303 CHAR_COMMERCIAL_AT === character ||
304 CHAR_COLON === character ||
305 CHAR_GRAVE_ACCENT === character) {
310 if (ESCAPE_SEQUENCES[character] ||
311 !((0x00020 <= character && character <= 0x00007E) ||
312 (0x00085 === character) ||
313 (0x000A0 <= character && character <= 0x00D7FF) ||
314 (0x0E000 <= character && character <= 0x00FFFD) ||
315 (0x10000 <= character && character <= 0x10FFFF))) {
316 state.dump += object.slice(checkpoint, position);
317 state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character);
318 checkpoint = position + 1;
323 if (checkpoint < position) {
324 state.dump += object.slice(checkpoint, position);
327 if (!isQuoted && testImplicitResolving(state, state.dump)) {
332 state.dump = '"' + state.dump + '"';
336 function writeFlowSequence(state, level, object) {
342 for (index = 0, length = object.length; index < length; index += 1) {
343 // Write only valid elements.
344 if (writeNode(state, level, object[index], false, false)) {
348 _result += state.dump;
353 state.dump = '[' + _result + ']';
356 function writeBlockSequence(state, level, object, compact) {
362 for (index = 0, length = object.length; index < length; index += 1) {
363 // Write only valid elements.
364 if (writeNode(state, level + 1, object[index], true, true)) {
365 if (!compact || 0 !== index) {
366 _result += generateNextLine(state, level);
368 _result += '- ' + state.dump;
373 state.dump = _result || '[]'; // Empty sequence if no valid values.
376 function writeFlowMapping(state, level, object) {
379 objectKeyList = Object.keys(object),
386 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
393 objectKey = objectKeyList[index];
394 objectValue = object[objectKey];
396 if (!writeNode(state, level, objectKey, false, false)) {
397 continue; // Skip this pair because of invalid key;
400 if (state.dump.length > 1024) {
404 pairBuffer += state.dump + ': ';
406 if (!writeNode(state, level, objectValue, false, false)) {
407 continue; // Skip this pair because of invalid value.
410 pairBuffer += state.dump;
412 // Both key and value are valid.
413 _result += pairBuffer;
417 state.dump = '{' + _result + '}';
420 function writeBlockMapping(state, level, object, compact) {
423 objectKeyList = Object.keys(object),
431 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
434 if (!compact || 0 !== index) {
435 pairBuffer += generateNextLine(state, level);
438 objectKey = objectKeyList[index];
439 objectValue = object[objectKey];
441 if (!writeNode(state, level + 1, objectKey, true, true)) {
442 continue; // Skip this pair because of invalid key.
445 explicitPair = (null !== state.tag && '?' !== state.tag) ||
446 (state.dump && state.dump.length > 1024);
449 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
456 pairBuffer += state.dump;
459 pairBuffer += generateNextLine(state, level);
462 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
463 continue; // Skip this pair because of invalid value.
466 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
472 pairBuffer += state.dump;
474 // Both key and value are valid.
475 _result += pairBuffer;
479 state.dump = _result || '{}'; // Empty mapping if no valid pairs.
482 function detectType(state, object, explicit) {
483 var _result, typeList, index, length, type, style;
485 typeList = explicit ? state.explicitTypes : state.implicitTypes;
487 for (index = 0, length = typeList.length; index < length; index += 1) {
488 type = typeList[index];
490 if ((type.instanceOf || type.predicate) &&
491 (!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) &&
492 (!type.predicate || type.predicate(object))) {
494 state.tag = explicit ? type.tag : '?';
496 if (type.represent) {
497 style = state.styleMap[type.tag] || type.defaultStyle;
499 if ('[object Function]' === _toString.call(type.represent)) {
500 _result = type.represent(object, style);
501 } else if (_hasOwnProperty.call(type.represent, style)) {
502 _result = type.represent[style](object, style);
504 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
507 state.dump = _result;
517 // Serializes `object` and writes it to global `result`.
518 // Returns true on success, or false on invalid object.
520 function writeNode(state, level, object, block, compact) {
524 if (!detectType(state, object, false)) {
525 detectType(state, object, true);
528 var type = _toString.call(state.dump);
531 block = (0 > state.flowLevel || state.flowLevel > level);
534 if ((null !== state.tag && '?' !== state.tag) || (2 !== state.indent && level > 0)) {
538 var objectOrArray = '[object Object]' === type || '[object Array]' === type,
543 duplicateIndex = state.duplicates.indexOf(object);
544 duplicate = duplicateIndex !== -1;
547 if (duplicate && state.usedDuplicates[duplicateIndex]) {
548 state.dump = '*ref_' + duplicateIndex;
550 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
551 state.usedDuplicates[duplicateIndex] = true;
553 if ('[object Object]' === type) {
554 if (block && (0 !== Object.keys(state.dump).length)) {
555 writeBlockMapping(state, level, state.dump, compact);
557 state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
560 writeFlowMapping(state, level, state.dump);
562 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
565 } else if ('[object Array]' === type) {
566 if (block && (0 !== state.dump.length)) {
567 writeBlockSequence(state, level, state.dump, compact);
569 state.dump = '&ref_' + duplicateIndex + (0 === level ? '\n' : '') + state.dump;
572 writeFlowSequence(state, level, state.dump);
574 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
577 } else if ('[object String]' === type) {
578 if ('?' !== state.tag) {
579 writeScalar(state, state.dump);
581 } else if (state.skipInvalid) {
584 throw new YAMLException('unacceptable kind of an object to dump ' + type);
587 if (null !== state.tag && '?' !== state.tag) {
588 state.dump = '!<' + state.tag + '> ' + state.dump;
595 function getDuplicateReferences(object, state) {
597 duplicatesIndexes = [],
601 inspectNode(object, objects, duplicatesIndexes);
603 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
604 state.duplicates.push(objects[duplicatesIndexes[index]]);
606 state.usedDuplicates = new Array(length);
609 function inspectNode(object, objects, duplicatesIndexes) {
610 var type = _toString.call(object),
615 if (null !== object && 'object' === typeof object) {
616 index = objects.indexOf(object);
618 if (-1 === duplicatesIndexes.indexOf(index)) {
619 duplicatesIndexes.push(index);
622 objects.push(object);
624 if(Array.isArray(object)) {
625 for (index = 0, length = object.length; index < length; index += 1) {
626 inspectNode(object[index], objects, duplicatesIndexes);
629 objectKeyList = Object.keys(object);
631 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
632 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
639 function dump(input, options) {
640 options = options || {};
642 var state = new State(options);
644 getDuplicateReferences(input, state);
646 if (writeNode(state, 0, input, true, true)) {
647 return state.dump + '\n';
654 function safeDump(input, options) {
655 return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
659 module.exports.dump = dump;
660 module.exports.safeDump = safeDump;
662 },{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){
666 function YAMLException(reason, mark) {
667 this.name = 'YAMLException';
668 this.reason = reason;
670 this.message = this.toString(false);
674 YAMLException.prototype.toString = function toString(compact) {
677 result = 'JS-YAML: ' + (this.reason || '(unknown reason)');
679 if (!compact && this.mark) {
680 result += ' ' + this.mark.toString();
687 module.exports = YAMLException;
689 },{}],5:[function(require,module,exports){
693 var common = require('./common');
694 var YAMLException = require('./exception');
695 var Mark = require('./mark');
696 var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
697 var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
700 var _hasOwnProperty = Object.prototype.hasOwnProperty;
703 var CONTEXT_FLOW_IN = 1;
704 var CONTEXT_FLOW_OUT = 2;
705 var CONTEXT_BLOCK_IN = 3;
706 var CONTEXT_BLOCK_OUT = 4;
709 var CHOMPING_CLIP = 1;
710 var CHOMPING_STRIP = 2;
711 var CHOMPING_KEEP = 3;
714 var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uD800-\uDFFF\uFFFE\uFFFF]/;
715 var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
716 var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
717 var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
718 var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
722 return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
725 function is_WHITE_SPACE(c) {
726 return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
729 function is_WS_OR_EOL(c) {
730 return (c === 0x09/* Tab */) ||
731 (c === 0x20/* Space */) ||
732 (c === 0x0A/* LF */) ||
733 (c === 0x0D/* CR */);
736 function is_FLOW_INDICATOR(c) {
737 return 0x2C/* , */ === c ||
744 function fromHexCode(c) {
747 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
752 if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
753 return lc - 0x61 + 10;
759 function escapedHexLen(c) {
760 if (c === 0x78/* x */) { return 2; }
761 if (c === 0x75/* u */) { return 4; }
762 if (c === 0x55/* U */) { return 8; }
766 function fromDecimalCode(c) {
767 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
774 function simpleEscapeSequence(c) {
775 return (c === 0x30/* 0 */) ? '\x00' :
776 (c === 0x61/* a */) ? '\x07' :
777 (c === 0x62/* b */) ? '\x08' :
778 (c === 0x74/* t */) ? '\x09' :
779 (c === 0x09/* Tab */) ? '\x09' :
780 (c === 0x6E/* n */) ? '\x0A' :
781 (c === 0x76/* v */) ? '\x0B' :
782 (c === 0x66/* f */) ? '\x0C' :
783 (c === 0x72/* r */) ? '\x0D' :
784 (c === 0x65/* e */) ? '\x1B' :
785 (c === 0x20/* Space */) ? ' ' :
786 (c === 0x22/* " */) ? '\x22' :
787 (c === 0x2F/* / */) ? '/' :
788 (c === 0x5C/* \ */) ? '\x5C' :
789 (c === 0x4E/* N */) ? '\x85' :
790 (c === 0x5F/* _ */) ? '\xA0' :
791 (c === 0x4C/* L */) ? '\u2028' :
792 (c === 0x50/* P */) ? '\u2029' : '';
795 function charFromCodepoint(c) {
797 return String.fromCharCode(c);
799 // Encode UTF-16 surrogate pair
800 // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
801 return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
802 ((c - 0x010000) & 0x03FF) + 0xDC00);
806 var simpleEscapeCheck = new Array(256); // integer, for fast access
807 var simpleEscapeMap = new Array(256);
808 for (var i = 0; i < 256; i++) {
809 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
810 simpleEscapeMap[i] = simpleEscapeSequence(i);
814 function State(input, options) {
817 this.filename = options['filename'] || null;
818 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
819 this.onWarning = options['onWarning'] || null;
820 this.legacy = options['legacy'] || false;
822 this.implicitTypes = this.schema.compiledImplicit;
823 this.typeMap = this.schema.compiledTypeMap;
825 this.length = input.length;
835 this.checkLineBreaks;
846 function generateError(state, message) {
847 return new YAMLException(
849 new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
852 function throwError(state, message) {
853 throw generateError(state, message);
856 function throwWarning(state, message) {
857 var error = generateError(state, message);
859 if (state.onWarning) {
860 state.onWarning.call(null, error);
867 var directiveHandlers = {
869 'YAML': function handleYamlDirective(state, name, args) {
871 var match, major, minor;
873 if (null !== state.version) {
874 throwError(state, 'duplication of %YAML directive');
877 if (1 !== args.length) {
878 throwError(state, 'YAML directive accepts exactly one argument');
881 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
883 if (null === match) {
884 throwError(state, 'ill-formed argument of the YAML directive');
887 major = parseInt(match[1], 10);
888 minor = parseInt(match[2], 10);
891 throwError(state, 'unacceptable YAML version of the document');
894 state.version = args[0];
895 state.checkLineBreaks = (minor < 2);
897 if (1 !== minor && 2 !== minor) {
898 throwWarning(state, 'unsupported YAML version of the document');
902 'TAG': function handleTagDirective(state, name, args) {
906 if (2 !== args.length) {
907 throwError(state, 'TAG directive accepts exactly two arguments');
913 if (!PATTERN_TAG_HANDLE.test(handle)) {
914 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
917 if (_hasOwnProperty.call(state.tagMap, handle)) {
918 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
921 if (!PATTERN_TAG_URI.test(prefix)) {
922 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
925 state.tagMap[handle] = prefix;
930 function captureSegment(state, start, end, checkJson) {
931 var _position, _length, _character, _result;
934 _result = state.input.slice(start, end);
937 for (_position = 0, _length = _result.length;
940 _character = _result.charCodeAt(_position);
941 if (!(0x09 === _character ||
942 0x20 <= _character && _character <= 0x10FFFF)) {
943 throwError(state, 'expected valid JSON character');
948 state.result += _result;
952 function mergeMappings(state, destination, source) {
953 var sourceKeys, key, index, quantity;
955 if (!common.isObject(source)) {
956 throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
959 sourceKeys = Object.keys(source);
961 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
962 key = sourceKeys[index];
964 if (!_hasOwnProperty.call(destination, key)) {
965 destination[key] = source[key];
970 function storeMappingPair(state, _result, keyTag, keyNode, valueNode) {
973 keyNode = String(keyNode);
975 if (null === _result) {
979 if ('tag:yaml.org,2002:merge' === keyTag) {
980 if (Array.isArray(valueNode)) {
981 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
982 mergeMappings(state, _result, valueNode[index]);
985 mergeMappings(state, _result, valueNode);
988 _result[keyNode] = valueNode;
994 function readLineBreak(state) {
997 ch = state.input.charCodeAt(state.position);
999 if (0x0A/* LF */ === ch) {
1001 } else if (0x0D/* CR */ === ch) {
1003 if (0x0A/* LF */ === state.input.charCodeAt(state.position)) {
1007 throwError(state, 'a line break is expected');
1011 state.lineStart = state.position;
1014 function skipSeparationSpace(state, allowComments, checkIndent) {
1016 ch = state.input.charCodeAt(state.position);
1019 while (is_WHITE_SPACE(ch)) {
1020 ch = state.input.charCodeAt(++state.position);
1023 if (allowComments && 0x23/* # */ === ch) {
1025 ch = state.input.charCodeAt(++state.position);
1026 } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && 0 !== ch);
1030 readLineBreak(state);
1032 ch = state.input.charCodeAt(state.position);
1034 state.lineIndent = 0;
1036 while (0x20/* Space */ === ch) {
1038 ch = state.input.charCodeAt(++state.position);
1045 if (-1 !== checkIndent && 0 !== lineBreaks && state.lineIndent < checkIndent) {
1046 throwWarning(state, 'deficient indentation');
1052 function testDocumentSeparator(state) {
1053 var _position = state.position,
1056 ch = state.input.charCodeAt(_position);
1058 // Condition state.position === state.lineStart is tested
1059 // in parent on each call, for efficiency. No needs to test here again.
1060 if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
1061 state.input.charCodeAt(_position + 1) === ch &&
1062 state.input.charCodeAt(_position+ 2) === ch) {
1066 ch = state.input.charCodeAt(_position);
1068 if (ch === 0 || is_WS_OR_EOL(ch)) {
1076 function writeFoldedLines(state, count) {
1078 state.result += ' ';
1079 } else if (count > 1) {
1080 state.result += common.repeat('\n', count - 1);
1085 function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1095 _result = state.result,
1098 ch = state.input.charCodeAt(state.position);
1100 if (is_WS_OR_EOL(ch) ||
1101 is_FLOW_INDICATOR(ch) ||
1102 0x23/* # */ === ch ||
1103 0x26/* & */ === ch ||
1104 0x2A/* * */ === ch ||
1105 0x21/* ! */ === ch ||
1106 0x7C/* | */ === ch ||
1107 0x3E/* > */ === ch ||
1108 0x27/* ' */ === ch ||
1109 0x22/* " */ === ch ||
1110 0x25/* % */ === ch ||
1111 0x40/* @ */ === ch ||
1112 0x60/* ` */ === ch) {
1116 if (0x3F/* ? */ === ch || 0x2D/* - */ === ch) {
1117 following = state.input.charCodeAt(state.position + 1);
1119 if (is_WS_OR_EOL(following) ||
1120 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1125 state.kind = 'scalar';
1127 captureStart = captureEnd = state.position;
1128 hasPendingContent = false;
1131 if (0x3A/* : */ === ch) {
1132 following = state.input.charCodeAt(state.position+1);
1134 if (is_WS_OR_EOL(following) ||
1135 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1139 } else if (0x23/* # */ === ch) {
1140 preceding = state.input.charCodeAt(state.position - 1);
1142 if (is_WS_OR_EOL(preceding)) {
1146 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
1147 withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1150 } else if (is_EOL(ch)) {
1152 _lineStart = state.lineStart;
1153 _lineIndent = state.lineIndent;
1154 skipSeparationSpace(state, false, -1);
1156 if (state.lineIndent >= nodeIndent) {
1157 hasPendingContent = true;
1158 ch = state.input.charCodeAt(state.position);
1161 state.position = captureEnd;
1163 state.lineStart = _lineStart;
1164 state.lineIndent = _lineIndent;
1169 if (hasPendingContent) {
1170 captureSegment(state, captureStart, captureEnd, false);
1171 writeFoldedLines(state, state.line - _line);
1172 captureStart = captureEnd = state.position;
1173 hasPendingContent = false;
1176 if (!is_WHITE_SPACE(ch)) {
1177 captureEnd = state.position + 1;
1180 ch = state.input.charCodeAt(++state.position);
1183 captureSegment(state, captureStart, captureEnd, false);
1189 state.result = _result;
1194 function readSingleQuotedScalar(state, nodeIndent) {
1196 captureStart, captureEnd;
1198 ch = state.input.charCodeAt(state.position);
1200 if (0x27/* ' */ !== ch) {
1204 state.kind = 'scalar';
1207 captureStart = captureEnd = state.position;
1209 while (0 !== (ch = state.input.charCodeAt(state.position))) {
1210 if (0x27/* ' */ === ch) {
1211 captureSegment(state, captureStart, state.position, true);
1212 ch = state.input.charCodeAt(++state.position);
1214 if (0x27/* ' */ === ch) {
1215 captureStart = captureEnd = state.position;
1221 } else if (is_EOL(ch)) {
1222 captureSegment(state, captureStart, captureEnd, true);
1223 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1224 captureStart = captureEnd = state.position;
1226 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1227 throwError(state, 'unexpected end of the document within a single quoted scalar');
1231 captureEnd = state.position;
1235 throwError(state, 'unexpected end of the stream within a single quoted scalar');
1238 function readDoubleQuotedScalar(state, nodeIndent) {
1246 ch = state.input.charCodeAt(state.position);
1248 if (0x22/* " */ !== ch) {
1252 state.kind = 'scalar';
1255 captureStart = captureEnd = state.position;
1257 while (0 !== (ch = state.input.charCodeAt(state.position))) {
1258 if (0x22/* " */ === ch) {
1259 captureSegment(state, captureStart, state.position, true);
1263 } else if (0x5C/* \ */ === ch) {
1264 captureSegment(state, captureStart, state.position, true);
1265 ch = state.input.charCodeAt(++state.position);
1268 skipSeparationSpace(state, false, nodeIndent);
1270 //TODO: rework to inline fn with no type cast?
1271 } else if (ch < 256 && simpleEscapeCheck[ch]) {
1272 state.result += simpleEscapeMap[ch];
1275 } else if ((tmp = escapedHexLen(ch)) > 0) {
1279 for (; hexLength > 0; hexLength--) {
1280 ch = state.input.charCodeAt(++state.position);
1282 if ((tmp = fromHexCode(ch)) >= 0) {
1283 hexResult = (hexResult << 4) + tmp;
1286 throwError(state, 'expected hexadecimal character');
1290 state.result += charFromCodepoint(hexResult);
1295 throwError(state, 'unknown escape sequence');
1298 captureStart = captureEnd = state.position;
1300 } else if (is_EOL(ch)) {
1301 captureSegment(state, captureStart, captureEnd, true);
1302 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1303 captureStart = captureEnd = state.position;
1305 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1306 throwError(state, 'unexpected end of the document within a double quoted scalar');
1310 captureEnd = state.position;
1314 throwError(state, 'unexpected end of the stream within a double quoted scalar');
1317 function readFlowCollection(state, nodeIndent) {
1318 var readNext = true,
1322 _anchor = state.anchor,
1333 ch = state.input.charCodeAt(state.position);
1335 if (ch === 0x5B/* [ */) {
1336 terminator = 0x5D/* ] */;
1339 } else if (ch === 0x7B/* { */) {
1340 terminator = 0x7D/* } */;
1347 if (null !== state.anchor) {
1348 state.anchorMap[state.anchor] = _result;
1351 ch = state.input.charCodeAt(++state.position);
1354 skipSeparationSpace(state, true, nodeIndent);
1356 ch = state.input.charCodeAt(state.position);
1358 if (ch === terminator) {
1361 state.anchor = _anchor;
1362 state.kind = isMapping ? 'mapping' : 'sequence';
1363 state.result = _result;
1365 } else if (!readNext) {
1366 throwError(state, 'missed comma between flow collection entries');
1369 keyTag = keyNode = valueNode = null;
1370 isPair = isExplicitPair = false;
1372 if (0x3F/* ? */ === ch) {
1373 following = state.input.charCodeAt(state.position + 1);
1375 if (is_WS_OR_EOL(following)) {
1376 isPair = isExplicitPair = true;
1378 skipSeparationSpace(state, true, nodeIndent);
1383 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1385 keyNode = state.result;
1386 skipSeparationSpace(state, true, nodeIndent);
1388 ch = state.input.charCodeAt(state.position);
1390 if ((isExplicitPair || state.line === _line) && 0x3A/* : */ === ch) {
1392 ch = state.input.charCodeAt(++state.position);
1393 skipSeparationSpace(state, true, nodeIndent);
1394 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1395 valueNode = state.result;
1399 storeMappingPair(state, _result, keyTag, keyNode, valueNode);
1400 } else if (isPair) {
1401 _result.push(storeMappingPair(state, null, keyTag, keyNode, valueNode));
1403 _result.push(keyNode);
1406 skipSeparationSpace(state, true, nodeIndent);
1408 ch = state.input.charCodeAt(state.position);
1410 if (0x2C/* , */ === ch) {
1412 ch = state.input.charCodeAt(++state.position);
1418 throwError(state, 'unexpected end of the stream within a flow collection');
1421 function readBlockScalar(state, nodeIndent) {
1424 chomping = CHOMPING_CLIP,
1425 detectedIndent = false,
1426 textIndent = nodeIndent,
1428 atMoreIndented = false,
1432 ch = state.input.charCodeAt(state.position);
1434 if (ch === 0x7C/* | */) {
1436 } else if (ch === 0x3E/* > */) {
1442 state.kind = 'scalar';
1446 ch = state.input.charCodeAt(++state.position);
1448 if (0x2B/* + */ === ch || 0x2D/* - */ === ch) {
1449 if (CHOMPING_CLIP === chomping) {
1450 chomping = (0x2B/* + */ === ch) ? CHOMPING_KEEP : CHOMPING_STRIP;
1452 throwError(state, 'repeat of a chomping mode identifier');
1455 } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1457 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
1458 } else if (!detectedIndent) {
1459 textIndent = nodeIndent + tmp - 1;
1460 detectedIndent = true;
1462 throwError(state, 'repeat of an indentation width identifier');
1470 if (is_WHITE_SPACE(ch)) {
1471 do { ch = state.input.charCodeAt(++state.position); }
1472 while (is_WHITE_SPACE(ch));
1474 if (0x23/* # */ === ch) {
1475 do { ch = state.input.charCodeAt(++state.position); }
1476 while (!is_EOL(ch) && (0 !== ch));
1481 readLineBreak(state);
1482 state.lineIndent = 0;
1484 ch = state.input.charCodeAt(state.position);
1486 while ((!detectedIndent || state.lineIndent < textIndent) &&
1487 (0x20/* Space */ === ch)) {
1489 ch = state.input.charCodeAt(++state.position);
1492 if (!detectedIndent && state.lineIndent > textIndent) {
1493 textIndent = state.lineIndent;
1501 // End of the scalar.
1502 if (state.lineIndent < textIndent) {
1504 // Perform the chomping.
1505 if (chomping === CHOMPING_KEEP) {
1506 state.result += common.repeat('\n', emptyLines);
1507 } else if (chomping === CHOMPING_CLIP) {
1508 if (detectedIndent) { // i.e. only if the scalar is not empty.
1509 state.result += '\n';
1513 // Break this `while` cycle and go to the funciton's epilogue.
1517 // Folded style: use fancy rules to handle line breaks.
1520 // Lines starting with white space characters (more-indented lines) are not folded.
1521 if (is_WHITE_SPACE(ch)) {
1522 atMoreIndented = true;
1523 state.result += common.repeat('\n', emptyLines + 1);
1525 // End of more-indented block.
1526 } else if (atMoreIndented) {
1527 atMoreIndented = false;
1528 state.result += common.repeat('\n', emptyLines + 1);
1530 // Just one line break - perceive as the same line.
1531 } else if (0 === emptyLines) {
1532 if (detectedIndent) { // i.e. only if we have already read some scalar content.
1533 state.result += ' ';
1536 // Several line breaks - perceive as different lines.
1538 state.result += common.repeat('\n', emptyLines);
1541 // Literal style: just add exact number of line breaks between content lines.
1544 // If current line isn't the first one - count line break from the last content line.
1545 if (detectedIndent) {
1546 state.result += common.repeat('\n', emptyLines + 1);
1548 // In case of the first content line - count only empty lines.
1550 state.result += common.repeat('\n', emptyLines);
1554 detectedIndent = true;
1556 captureStart = state.position;
1558 while (!is_EOL(ch) && (0 !== ch))
1559 { ch = state.input.charCodeAt(++state.position); }
1561 captureSegment(state, captureStart, state.position, false);
1567 function readBlockSequence(state, nodeIndent) {
1570 _anchor = state.anchor,
1576 if (null !== state.anchor) {
1577 state.anchorMap[state.anchor] = _result;
1580 ch = state.input.charCodeAt(state.position);
1584 if (0x2D/* - */ !== ch) {
1588 following = state.input.charCodeAt(state.position + 1);
1590 if (!is_WS_OR_EOL(following)) {
1597 if (skipSeparationSpace(state, true, -1)) {
1598 if (state.lineIndent <= nodeIndent) {
1600 ch = state.input.charCodeAt(state.position);
1606 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1607 _result.push(state.result);
1608 skipSeparationSpace(state, true, -1);
1610 ch = state.input.charCodeAt(state.position);
1612 if ((state.line === _line || state.lineIndent > nodeIndent) && (0 !== ch)) {
1613 throwError(state, 'bad indentation of a sequence entry');
1614 } else if (state.lineIndent < nodeIndent) {
1621 state.anchor = _anchor;
1622 state.kind = 'sequence';
1623 state.result = _result;
1630 function readBlockMapping(state, nodeIndent, flowIndent) {
1635 _anchor = state.anchor,
1640 atExplicitKey = false,
1644 if (null !== state.anchor) {
1645 state.anchorMap[state.anchor] = _result;
1648 ch = state.input.charCodeAt(state.position);
1651 following = state.input.charCodeAt(state.position + 1);
1652 _line = state.line; // Save the current line.
1655 // Explicit notation case. There are two separate blocks:
1656 // first for the key (denoted by "?") and second for the value (denoted by ":")
1658 if ((0x3F/* ? */ === ch || 0x3A/* : */ === ch) && is_WS_OR_EOL(following)) {
1660 if (0x3F/* ? */ === ch) {
1661 if (atExplicitKey) {
1662 storeMappingPair(state, _result, keyTag, keyNode, null);
1663 keyTag = keyNode = valueNode = null;
1667 atExplicitKey = true;
1668 allowCompact = true;
1670 } else if (atExplicitKey) {
1671 // i.e. 0x3A/* : */ === character after the explicit key.
1672 atExplicitKey = false;
1673 allowCompact = true;
1676 throwError(state, 'incomplete explicit mapping pair; a key node is missed');
1679 state.position += 1;
1683 // Implicit notation case. Flow-style node as the key first, then ":", and the value.
1685 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1687 if (state.line === _line) {
1688 ch = state.input.charCodeAt(state.position);
1690 while (is_WHITE_SPACE(ch)) {
1691 ch = state.input.charCodeAt(++state.position);
1694 if (0x3A/* : */ === ch) {
1695 ch = state.input.charCodeAt(++state.position);
1697 if (!is_WS_OR_EOL(ch)) {
1698 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
1701 if (atExplicitKey) {
1702 storeMappingPair(state, _result, keyTag, keyNode, null);
1703 keyTag = keyNode = valueNode = null;
1707 atExplicitKey = false;
1708 allowCompact = false;
1710 keyNode = state.result;
1712 } else if (detected) {
1713 throwError(state, 'can not read an implicit mapping pair; a colon is missed');
1717 state.anchor = _anchor;
1718 return true; // Keep the result of `composeNode`.
1721 } else if (detected) {
1722 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
1726 state.anchor = _anchor;
1727 return true; // Keep the result of `composeNode`.
1731 break; // Reading is done. Go to the epilogue.
1735 // Common reading code for both explicit and implicit notations.
1737 if (state.line === _line || state.lineIndent > nodeIndent) {
1738 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1739 if (atExplicitKey) {
1740 keyNode = state.result;
1742 valueNode = state.result;
1746 if (!atExplicitKey) {
1747 storeMappingPair(state, _result, keyTag, keyNode, valueNode);
1748 keyTag = keyNode = valueNode = null;
1751 skipSeparationSpace(state, true, -1);
1752 ch = state.input.charCodeAt(state.position);
1755 if (state.lineIndent > nodeIndent && (0 !== ch)) {
1756 throwError(state, 'bad indentation of a mapping entry');
1757 } else if (state.lineIndent < nodeIndent) {
1766 // Special case: last mapping's node contains only the key in explicit notation.
1767 if (atExplicitKey) {
1768 storeMappingPair(state, _result, keyTag, keyNode, null);
1771 // Expose the resulting mapping.
1774 state.anchor = _anchor;
1775 state.kind = 'mapping';
1776 state.result = _result;
1782 function readTagProperty(state) {
1790 ch = state.input.charCodeAt(state.position);
1792 if (0x21/* ! */ !== ch) {
1796 if (null !== state.tag) {
1797 throwError(state, 'duplication of a tag property');
1800 ch = state.input.charCodeAt(++state.position);
1802 if (0x3C/* < */ === ch) {
1804 ch = state.input.charCodeAt(++state.position);
1806 } else if (0x21/* ! */ === ch) {
1809 ch = state.input.charCodeAt(++state.position);
1815 _position = state.position;
1818 do { ch = state.input.charCodeAt(++state.position); }
1819 while (0 !== ch && 0x3E/* > */ !== ch);
1821 if (state.position < state.length) {
1822 tagName = state.input.slice(_position, state.position);
1823 ch = state.input.charCodeAt(++state.position);
1825 throwError(state, 'unexpected end of the stream within a verbatim tag');
1828 while (0 !== ch && !is_WS_OR_EOL(ch)) {
1830 if (0x21/* ! */ === ch) {
1832 tagHandle = state.input.slice(_position - 1, state.position + 1);
1834 if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1835 throwError(state, 'named tag handle cannot contain such characters');
1839 _position = state.position + 1;
1841 throwError(state, 'tag suffix cannot contain exclamation marks');
1845 ch = state.input.charCodeAt(++state.position);
1848 tagName = state.input.slice(_position, state.position);
1850 if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1851 throwError(state, 'tag suffix cannot contain flow indicator characters');
1855 if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1856 throwError(state, 'tag name cannot contain such characters: ' + tagName);
1860 state.tag = tagName;
1862 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
1863 state.tag = state.tagMap[tagHandle] + tagName;
1865 } else if ('!' === tagHandle) {
1866 state.tag = '!' + tagName;
1868 } else if ('!!' === tagHandle) {
1869 state.tag = 'tag:yaml.org,2002:' + tagName;
1872 throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1878 function readAnchorProperty(state) {
1882 ch = state.input.charCodeAt(state.position);
1884 if (0x26/* & */ !== ch) {
1888 if (null !== state.anchor) {
1889 throwError(state, 'duplication of an anchor property');
1892 ch = state.input.charCodeAt(++state.position);
1893 _position = state.position;
1895 while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1896 ch = state.input.charCodeAt(++state.position);
1899 if (state.position === _position) {
1900 throwError(state, 'name of an anchor node must contain at least one character');
1903 state.anchor = state.input.slice(_position, state.position);
1907 function readAlias(state) {
1908 var _position, alias,
1910 input = state.input,
1913 ch = state.input.charCodeAt(state.position);
1915 if (0x2A/* * */ !== ch) {
1919 ch = state.input.charCodeAt(++state.position);
1920 _position = state.position;
1922 while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1923 ch = state.input.charCodeAt(++state.position);
1926 if (state.position === _position) {
1927 throwError(state, 'name of an alias node must contain at least one character');
1930 alias = state.input.slice(_position, state.position);
1932 if (!state.anchorMap.hasOwnProperty(alias)) {
1933 throwError(state, 'unidentified alias "' + alias + '"');
1936 state.result = state.anchorMap[alias];
1937 skipSeparationSpace(state, true, -1);
1941 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1942 var allowBlockStyles,
1944 allowBlockCollections,
1945 indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
1956 state.anchor = null;
1958 state.result = null;
1960 allowBlockStyles = allowBlockScalars = allowBlockCollections =
1961 CONTEXT_BLOCK_OUT === nodeContext ||
1962 CONTEXT_BLOCK_IN === nodeContext;
1965 if (skipSeparationSpace(state, true, -1)) {
1968 if (state.lineIndent > parentIndent) {
1970 } else if (state.lineIndent === parentIndent) {
1972 } else if (state.lineIndent < parentIndent) {
1978 if (1 === indentStatus) {
1979 while (readTagProperty(state) || readAnchorProperty(state)) {
1980 if (skipSeparationSpace(state, true, -1)) {
1982 allowBlockCollections = allowBlockStyles;
1984 if (state.lineIndent > parentIndent) {
1986 } else if (state.lineIndent === parentIndent) {
1988 } else if (state.lineIndent < parentIndent) {
1992 allowBlockCollections = false;
1997 if (allowBlockCollections) {
1998 allowBlockCollections = atNewLine || allowCompact;
2001 if (1 === indentStatus || CONTEXT_BLOCK_OUT === nodeContext) {
2002 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2003 flowIndent = parentIndent;
2005 flowIndent = parentIndent + 1;
2008 blockIndent = state.position - state.lineStart;
2010 if (1 === indentStatus) {
2011 if (allowBlockCollections &&
2012 (readBlockSequence(state, blockIndent) ||
2013 readBlockMapping(state, blockIndent, flowIndent)) ||
2014 readFlowCollection(state, flowIndent)) {
2017 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
2018 readSingleQuotedScalar(state, flowIndent) ||
2019 readDoubleQuotedScalar(state, flowIndent)) {
2022 } else if (readAlias(state)) {
2025 if (null !== state.tag || null !== state.anchor) {
2026 throwError(state, 'alias node should not have any properties');
2029 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2032 if (null === state.tag) {
2037 if (null !== state.anchor) {
2038 state.anchorMap[state.anchor] = state.result;
2041 } else if (0 === indentStatus) {
2042 // Special case: block sequences are allowed to have same indentation level as the parent.
2043 // http://www.yaml.org/spec/1.2/spec.html#id2799784
2044 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2048 if (null !== state.tag && '!' !== state.tag) {
2049 if ('?' === state.tag) {
2050 for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
2051 typeIndex < typeQuantity;
2053 type = state.implicitTypes[typeIndex];
2055 // Implicit resolving is not allowed for non-scalar types, and '?'
2056 // non-specific tag is only assigned to plain scalars. So, it isn't
2057 // needed to check for 'kind' conformity.
2059 if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
2060 state.result = type.construct(state.result);
2061 state.tag = type.tag;
2062 if (null !== state.anchor) {
2063 state.anchorMap[state.anchor] = state.result;
2068 } else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
2069 type = state.typeMap[state.tag];
2071 if (null !== state.result && type.kind !== state.kind) {
2072 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2075 if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
2076 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
2078 state.result = type.construct(state.result);
2079 if (null !== state.anchor) {
2080 state.anchorMap[state.anchor] = state.result;
2084 throwWarning(state, 'unknown tag !<' + state.tag + '>');
2088 return null !== state.tag || null !== state.anchor || hasContent;
2091 function readDocument(state) {
2092 var documentStart = state.position,
2096 hasDirectives = false,
2099 state.version = null;
2100 state.checkLineBreaks = state.legacy;
2102 state.anchorMap = {};
2104 while (0 !== (ch = state.input.charCodeAt(state.position))) {
2105 skipSeparationSpace(state, true, -1);
2107 ch = state.input.charCodeAt(state.position);
2109 if (state.lineIndent > 0 || 0x25/* % */ !== ch) {
2113 hasDirectives = true;
2114 ch = state.input.charCodeAt(++state.position);
2115 _position = state.position;
2117 while (0 !== ch && !is_WS_OR_EOL(ch)) {
2118 ch = state.input.charCodeAt(++state.position);
2121 directiveName = state.input.slice(_position, state.position);
2124 if (directiveName.length < 1) {
2125 throwError(state, 'directive name must not be less than one character in length');
2129 while (is_WHITE_SPACE(ch)) {
2130 ch = state.input.charCodeAt(++state.position);
2133 if (0x23/* # */ === ch) {
2134 do { ch = state.input.charCodeAt(++state.position); }
2135 while (0 !== ch && !is_EOL(ch));
2143 _position = state.position;
2145 while (0 !== ch && !is_WS_OR_EOL(ch)) {
2146 ch = state.input.charCodeAt(++state.position);
2149 directiveArgs.push(state.input.slice(_position, state.position));
2153 readLineBreak(state);
2156 if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2157 directiveHandlers[directiveName](state, directiveName, directiveArgs);
2159 throwWarning(state, 'unknown document directive "' + directiveName + '"');
2163 skipSeparationSpace(state, true, -1);
2165 if (0 === state.lineIndent &&
2166 0x2D/* - */ === state.input.charCodeAt(state.position) &&
2167 0x2D/* - */ === state.input.charCodeAt(state.position + 1) &&
2168 0x2D/* - */ === state.input.charCodeAt(state.position + 2)) {
2169 state.position += 3;
2170 skipSeparationSpace(state, true, -1);
2172 } else if (hasDirectives) {
2173 throwError(state, 'directives end mark is expected');
2176 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2177 skipSeparationSpace(state, true, -1);
2179 if (state.checkLineBreaks &&
2180 PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2181 throwWarning(state, 'non-ASCII line breaks are interpreted as content');
2184 state.documents.push(state.result);
2186 if (state.position === state.lineStart && testDocumentSeparator(state)) {
2188 if (0x2E/* . */ === state.input.charCodeAt(state.position)) {
2189 state.position += 3;
2190 skipSeparationSpace(state, true, -1);
2195 if (state.position < (state.length - 1)) {
2196 throwError(state, 'end of the stream or a document separator is expected');
2203 function loadDocuments(input, options) {
2204 input = String(input);
2205 options = options || {};
2207 if (0 !== input.length &&
2208 0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
2209 0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
2213 var state = new State(input, options);
2215 if (PATTERN_NON_PRINTABLE.test(state.input)) {
2216 throwError(state, 'the stream contains non-printable characters');
2219 // Use 0 as string terminator. That significantly simplifies bounds check.
2220 state.input += '\0';
2222 while (0x20/* Space */ === state.input.charCodeAt(state.position)) {
2223 state.lineIndent += 1;
2224 state.position += 1;
2227 while (state.position < (state.length - 1)) {
2228 readDocument(state);
2231 return state.documents;
2235 function loadAll(input, iterator, options) {
2236 var documents = loadDocuments(input, options), index, length;
2238 for (index = 0, length = documents.length; index < length; index += 1) {
2239 iterator(documents[index]);
2244 function load(input, options) {
2245 var documents = loadDocuments(input, options), index, length;
2247 if (0 === documents.length) {
2249 } else if (1 === documents.length) {
2250 return documents[0];
2252 throw new YAMLException('expected a single document in the stream, but found more');
2257 function safeLoadAll(input, output, options) {
2258 loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2262 function safeLoad(input, options) {
2263 return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2267 module.exports.loadAll = loadAll;
2268 module.exports.load = load;
2269 module.exports.safeLoadAll = safeLoadAll;
2270 module.exports.safeLoad = safeLoad;
2272 },{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){
2276 var common = require('./common');
2279 function Mark(name, buffer, position, line, column) {
2281 this.buffer = buffer;
2282 this.position = position;
2284 this.column = column;
2288 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2289 var head, start, tail, end, snippet;
2295 indent = indent || 4;
2296 maxLength = maxLength || 75;
2299 start = this.position;
2301 while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
2303 if (this.position - start > (maxLength / 2 - 1)) {
2311 end = this.position;
2313 while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
2315 if (end - this.position > (maxLength / 2 - 1)) {
2322 snippet = this.buffer.slice(start, end);
2324 return common.repeat(' ', indent) + head + snippet + tail + '\n' +
2325 common.repeat(' ', indent + this.position - start + head.length) + '^';
2329 Mark.prototype.toString = function toString(compact) {
2330 var snippet, where = '';
2333 where += 'in "' + this.name + '" ';
2336 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
2339 snippet = this.getSnippet();
2342 where += ':\n' + snippet;
2350 module.exports = Mark;
2352 },{"./common":2}],7:[function(require,module,exports){
2356 var common = require('./common');
2357 var YAMLException = require('./exception');
2358 var Type = require('./type');
2361 function compileList(schema, name, result) {
2364 schema.include.forEach(function (includedSchema) {
2365 result = compileList(includedSchema, name, result);
2368 schema[name].forEach(function (currentType) {
2369 result.forEach(function (previousType, previousIndex) {
2370 if (previousType.tag === currentType.tag) {
2371 exclude.push(previousIndex);
2375 result.push(currentType);
2378 return result.filter(function (type, index) {
2379 return -1 === exclude.indexOf(index);
2384 function compileMap(/* lists... */) {
2385 var result = {}, index, length;
2387 function collectType(type) {
2388 result[type.tag] = type;
2391 for (index = 0, length = arguments.length; index < length; index += 1) {
2392 arguments[index].forEach(collectType);
2399 function Schema(definition) {
2400 this.include = definition.include || [];
2401 this.implicit = definition.implicit || [];
2402 this.explicit = definition.explicit || [];
2404 this.implicit.forEach(function (type) {
2405 if (type.loadKind && 'scalar' !== type.loadKind) {
2406 throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
2410 this.compiledImplicit = compileList(this, 'implicit', []);
2411 this.compiledExplicit = compileList(this, 'explicit', []);
2412 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
2416 Schema.DEFAULT = null;
2419 Schema.create = function createSchema() {
2422 switch (arguments.length) {
2424 schemas = Schema.DEFAULT;
2425 types = arguments[0];
2429 schemas = arguments[0];
2430 types = arguments[1];
2434 throw new YAMLException('Wrong number of arguments for Schema.create function');
2437 schemas = common.toArray(schemas);
2438 types = common.toArray(types);
2440 if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
2441 throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
2444 if (!types.every(function (type) { return type instanceof Type; })) {
2445 throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
2455 module.exports = Schema;
2457 },{"./common":2,"./exception":4,"./type":13}],8:[function(require,module,exports){
2458 // Standard YAML's Core schema.
2459 // http://www.yaml.org/spec/1.2/spec.html#id2804923
2461 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2462 // So, Core schema has no distinctions from JSON schema is JS-YAML.
2468 var Schema = require('../schema');
2471 module.exports = new Schema({
2477 },{"../schema":7,"./json":12}],9:[function(require,module,exports){
2478 // JS-YAML's default schema for `load` function.
2479 // It is not described in the YAML specification.
2481 // This schema is based on JS-YAML's default safe schema and includes
2482 // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
2484 // Also this schema is used as default base schema at `Schema.create` function.
2490 var Schema = require('../schema');
2493 module.exports = Schema.DEFAULT = new Schema({
2495 require('./default_safe')
2498 require('../type/js/undefined'),
2499 require('../type/js/regexp'),
2500 require('../type/js/function')
2504 },{"../schema":7,"../type/js/function":18,"../type/js/regexp":19,"../type/js/undefined":20,"./default_safe":10}],10:[function(require,module,exports){
2505 // JS-YAML's default schema for `safeLoad` function.
2506 // It is not described in the YAML specification.
2508 // This schema is based on standard YAML's Core schema and includes most of
2509 // extra types described at YAML tag repository. (http://yaml.org/type/)
2515 var Schema = require('../schema');
2518 module.exports = new Schema({
2523 require('../type/timestamp'),
2524 require('../type/merge')
2527 require('../type/binary'),
2528 require('../type/omap'),
2529 require('../type/pairs'),
2530 require('../type/set')
2534 },{"../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){
2535 // Standard YAML's Failsafe schema.
2536 // http://www.yaml.org/spec/1.2/spec.html#id2802346
2542 var Schema = require('../schema');
2545 module.exports = new Schema({
2547 require('../type/str'),
2548 require('../type/seq'),
2549 require('../type/map')
2553 },{"../schema":7,"../type/map":21,"../type/seq":26,"../type/str":28}],12:[function(require,module,exports){
2554 // Standard YAML's JSON schema.
2555 // http://www.yaml.org/spec/1.2/spec.html#id2803231
2557 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2558 // So, this schema is not such strict as defined in the YAML specification.
2559 // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
2565 var Schema = require('../schema');
2568 module.exports = new Schema({
2570 require('./failsafe')
2573 require('../type/null'),
2574 require('../type/bool'),
2575 require('../type/int'),
2576 require('../type/float')
2580 },{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){
2583 var YAMLException = require('./exception');
2585 var TYPE_CONSTRUCTOR_OPTIONS = [
2596 var YAML_NODE_KINDS = [
2602 function compileStyleAliases(map) {
2606 Object.keys(map).forEach(function (style) {
2607 map[style].forEach(function (alias) {
2608 result[String(alias)] = style;
2616 function Type(tag, options) {
2617 options = options || {};
2619 Object.keys(options).forEach(function (name) {
2620 if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
2621 throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
2625 // TODO: Add tag format check.
2627 this.kind = options['kind'] || null;
2628 this.resolve = options['resolve'] || function () { return true; };
2629 this.construct = options['construct'] || function (data) { return data; };
2630 this.instanceOf = options['instanceOf'] || null;
2631 this.predicate = options['predicate'] || null;
2632 this.represent = options['represent'] || null;
2633 this.defaultStyle = options['defaultStyle'] || null;
2634 this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
2636 if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
2637 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
2641 module.exports = Type;
2643 },{"./exception":4}],14:[function(require,module,exports){
2647 // A trick for browserified version.
2648 // Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
2649 var NodeBuffer = require('buffer').Buffer;
2650 var Type = require('../type');
2653 // [ 64, 65, 66 ] -> [ padding, CR, LF ]
2654 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
2657 function resolveYamlBinary(data) {
2658 if (null === data) {
2662 var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
2664 // Convert one by one.
2665 for (idx = 0; idx < max; idx ++) {
2666 code = map.indexOf(data.charAt(idx));
2669 if (code > 64) { continue; }
2671 // Fail on illegal characters
2672 if (code < 0) { return false; }
2677 // If there are any bits left, source was corrupted
2678 return (bitlen % 8) === 0;
2681 function constructYamlBinary(data) {
2682 var code, idx, tailbits,
2683 input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
2689 // Collect by 6*4 bits (3 bytes)
2691 for (idx = 0; idx < max; idx++) {
2692 if ((idx % 4 === 0) && idx) {
2693 result.push((bits >> 16) & 0xFF);
2694 result.push((bits >> 8) & 0xFF);
2695 result.push(bits & 0xFF);
2698 bits = (bits << 6) | map.indexOf(input.charAt(idx));
2703 tailbits = (max % 4)*6;
2705 if (tailbits === 0) {
2706 result.push((bits >> 16) & 0xFF);
2707 result.push((bits >> 8) & 0xFF);
2708 result.push(bits & 0xFF);
2709 } else if (tailbits === 18) {
2710 result.push((bits >> 10) & 0xFF);
2711 result.push((bits >> 2) & 0xFF);
2712 } else if (tailbits === 12) {
2713 result.push((bits >> 4) & 0xFF);
2716 // Wrap into Buffer for NodeJS and leave Array for browser
2718 return new NodeBuffer(result);
2724 function representYamlBinary(object /*, style*/) {
2725 var result = '', bits = 0, idx, tail,
2726 max = object.length,
2729 // Convert every three bytes to 4 ASCII characters.
2731 for (idx = 0; idx < max; idx++) {
2732 if ((idx % 3 === 0) && idx) {
2733 result += map[(bits >> 18) & 0x3F];
2734 result += map[(bits >> 12) & 0x3F];
2735 result += map[(bits >> 6) & 0x3F];
2736 result += map[bits & 0x3F];
2739 bits = (bits << 8) + object[idx];
2747 result += map[(bits >> 18) & 0x3F];
2748 result += map[(bits >> 12) & 0x3F];
2749 result += map[(bits >> 6) & 0x3F];
2750 result += map[bits & 0x3F];
2751 } else if (tail === 2) {
2752 result += map[(bits >> 10) & 0x3F];
2753 result += map[(bits >> 4) & 0x3F];
2754 result += map[(bits << 2) & 0x3F];
2756 } else if (tail === 1) {
2757 result += map[(bits >> 2) & 0x3F];
2758 result += map[(bits << 4) & 0x3F];
2766 function isBinary(object) {
2767 return NodeBuffer && NodeBuffer.isBuffer(object);
2770 module.exports = new Type('tag:yaml.org,2002:binary', {
2772 resolve: resolveYamlBinary,
2773 construct: constructYamlBinary,
2774 predicate: isBinary,
2775 represent: representYamlBinary
2778 },{"../type":13,"buffer":30}],15:[function(require,module,exports){
2781 var Type = require('../type');
2783 function resolveYamlBoolean(data) {
2784 if (null === data) {
2788 var max = data.length;
2790 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
2791 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
2794 function constructYamlBoolean(data) {
2795 return data === 'true' ||
2800 function isBoolean(object) {
2801 return '[object Boolean]' === Object.prototype.toString.call(object);
2804 module.exports = new Type('tag:yaml.org,2002:bool', {
2806 resolve: resolveYamlBoolean,
2807 construct: constructYamlBoolean,
2808 predicate: isBoolean,
2810 lowercase: function (object) { return object ? 'true' : 'false'; },
2811 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
2812 camelcase: function (object) { return object ? 'True' : 'False'; }
2814 defaultStyle: 'lowercase'
2817 },{"../type":13}],16:[function(require,module,exports){
2820 var common = require('../common');
2821 var Type = require('../type');
2823 var YAML_FLOAT_PATTERN = new RegExp(
2824 '^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
2825 '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' +
2826 '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
2827 '|[-+]?\\.(?:inf|Inf|INF)' +
2828 '|\\.(?:nan|NaN|NAN))$');
2830 function resolveYamlFloat(data) {
2831 if (null === data) {
2835 var value, sign, base, digits;
2837 if (!YAML_FLOAT_PATTERN.test(data)) {
2843 function constructYamlFloat(data) {
2844 var value, sign, base, digits;
2846 value = data.replace(/_/g, '').toLowerCase();
2847 sign = '-' === value[0] ? -1 : 1;
2850 if (0 <= '+-'.indexOf(value[0])) {
2851 value = value.slice(1);
2854 if ('.inf' === value) {
2855 return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
2857 } else if ('.nan' === value) {
2860 } else if (0 <= value.indexOf(':')) {
2861 value.split(':').forEach(function (v) {
2862 digits.unshift(parseFloat(v, 10));
2868 digits.forEach(function (d) {
2873 return sign * value;
2876 return sign * parseFloat(value, 10);
2880 function representYamlFloat(object, style) {
2881 if (isNaN(object)) {
2890 } else if (Number.POSITIVE_INFINITY === object) {
2899 } else if (Number.NEGATIVE_INFINITY === object) {
2908 } else if (common.isNegativeZero(object)) {
2911 return object.toString(10);
2915 function isFloat(object) {
2916 return ('[object Number]' === Object.prototype.toString.call(object)) &&
2917 (0 !== object % 1 || common.isNegativeZero(object));
2920 module.exports = new Type('tag:yaml.org,2002:float', {
2922 resolve: resolveYamlFloat,
2923 construct: constructYamlFloat,
2925 represent: representYamlFloat,
2926 defaultStyle: 'lowercase'
2929 },{"../common":2,"../type":13}],17:[function(require,module,exports){
2932 var common = require('../common');
2933 var Type = require('../type');
2935 function isHexCode(c) {
2936 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
2937 ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
2938 ((0x61/* a */ <= c) && (c <= 0x66/* f */));
2941 function isOctCode(c) {
2942 return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
2945 function isDecCode(c) {
2946 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
2949 function resolveYamlInteger(data) {
2950 if (null === data) {
2954 var max = data.length,
2959 if (!max) { return false; }
2964 if (ch === '-' || ch === '+') {
2970 if (index+1 === max) { return true; }
2973 // base 2, base 8, base 16
2979 for (; index < max; index++) {
2981 if (ch === '_') { continue; }
2982 if (ch !== '0' && ch !== '1') {
2995 for (; index < max; index++) {
2997 if (ch === '_') { continue; }
2998 if (!isHexCode(data.charCodeAt(index))) {
3007 for (; index < max; index++) {
3009 if (ch === '_') { continue; }
3010 if (!isOctCode(data.charCodeAt(index))) {
3018 // base 10 (except 0) or base 60
3020 for (; index < max; index++) {
3022 if (ch === '_') { continue; }
3023 if (ch === ':') { break; }
3024 if (!isDecCode(data.charCodeAt(index))) {
3030 if (!hasDigits) { return false; }
3032 // if !base60 - done;
3033 if (ch !== ':') { return true; }
3035 // base60 almost not used, no needs to optimize
3036 return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
3039 function constructYamlInteger(data) {
3040 var value = data, sign = 1, ch, base, digits = [];
3042 if (value.indexOf('_') !== -1) {
3043 value = value.replace(/_/g, '');
3048 if (ch === '-' || ch === '+') {
3049 if (ch === '-') { sign = -1; }
3050 value = value.slice(1);
3054 if ('0' === value) {
3059 if (value[1] === 'b') {
3060 return sign * parseInt(value.slice(2), 2);
3062 if (value[1] === 'x') {
3063 return sign * parseInt(value, 16);
3065 return sign * parseInt(value, 8);
3069 if (value.indexOf(':') !== -1) {
3070 value.split(':').forEach(function (v) {
3071 digits.unshift(parseInt(v, 10));
3077 digits.forEach(function (d) {
3078 value += (d * base);
3082 return sign * value;
3086 return sign * parseInt(value, 10);
3089 function isInteger(object) {
3090 return ('[object Number]' === Object.prototype.toString.call(object)) &&
3091 (0 === object % 1 && !common.isNegativeZero(object));
3094 module.exports = new Type('tag:yaml.org,2002:int', {
3096 resolve: resolveYamlInteger,
3097 construct: constructYamlInteger,
3098 predicate: isInteger,
3100 binary: function (object) { return '0b' + object.toString(2); },
3101 octal: function (object) { return '0' + object.toString(8); },
3102 decimal: function (object) { return object.toString(10); },
3103 hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
3105 defaultStyle: 'decimal',
3107 binary: [ 2, 'bin' ],
3108 octal: [ 8, 'oct' ],
3109 decimal: [ 10, 'dec' ],
3110 hexadecimal: [ 16, 'hex' ]
3114 },{"../common":2,"../type":13}],18:[function(require,module,exports){
3119 // Browserified version does not have esprima
3121 // 1. For node.js just require module as deps
3122 // 2. For browser try to require mudule via external AMD system.
3123 // If not found - try to fallback to window.esprima. If not
3124 // found too - then fail to parse.
3127 esprima = require('esprima');
3130 if (typeof window !== 'undefined') { esprima = window.esprima; }
3133 var Type = require('../../type');
3135 function resolveJavascriptFunction(data) {
3136 if (null === data) {
3141 var source = '(' + data + ')',
3142 ast = esprima.parse(source, { range: true }),
3146 if ('Program' !== ast.type ||
3147 1 !== ast.body.length ||
3148 'ExpressionStatement' !== ast.body[0].type ||
3149 'FunctionExpression' !== ast.body[0].expression.type) {
3159 function constructJavascriptFunction(data) {
3160 /*jslint evil:true*/
3162 var source = '(' + data + ')',
3163 ast = esprima.parse(source, { range: true }),
3167 if ('Program' !== ast.type ||
3168 1 !== ast.body.length ||
3169 'ExpressionStatement' !== ast.body[0].type ||
3170 'FunctionExpression' !== ast.body[0].expression.type) {
3171 throw new Error('Failed to resolve function');
3174 ast.body[0].expression.params.forEach(function (param) {
3175 params.push(param.name);
3178 body = ast.body[0].expression.body.range;
3180 // Esprima's ranges include the first '{' and the last '}' characters on
3181 // function expressions. So cut them out.
3182 return new Function(params, source.slice(body[0]+1, body[1]-1));
3185 function representJavascriptFunction(object /*, style*/) {
3186 return object.toString();
3189 function isFunction(object) {
3190 return '[object Function]' === Object.prototype.toString.call(object);
3193 module.exports = new Type('tag:yaml.org,2002:js/function', {
3195 resolve: resolveJavascriptFunction,
3196 construct: constructJavascriptFunction,
3197 predicate: isFunction,
3198 represent: representJavascriptFunction
3201 },{"../../type":13,"esprima":"esprima"}],19:[function(require,module,exports){
3204 var Type = require('../../type');
3206 function resolveJavascriptRegExp(data) {
3207 if (null === data) {
3211 if (0 === data.length) {
3216 tail = /\/([gim]*)$/.exec(data),
3219 // if regexp starts with '/' it can have modifiers and must be properly closed
3220 // `/foo/gim` - modifiers tail can be maximum 3 chars
3221 if ('/' === regexp[0]) {
3223 modifiers = tail[1];
3226 if (modifiers.length > 3) { return false; }
3227 // if expression starts with /, is should be properly terminated
3228 if (regexp[regexp.length - modifiers.length - 1] !== '/') { return false; }
3230 regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3234 var dummy = new RegExp(regexp, modifiers);
3241 function constructJavascriptRegExp(data) {
3243 tail = /\/([gim]*)$/.exec(data),
3246 // `/foo/gim` - tail can be maximum 4 chars
3247 if ('/' === regexp[0]) {
3249 modifiers = tail[1];
3251 regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3254 return new RegExp(regexp, modifiers);
3257 function representJavascriptRegExp(object /*, style*/) {
3258 var result = '/' + object.source + '/';
3260 if (object.global) {
3264 if (object.multiline) {
3268 if (object.ignoreCase) {
3275 function isRegExp(object) {
3276 return '[object RegExp]' === Object.prototype.toString.call(object);
3279 module.exports = new Type('tag:yaml.org,2002:js/regexp', {
3281 resolve: resolveJavascriptRegExp,
3282 construct: constructJavascriptRegExp,
3283 predicate: isRegExp,
3284 represent: representJavascriptRegExp
3287 },{"../../type":13}],20:[function(require,module,exports){
3290 var Type = require('../../type');
3292 function resolveJavascriptUndefined() {
3296 function constructJavascriptUndefined() {
3300 function representJavascriptUndefined() {
3304 function isUndefined(object) {
3305 return 'undefined' === typeof object;
3308 module.exports = new Type('tag:yaml.org,2002:js/undefined', {
3310 resolve: resolveJavascriptUndefined,
3311 construct: constructJavascriptUndefined,
3312 predicate: isUndefined,
3313 represent: representJavascriptUndefined
3316 },{"../../type":13}],21:[function(require,module,exports){
3319 var Type = require('../type');
3321 module.exports = new Type('tag:yaml.org,2002:map', {
3323 construct: function (data) { return null !== data ? data : {}; }
3326 },{"../type":13}],22:[function(require,module,exports){
3329 var Type = require('../type');
3331 function resolveYamlMerge(data) {
3332 return '<<' === data || null === data;
3335 module.exports = new Type('tag:yaml.org,2002:merge', {
3337 resolve: resolveYamlMerge
3340 },{"../type":13}],23:[function(require,module,exports){
3343 var Type = require('../type');
3345 function resolveYamlNull(data) {
3346 if (null === data) {
3350 var max = data.length;
3352 return (max === 1 && data === '~') ||
3353 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
3356 function constructYamlNull() {
3360 function isNull(object) {
3361 return null === object;
3364 module.exports = new Type('tag:yaml.org,2002:null', {
3366 resolve: resolveYamlNull,
3367 construct: constructYamlNull,
3370 canonical: function () { return '~'; },
3371 lowercase: function () { return 'null'; },
3372 uppercase: function () { return 'NULL'; },
3373 camelcase: function () { return 'Null'; }
3375 defaultStyle: 'lowercase'
3378 },{"../type":13}],24:[function(require,module,exports){
3381 var Type = require('../type');
3383 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3384 var _toString = Object.prototype.toString;
3386 function resolveYamlOmap(data) {
3387 if (null === data) {
3391 var objectKeys = [], index, length, pair, pairKey, pairHasKey,
3394 for (index = 0, length = object.length; index < length; index += 1) {
3395 pair = object[index];
3398 if ('[object Object]' !== _toString.call(pair)) {
3402 for (pairKey in pair) {
3403 if (_hasOwnProperty.call(pair, pairKey)) {
3416 if (-1 === objectKeys.indexOf(pairKey)) {
3417 objectKeys.push(pairKey);
3426 function constructYamlOmap(data) {
3427 return null !== data ? data : [];
3430 module.exports = new Type('tag:yaml.org,2002:omap', {
3432 resolve: resolveYamlOmap,
3433 construct: constructYamlOmap
3436 },{"../type":13}],25:[function(require,module,exports){
3439 var Type = require('../type');
3441 var _toString = Object.prototype.toString;
3443 function resolveYamlPairs(data) {
3444 if (null === data) {
3448 var index, length, pair, keys, result,
3451 result = new Array(object.length);
3453 for (index = 0, length = object.length; index < length; index += 1) {
3454 pair = object[index];
3456 if ('[object Object]' !== _toString.call(pair)) {
3460 keys = Object.keys(pair);
3462 if (1 !== keys.length) {
3466 result[index] = [ keys[0], pair[keys[0]] ];
3472 function constructYamlPairs(data) {
3473 if (null === data) {
3477 var index, length, pair, keys, result,
3480 result = new Array(object.length);
3482 for (index = 0, length = object.length; index < length; index += 1) {
3483 pair = object[index];
3485 keys = Object.keys(pair);
3487 result[index] = [ keys[0], pair[keys[0]] ];
3493 module.exports = new Type('tag:yaml.org,2002:pairs', {
3495 resolve: resolveYamlPairs,
3496 construct: constructYamlPairs
3499 },{"../type":13}],26:[function(require,module,exports){
3502 var Type = require('../type');
3504 module.exports = new Type('tag:yaml.org,2002:seq', {
3506 construct: function (data) { return null !== data ? data : []; }
3509 },{"../type":13}],27:[function(require,module,exports){
3512 var Type = require('../type');
3514 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3516 function resolveYamlSet(data) {
3517 if (null === data) {
3521 var key, object = data;
3523 for (key in object) {
3524 if (_hasOwnProperty.call(object, key)) {
3525 if (null !== object[key]) {
3534 function constructYamlSet(data) {
3535 return null !== data ? data : {};
3538 module.exports = new Type('tag:yaml.org,2002:set', {
3540 resolve: resolveYamlSet,
3541 construct: constructYamlSet
3544 },{"../type":13}],28:[function(require,module,exports){
3547 var Type = require('../type');
3549 module.exports = new Type('tag:yaml.org,2002:str', {
3551 construct: function (data) { return null !== data ? data : ''; }
3554 },{"../type":13}],29:[function(require,module,exports){
3557 var Type = require('../type');
3559 var YAML_TIMESTAMP_REGEXP = new RegExp(
3560 '^([0-9][0-9][0-9][0-9])' + // [1] year
3561 '-([0-9][0-9]?)' + // [2] month
3562 '-([0-9][0-9]?)' + // [3] day
3563 '(?:(?:[Tt]|[ \\t]+)' + // ...
3564 '([0-9][0-9]?)' + // [4] hour
3565 ':([0-9][0-9])' + // [5] minute
3566 ':([0-9][0-9])' + // [6] second
3567 '(?:\\.([0-9]*))?' + // [7] fraction
3568 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
3569 '(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
3571 function resolveYamlTimestamp(data) {
3572 if (null === data) {
3576 var match, year, month, day, hour, minute, second, fraction = 0,
3577 delta = null, tz_hour, tz_minute, date;
3579 match = YAML_TIMESTAMP_REGEXP.exec(data);
3581 if (null === match) {
3588 function constructYamlTimestamp(data) {
3589 var match, year, month, day, hour, minute, second, fraction = 0,
3590 delta = null, tz_hour, tz_minute, date;
3592 match = YAML_TIMESTAMP_REGEXP.exec(data);
3594 if (null === match) {
3595 throw new Error('Date resolve error');
3598 // match: [1] year [2] month [3] day
3601 month = +(match[2]) - 1; // JS month starts with 0
3604 if (!match[4]) { // no hour
3605 return new Date(Date.UTC(year, month, day));
3608 // match: [4] hour [5] minute [6] second [7] fraction
3611 minute = +(match[5]);
3612 second = +(match[6]);
3615 fraction = match[7].slice(0, 3);
3616 while (fraction.length < 3) { // milli-seconds
3619 fraction = +fraction;
3622 // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
3625 tz_hour = +(match[10]);
3626 tz_minute = +(match[11] || 0);
3627 delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
3628 if ('-' === match[9]) {
3633 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
3636 date.setTime(date.getTime() - delta);
3642 function representYamlTimestamp(object /*, style*/) {
3643 return object.toISOString();
3646 module.exports = new Type('tag:yaml.org,2002:timestamp', {
3648 resolve: resolveYamlTimestamp,
3649 construct: constructYamlTimestamp,
3651 represent: representYamlTimestamp
3654 },{"../type":13}],30:[function(require,module,exports){
3656 },{}],"/":[function(require,module,exports){
3660 var yaml = require('./lib/js-yaml.js');
3663 module.exports = yaml;
3665 },{"./lib/js-yaml.js":1}]},{},[])("/")