You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3946 lines
106 KiB

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