yaml.js 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859
  1. (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. var Dumper, Inline, Utils;
  3. Utils = require('./Utils');
  4. Inline = require('./Inline');
  5. Dumper = (function() {
  6. function Dumper() {}
  7. Dumper.indentation = 4;
  8. Dumper.prototype.dump = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
  9. var i, key, len, output, prefix, value, willBeInlined;
  10. if (inline == null) {
  11. inline = 0;
  12. }
  13. if (indent == null) {
  14. indent = 0;
  15. }
  16. if (exceptionOnInvalidType == null) {
  17. exceptionOnInvalidType = false;
  18. }
  19. if (objectEncoder == null) {
  20. objectEncoder = null;
  21. }
  22. output = '';
  23. prefix = (indent ? Utils.strRepeat(' ', indent) : '');
  24. if (inline <= 0 || typeof input !== 'object' || input instanceof Date || Utils.isEmpty(input)) {
  25. output += prefix + Inline.dump(input, exceptionOnInvalidType, objectEncoder);
  26. } else {
  27. if (input instanceof Array) {
  28. for (i = 0, len = input.length; i < len; i++) {
  29. value = input[i];
  30. willBeInlined = inline - 1 <= 0 || typeof value !== 'object' || Utils.isEmpty(value);
  31. output += prefix + '-' + (willBeInlined ? ' ' : "\n") + this.dump(value, inline - 1, (willBeInlined ? 0 : indent + this.indentation), exceptionOnInvalidType, objectEncoder) + (willBeInlined ? "\n" : '');
  32. }
  33. } else {
  34. for (key in input) {
  35. value = input[key];
  36. willBeInlined = inline - 1 <= 0 || typeof value !== 'object' || Utils.isEmpty(value);
  37. output += prefix + Inline.dump(key, exceptionOnInvalidType, objectEncoder) + ':' + (willBeInlined ? ' ' : "\n") + this.dump(value, inline - 1, (willBeInlined ? 0 : indent + this.indentation), exceptionOnInvalidType, objectEncoder) + (willBeInlined ? "\n" : '');
  38. }
  39. }
  40. }
  41. return output;
  42. };
  43. return Dumper;
  44. })();
  45. module.exports = Dumper;
  46. },{"./Inline":5,"./Utils":9}],2:[function(require,module,exports){
  47. var Escaper, Pattern;
  48. Pattern = require('./Pattern');
  49. Escaper = (function() {
  50. var ch;
  51. function Escaper() {}
  52. Escaper.LIST_ESCAPEES = ['\\', '\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", (ch = String.fromCharCode)(0x0085), ch(0x00A0), ch(0x2028), ch(0x2029)];
  53. Escaper.LIST_ESCAPED = ['\\\\', '\\"', '\\"', '\\"', "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f", "\\N", "\\_", "\\L", "\\P"];
  54. Escaper.MAPPING_ESCAPEES_TO_ESCAPED = (function() {
  55. var i, j, mapping, ref;
  56. mapping = {};
  57. for (i = j = 0, ref = Escaper.LIST_ESCAPEES.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
  58. mapping[Escaper.LIST_ESCAPEES[i]] = Escaper.LIST_ESCAPED[i];
  59. }
  60. return mapping;
  61. })();
  62. Escaper.PATTERN_CHARACTERS_TO_ESCAPE = new Pattern('[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9');
  63. Escaper.PATTERN_MAPPING_ESCAPEES = new Pattern(Escaper.LIST_ESCAPEES.join('|').split('\\').join('\\\\'));
  64. Escaper.PATTERN_SINGLE_QUOTING = new Pattern('[\\s\'":{}[\\],&*#?]|^[-?|<>=!%@`]');
  65. Escaper.requiresDoubleQuoting = function(value) {
  66. return this.PATTERN_CHARACTERS_TO_ESCAPE.test(value);
  67. };
  68. Escaper.escapeWithDoubleQuotes = function(value) {
  69. var result;
  70. result = this.PATTERN_MAPPING_ESCAPEES.replace(value, (function(_this) {
  71. return function(str) {
  72. return _this.MAPPING_ESCAPEES_TO_ESCAPED[str];
  73. };
  74. })(this));
  75. return '"' + result + '"';
  76. };
  77. Escaper.requiresSingleQuoting = function(value) {
  78. return this.PATTERN_SINGLE_QUOTING.test(value);
  79. };
  80. Escaper.escapeWithSingleQuotes = function(value) {
  81. return "'" + value.replace(/'/g, "''") + "'";
  82. };
  83. return Escaper;
  84. })();
  85. module.exports = Escaper;
  86. },{"./Pattern":7}],3:[function(require,module,exports){
  87. var DumpException,
  88. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  89. hasProp = {}.hasOwnProperty;
  90. DumpException = (function(superClass) {
  91. extend(DumpException, superClass);
  92. function DumpException(message, parsedLine, snippet) {
  93. this.message = message;
  94. this.parsedLine = parsedLine;
  95. this.snippet = snippet;
  96. }
  97. DumpException.prototype.toString = function() {
  98. if ((this.parsedLine != null) && (this.snippet != null)) {
  99. return '<DumpException> ' + this.message + ' (line ' + this.parsedLine + ': \'' + this.snippet + '\')';
  100. } else {
  101. return '<DumpException> ' + this.message;
  102. }
  103. };
  104. return DumpException;
  105. })(Error);
  106. module.exports = DumpException;
  107. },{}],4:[function(require,module,exports){
  108. var ParseException,
  109. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  110. hasProp = {}.hasOwnProperty;
  111. ParseException = (function(superClass) {
  112. extend(ParseException, superClass);
  113. function ParseException(message, parsedLine, snippet) {
  114. this.message = message;
  115. this.parsedLine = parsedLine;
  116. this.snippet = snippet;
  117. }
  118. ParseException.prototype.toString = function() {
  119. if ((this.parsedLine != null) && (this.snippet != null)) {
  120. return '<ParseException> ' + this.message + ' (line ' + this.parsedLine + ': \'' + this.snippet + '\')';
  121. } else {
  122. return '<ParseException> ' + this.message;
  123. }
  124. };
  125. return ParseException;
  126. })(Error);
  127. module.exports = ParseException;
  128. },{}],5:[function(require,module,exports){
  129. var DumpException, Escaper, Inline, ParseException, Pattern, Unescaper, Utils,
  130. indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
  131. Pattern = require('./Pattern');
  132. Unescaper = require('./Unescaper');
  133. Escaper = require('./Escaper');
  134. Utils = require('./Utils');
  135. ParseException = require('./Exception/ParseException');
  136. DumpException = require('./Exception/DumpException');
  137. Inline = (function() {
  138. function Inline() {}
  139. Inline.REGEX_QUOTED_STRING = '(?:"(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'(?:[^\']*(?:\'\'[^\']*)*)\')';
  140. Inline.PATTERN_TRAILING_COMMENTS = new Pattern('^\\s*#.*$');
  141. Inline.PATTERN_QUOTED_SCALAR = new Pattern('^' + Inline.REGEX_QUOTED_STRING);
  142. Inline.PATTERN_THOUSAND_NUMERIC_SCALAR = new Pattern('^(-|\\+)?[0-9,]+(\\.[0-9]+)?$');
  143. Inline.PATTERN_SCALAR_BY_DELIMITERS = {};
  144. Inline.settings = {};
  145. Inline.configure = function(exceptionOnInvalidType, objectDecoder) {
  146. if (exceptionOnInvalidType == null) {
  147. exceptionOnInvalidType = null;
  148. }
  149. if (objectDecoder == null) {
  150. objectDecoder = null;
  151. }
  152. this.settings.exceptionOnInvalidType = exceptionOnInvalidType;
  153. this.settings.objectDecoder = objectDecoder;
  154. };
  155. Inline.parse = function(value, exceptionOnInvalidType, objectDecoder) {
  156. var context, result;
  157. if (exceptionOnInvalidType == null) {
  158. exceptionOnInvalidType = false;
  159. }
  160. if (objectDecoder == null) {
  161. objectDecoder = null;
  162. }
  163. this.settings.exceptionOnInvalidType = exceptionOnInvalidType;
  164. this.settings.objectDecoder = objectDecoder;
  165. if (value == null) {
  166. return '';
  167. }
  168. value = Utils.trim(value);
  169. if (0 === value.length) {
  170. return '';
  171. }
  172. context = {
  173. exceptionOnInvalidType: exceptionOnInvalidType,
  174. objectDecoder: objectDecoder,
  175. i: 0
  176. };
  177. switch (value.charAt(0)) {
  178. case '[':
  179. result = this.parseSequence(value, context);
  180. ++context.i;
  181. break;
  182. case '{':
  183. result = this.parseMapping(value, context);
  184. ++context.i;
  185. break;
  186. default:
  187. result = this.parseScalar(value, null, ['"', "'"], context);
  188. }
  189. if (this.PATTERN_TRAILING_COMMENTS.replace(value.slice(context.i), '') !== '') {
  190. throw new ParseException('Unexpected characters near "' + value.slice(context.i) + '".');
  191. }
  192. return result;
  193. };
  194. Inline.dump = function(value, exceptionOnInvalidType, objectEncoder) {
  195. var ref, result, type;
  196. if (exceptionOnInvalidType == null) {
  197. exceptionOnInvalidType = false;
  198. }
  199. if (objectEncoder == null) {
  200. objectEncoder = null;
  201. }
  202. if (value == null) {
  203. return 'null';
  204. }
  205. type = typeof value;
  206. if (type === 'object') {
  207. if (value instanceof Date) {
  208. return value.toISOString();
  209. } else if (objectEncoder != null) {
  210. result = objectEncoder(value);
  211. if (typeof result === 'string' || (result != null)) {
  212. return result;
  213. }
  214. }
  215. return this.dumpObject(value);
  216. }
  217. if (type === 'boolean') {
  218. return (value ? 'true' : 'false');
  219. }
  220. if (Utils.isDigits(value)) {
  221. return (type === 'string' ? "'" + value + "'" : String(parseInt(value)));
  222. }
  223. if (Utils.isNumeric(value)) {
  224. return (type === 'string' ? "'" + value + "'" : String(parseFloat(value)));
  225. }
  226. if (type === 'number') {
  227. return (value === Infinity ? '.Inf' : (value === -Infinity ? '-.Inf' : (isNaN(value) ? '.NaN' : value)));
  228. }
  229. if (Escaper.requiresDoubleQuoting(value)) {
  230. return Escaper.escapeWithDoubleQuotes(value);
  231. }
  232. if (Escaper.requiresSingleQuoting(value)) {
  233. return Escaper.escapeWithSingleQuotes(value);
  234. }
  235. if ('' === value) {
  236. return '""';
  237. }
  238. if (Utils.PATTERN_DATE.test(value)) {
  239. return "'" + value + "'";
  240. }
  241. if ((ref = value.toLowerCase()) === 'null' || ref === '~' || ref === 'true' || ref === 'false') {
  242. return "'" + value + "'";
  243. }
  244. return value;
  245. };
  246. Inline.dumpObject = function(value, exceptionOnInvalidType, objectSupport) {
  247. var j, key, len1, output, val;
  248. if (objectSupport == null) {
  249. objectSupport = null;
  250. }
  251. if (value instanceof Array) {
  252. output = [];
  253. for (j = 0, len1 = value.length; j < len1; j++) {
  254. val = value[j];
  255. output.push(this.dump(val));
  256. }
  257. return '[' + output.join(', ') + ']';
  258. } else {
  259. output = [];
  260. for (key in value) {
  261. val = value[key];
  262. output.push(this.dump(key) + ': ' + this.dump(val));
  263. }
  264. return '{' + output.join(', ') + '}';
  265. }
  266. };
  267. Inline.parseScalar = function(scalar, delimiters, stringDelimiters, context, evaluate) {
  268. var i, joinedDelimiters, match, output, pattern, ref, ref1, strpos, tmp;
  269. if (delimiters == null) {
  270. delimiters = null;
  271. }
  272. if (stringDelimiters == null) {
  273. stringDelimiters = ['"', "'"];
  274. }
  275. if (context == null) {
  276. context = null;
  277. }
  278. if (evaluate == null) {
  279. evaluate = true;
  280. }
  281. if (context == null) {
  282. context = {
  283. exceptionOnInvalidType: this.settings.exceptionOnInvalidType,
  284. objectDecoder: this.settings.objectDecoder,
  285. i: 0
  286. };
  287. }
  288. i = context.i;
  289. if (ref = scalar.charAt(i), indexOf.call(stringDelimiters, ref) >= 0) {
  290. output = this.parseQuotedScalar(scalar, context);
  291. i = context.i;
  292. if (delimiters != null) {
  293. tmp = Utils.ltrim(scalar.slice(i), ' ');
  294. if (!(ref1 = tmp.charAt(0), indexOf.call(delimiters, ref1) >= 0)) {
  295. throw new ParseException('Unexpected characters (' + scalar.slice(i) + ').');
  296. }
  297. }
  298. } else {
  299. if (!delimiters) {
  300. output = scalar.slice(i);
  301. i += output.length;
  302. strpos = output.indexOf(' #');
  303. if (strpos !== -1) {
  304. output = Utils.rtrim(output.slice(0, strpos));
  305. }
  306. } else {
  307. joinedDelimiters = delimiters.join('|');
  308. pattern = this.PATTERN_SCALAR_BY_DELIMITERS[joinedDelimiters];
  309. if (pattern == null) {
  310. pattern = new Pattern('^(.+?)(' + joinedDelimiters + ')');
  311. this.PATTERN_SCALAR_BY_DELIMITERS[joinedDelimiters] = pattern;
  312. }
  313. if (match = pattern.exec(scalar.slice(i))) {
  314. output = match[1];
  315. i += output.length;
  316. } else {
  317. throw new ParseException('Malformed inline YAML string (' + scalar + ').');
  318. }
  319. }
  320. if (evaluate) {
  321. output = this.evaluateScalar(output, context);
  322. }
  323. }
  324. context.i = i;
  325. return output;
  326. };
  327. Inline.parseQuotedScalar = function(scalar, context) {
  328. var i, match, output;
  329. i = context.i;
  330. if (!(match = this.PATTERN_QUOTED_SCALAR.exec(scalar.slice(i)))) {
  331. throw new ParseException('Malformed inline YAML string (' + scalar.slice(i) + ').');
  332. }
  333. output = match[0].substr(1, match[0].length - 2);
  334. if ('"' === scalar.charAt(i)) {
  335. output = Unescaper.unescapeDoubleQuotedString(output);
  336. } else {
  337. output = Unescaper.unescapeSingleQuotedString(output);
  338. }
  339. i += match[0].length;
  340. context.i = i;
  341. return output;
  342. };
  343. Inline.parseSequence = function(sequence, context) {
  344. var e, error, i, isQuoted, len, output, ref, value;
  345. output = [];
  346. len = sequence.length;
  347. i = context.i;
  348. i += 1;
  349. while (i < len) {
  350. context.i = i;
  351. switch (sequence.charAt(i)) {
  352. case '[':
  353. output.push(this.parseSequence(sequence, context));
  354. i = context.i;
  355. break;
  356. case '{':
  357. output.push(this.parseMapping(sequence, context));
  358. i = context.i;
  359. break;
  360. case ']':
  361. return output;
  362. case ',':
  363. case ' ':
  364. case "\n":
  365. break;
  366. default:
  367. isQuoted = ((ref = sequence.charAt(i)) === '"' || ref === "'");
  368. value = this.parseScalar(sequence, [',', ']'], ['"', "'"], context);
  369. i = context.i;
  370. if (!isQuoted && typeof value === 'string' && (value.indexOf(': ') !== -1 || value.indexOf(":\n") !== -1)) {
  371. try {
  372. value = this.parseMapping('{' + value + '}');
  373. } catch (error) {
  374. e = error;
  375. }
  376. }
  377. output.push(value);
  378. --i;
  379. }
  380. ++i;
  381. }
  382. throw new ParseException('Malformed inline YAML string ' + sequence);
  383. };
  384. Inline.parseMapping = function(mapping, context) {
  385. var done, i, key, len, output, shouldContinueWhileLoop, value;
  386. output = {};
  387. len = mapping.length;
  388. i = context.i;
  389. i += 1;
  390. shouldContinueWhileLoop = false;
  391. while (i < len) {
  392. context.i = i;
  393. switch (mapping.charAt(i)) {
  394. case ' ':
  395. case ',':
  396. case "\n":
  397. ++i;
  398. context.i = i;
  399. shouldContinueWhileLoop = true;
  400. break;
  401. case '}':
  402. return output;
  403. }
  404. if (shouldContinueWhileLoop) {
  405. shouldContinueWhileLoop = false;
  406. continue;
  407. }
  408. key = this.parseScalar(mapping, [':', ' ', "\n"], ['"', "'"], context, false);
  409. i = context.i;
  410. done = false;
  411. while (i < len) {
  412. context.i = i;
  413. switch (mapping.charAt(i)) {
  414. case '[':
  415. value = this.parseSequence(mapping, context);
  416. i = context.i;
  417. if (output[key] === void 0) {
  418. output[key] = value;
  419. }
  420. done = true;
  421. break;
  422. case '{':
  423. value = this.parseMapping(mapping, context);
  424. i = context.i;
  425. if (output[key] === void 0) {
  426. output[key] = value;
  427. }
  428. done = true;
  429. break;
  430. case ':':
  431. case ' ':
  432. case "\n":
  433. break;
  434. default:
  435. value = this.parseScalar(mapping, [',', '}'], ['"', "'"], context);
  436. i = context.i;
  437. if (output[key] === void 0) {
  438. output[key] = value;
  439. }
  440. done = true;
  441. --i;
  442. }
  443. ++i;
  444. if (done) {
  445. break;
  446. }
  447. }
  448. }
  449. throw new ParseException('Malformed inline YAML string ' + mapping);
  450. };
  451. Inline.evaluateScalar = function(scalar, context) {
  452. var cast, date, exceptionOnInvalidType, firstChar, firstSpace, firstWord, objectDecoder, raw, scalarLower, subValue, trimmedScalar;
  453. scalar = Utils.trim(scalar);
  454. scalarLower = scalar.toLowerCase();
  455. switch (scalarLower) {
  456. case 'null':
  457. case '':
  458. case '~':
  459. return null;
  460. case 'true':
  461. return true;
  462. case 'false':
  463. return false;
  464. case '.inf':
  465. return Infinity;
  466. case '.nan':
  467. return NaN;
  468. case '-.inf':
  469. return Infinity;
  470. default:
  471. firstChar = scalarLower.charAt(0);
  472. switch (firstChar) {
  473. case '!':
  474. firstSpace = scalar.indexOf(' ');
  475. if (firstSpace === -1) {
  476. firstWord = scalarLower;
  477. } else {
  478. firstWord = scalarLower.slice(0, firstSpace);
  479. }
  480. switch (firstWord) {
  481. case '!':
  482. if (firstSpace !== -1) {
  483. return parseInt(this.parseScalar(scalar.slice(2)));
  484. }
  485. return null;
  486. case '!str':
  487. return Utils.ltrim(scalar.slice(4));
  488. case '!!str':
  489. return Utils.ltrim(scalar.slice(5));
  490. case '!!int':
  491. return parseInt(this.parseScalar(scalar.slice(5)));
  492. case '!!bool':
  493. return Utils.parseBoolean(this.parseScalar(scalar.slice(6)), false);
  494. case '!!float':
  495. return parseFloat(this.parseScalar(scalar.slice(7)));
  496. case '!!timestamp':
  497. return Utils.stringToDate(Utils.ltrim(scalar.slice(11)));
  498. default:
  499. if (context == null) {
  500. context = {
  501. exceptionOnInvalidType: this.settings.exceptionOnInvalidType,
  502. objectDecoder: this.settings.objectDecoder,
  503. i: 0
  504. };
  505. }
  506. objectDecoder = context.objectDecoder, exceptionOnInvalidType = context.exceptionOnInvalidType;
  507. if (objectDecoder) {
  508. trimmedScalar = Utils.rtrim(scalar);
  509. firstSpace = trimmedScalar.indexOf(' ');
  510. if (firstSpace === -1) {
  511. return objectDecoder(trimmedScalar, null);
  512. } else {
  513. subValue = Utils.ltrim(trimmedScalar.slice(firstSpace + 1));
  514. if (!(subValue.length > 0)) {
  515. subValue = null;
  516. }
  517. return objectDecoder(trimmedScalar.slice(0, firstSpace), subValue);
  518. }
  519. }
  520. if (exceptionOnInvalidType) {
  521. throw new ParseException('Custom object support when parsing a YAML file has been disabled.');
  522. }
  523. return null;
  524. }
  525. break;
  526. case '0':
  527. if ('0x' === scalar.slice(0, 2)) {
  528. return Utils.hexDec(scalar);
  529. } else if (Utils.isDigits(scalar)) {
  530. return Utils.octDec(scalar);
  531. } else if (Utils.isNumeric(scalar)) {
  532. return parseFloat(scalar);
  533. } else {
  534. return scalar;
  535. }
  536. break;
  537. case '+':
  538. if (Utils.isDigits(scalar)) {
  539. raw = scalar;
  540. cast = parseInt(raw);
  541. if (raw === String(cast)) {
  542. return cast;
  543. } else {
  544. return raw;
  545. }
  546. } else if (Utils.isNumeric(scalar)) {
  547. return parseFloat(scalar);
  548. } else if (this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(scalar)) {
  549. return parseFloat(scalar.replace(',', ''));
  550. }
  551. return scalar;
  552. case '-':
  553. if (Utils.isDigits(scalar.slice(1))) {
  554. if ('0' === scalar.charAt(1)) {
  555. return -Utils.octDec(scalar.slice(1));
  556. } else {
  557. raw = scalar.slice(1);
  558. cast = parseInt(raw);
  559. if (raw === String(cast)) {
  560. return -cast;
  561. } else {
  562. return -raw;
  563. }
  564. }
  565. } else if (Utils.isNumeric(scalar)) {
  566. return parseFloat(scalar);
  567. } else if (this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(scalar)) {
  568. return parseFloat(scalar.replace(',', ''));
  569. }
  570. return scalar;
  571. default:
  572. if (date = Utils.stringToDate(scalar)) {
  573. return date;
  574. } else if (Utils.isNumeric(scalar)) {
  575. return parseFloat(scalar);
  576. } else if (this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(scalar)) {
  577. return parseFloat(scalar.replace(',', ''));
  578. }
  579. return scalar;
  580. }
  581. }
  582. };
  583. return Inline;
  584. })();
  585. module.exports = Inline;
  586. },{"./Escaper":2,"./Exception/DumpException":3,"./Exception/ParseException":4,"./Pattern":7,"./Unescaper":8,"./Utils":9}],6:[function(require,module,exports){
  587. var Inline, ParseException, Parser, Pattern, Utils;
  588. Inline = require('./Inline');
  589. Pattern = require('./Pattern');
  590. Utils = require('./Utils');
  591. ParseException = require('./Exception/ParseException');
  592. Parser = (function() {
  593. Parser.prototype.PATTERN_FOLDED_SCALAR_ALL = new Pattern('^(?:(?<type>![^\\|>]*)\\s+)?(?<separator>\\||>)(?<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?<comments> +#.*)?$');
  594. Parser.prototype.PATTERN_FOLDED_SCALAR_END = new Pattern('(?<separator>\\||>)(?<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?<comments> +#.*)?$');
  595. Parser.prototype.PATTERN_SEQUENCE_ITEM = new Pattern('^\\-((?<leadspaces>\\s+)(?<value>.+?))?\\s*$');
  596. Parser.prototype.PATTERN_ANCHOR_VALUE = new Pattern('^&(?<ref>[^ ]+) *(?<value>.*)');
  597. Parser.prototype.PATTERN_COMPACT_NOTATION = new Pattern('^(?<key>' + Inline.REGEX_QUOTED_STRING + '|[^ \'"\\{\\[].*?) *\\:(\\s+(?<value>.+?))?\\s*$');
  598. Parser.prototype.PATTERN_MAPPING_ITEM = new Pattern('^(?<key>' + Inline.REGEX_QUOTED_STRING + '|[^ \'"\\[\\{].*?) *\\:(\\s+(?<value>.+?))?\\s*$');
  599. Parser.prototype.PATTERN_DECIMAL = new Pattern('\\d+');
  600. Parser.prototype.PATTERN_INDENT_SPACES = new Pattern('^ +');
  601. Parser.prototype.PATTERN_TRAILING_LINES = new Pattern('(\n*)$');
  602. Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n');
  603. Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+');
  604. Parser.prototype.PATTERN_DOCUMENT_MARKER_START = new Pattern('^\\-\\-\\-.*?\n');
  605. Parser.prototype.PATTERN_DOCUMENT_MARKER_END = new Pattern('^\\.\\.\\.\\s*$');
  606. Parser.prototype.PATTERN_FOLDED_SCALAR_BY_INDENTATION = {};
  607. Parser.prototype.CONTEXT_NONE = 0;
  608. Parser.prototype.CONTEXT_SEQUENCE = 1;
  609. Parser.prototype.CONTEXT_MAPPING = 2;
  610. function Parser(offset) {
  611. this.offset = offset != null ? offset : 0;
  612. this.lines = [];
  613. this.currentLineNb = -1;
  614. this.currentLine = '';
  615. this.refs = {};
  616. }
  617. Parser.prototype.parse = function(value, exceptionOnInvalidType, objectDecoder) {
  618. var alias, allowOverwrite, block, c, context, data, e, error, error1, error2, first, i, indent, isRef, j, k, key, l, lastKey, len, len1, len2, len3, lineCount, m, matches, mergeNode, n, name, parsed, parsedItem, parser, ref, ref1, ref2, refName, refValue, val, values;
  619. if (exceptionOnInvalidType == null) {
  620. exceptionOnInvalidType = false;
  621. }
  622. if (objectDecoder == null) {
  623. objectDecoder = null;
  624. }
  625. this.currentLineNb = -1;
  626. this.currentLine = '';
  627. this.lines = this.cleanup(value).split("\n");
  628. data = null;
  629. context = this.CONTEXT_NONE;
  630. allowOverwrite = false;
  631. while (this.moveToNextLine()) {
  632. if (this.isCurrentLineEmpty()) {
  633. continue;
  634. }
  635. if ("\t" === this.currentLine[0]) {
  636. throw new ParseException('A YAML file cannot contain tabs as indentation.', this.getRealCurrentLineNb() + 1, this.currentLine);
  637. }
  638. isRef = mergeNode = false;
  639. if (values = this.PATTERN_SEQUENCE_ITEM.exec(this.currentLine)) {
  640. if (this.CONTEXT_MAPPING === context) {
  641. throw new ParseException('You cannot define a sequence item when in a mapping');
  642. }
  643. context = this.CONTEXT_SEQUENCE;
  644. if (data == null) {
  645. data = [];
  646. }
  647. if ((values.value != null) && (matches = this.PATTERN_ANCHOR_VALUE.exec(values.value))) {
  648. isRef = matches.ref;
  649. values.value = matches.value;
  650. }
  651. if (!(values.value != null) || '' === Utils.trim(values.value, ' ') || Utils.ltrim(values.value, ' ').indexOf('#') === 0) {
  652. if (this.currentLineNb < this.lines.length - 1 && !this.isNextLineUnIndentedCollection()) {
  653. c = this.getRealCurrentLineNb() + 1;
  654. parser = new Parser(c);
  655. parser.refs = this.refs;
  656. data.push(parser.parse(this.getNextEmbedBlock(null, true), exceptionOnInvalidType, objectDecoder));
  657. } else {
  658. data.push(null);
  659. }
  660. } else {
  661. if (((ref = values.leadspaces) != null ? ref.length : void 0) && (matches = this.PATTERN_COMPACT_NOTATION.exec(values.value))) {
  662. c = this.getRealCurrentLineNb();
  663. parser = new Parser(c);
  664. parser.refs = this.refs;
  665. block = values.value;
  666. indent = this.getCurrentLineIndentation();
  667. if (this.isNextLineIndented(false)) {
  668. block += "\n" + this.getNextEmbedBlock(indent + values.leadspaces.length + 1, true);
  669. }
  670. data.push(parser.parse(block, exceptionOnInvalidType, objectDecoder));
  671. } else {
  672. data.push(this.parseValue(values.value, exceptionOnInvalidType, objectDecoder));
  673. }
  674. }
  675. } else if ((values = this.PATTERN_MAPPING_ITEM.exec(this.currentLine)) && values.key.indexOf(' #') === -1) {
  676. if (this.CONTEXT_SEQUENCE === context) {
  677. throw new ParseException('You cannot define a mapping item when in a sequence');
  678. }
  679. context = this.CONTEXT_MAPPING;
  680. if (data == null) {
  681. data = {};
  682. }
  683. Inline.configure(exceptionOnInvalidType, objectDecoder);
  684. try {
  685. key = Inline.parseScalar(values.key);
  686. } catch (error) {
  687. e = error;
  688. e.parsedLine = this.getRealCurrentLineNb() + 1;
  689. e.snippet = this.currentLine;
  690. throw e;
  691. }
  692. if ('<<' === key) {
  693. mergeNode = true;
  694. allowOverwrite = true;
  695. if (((ref1 = values.value) != null ? ref1.indexOf('*') : void 0) === 0) {
  696. refName = values.value.slice(1);
  697. if (this.refs[refName] == null) {
  698. throw new ParseException('Reference "' + refName + '" does not exist.', this.getRealCurrentLineNb() + 1, this.currentLine);
  699. }
  700. refValue = this.refs[refName];
  701. if (typeof refValue !== 'object') {
  702. throw new ParseException('YAML merge keys used with a scalar value instead of an object.', this.getRealCurrentLineNb() + 1, this.currentLine);
  703. }
  704. if (refValue instanceof Array) {
  705. for (i = j = 0, len = refValue.length; j < len; i = ++j) {
  706. value = refValue[i];
  707. if (data[name = String(i)] == null) {
  708. data[name] = value;
  709. }
  710. }
  711. } else {
  712. for (key in refValue) {
  713. value = refValue[key];
  714. if (data[key] == null) {
  715. data[key] = value;
  716. }
  717. }
  718. }
  719. } else {
  720. if ((values.value != null) && values.value !== '') {
  721. value = values.value;
  722. } else {
  723. value = this.getNextEmbedBlock();
  724. }
  725. c = this.getRealCurrentLineNb() + 1;
  726. parser = new Parser(c);
  727. parser.refs = this.refs;
  728. parsed = parser.parse(value, exceptionOnInvalidType);
  729. if (typeof parsed !== 'object') {
  730. throw new ParseException('YAML merge keys used with a scalar value instead of an object.', this.getRealCurrentLineNb() + 1, this.currentLine);
  731. }
  732. if (parsed instanceof Array) {
  733. for (l = 0, len1 = parsed.length; l < len1; l++) {
  734. parsedItem = parsed[l];
  735. if (typeof parsedItem !== 'object') {
  736. throw new ParseException('Merge items must be objects.', this.getRealCurrentLineNb() + 1, parsedItem);
  737. }
  738. if (parsedItem instanceof Array) {
  739. for (i = m = 0, len2 = parsedItem.length; m < len2; i = ++m) {
  740. value = parsedItem[i];
  741. k = String(i);
  742. if (!data.hasOwnProperty(k)) {
  743. data[k] = value;
  744. }
  745. }
  746. } else {
  747. for (key in parsedItem) {
  748. value = parsedItem[key];
  749. if (!data.hasOwnProperty(key)) {
  750. data[key] = value;
  751. }
  752. }
  753. }
  754. }
  755. } else {
  756. for (key in parsed) {
  757. value = parsed[key];
  758. if (!data.hasOwnProperty(key)) {
  759. data[key] = value;
  760. }
  761. }
  762. }
  763. }
  764. } else if ((values.value != null) && (matches = this.PATTERN_ANCHOR_VALUE.exec(values.value))) {
  765. isRef = matches.ref;
  766. values.value = matches.value;
  767. }
  768. if (mergeNode) {
  769. } else if (!(values.value != null) || '' === Utils.trim(values.value, ' ') || Utils.ltrim(values.value, ' ').indexOf('#') === 0) {
  770. if (!(this.isNextLineIndented()) && !(this.isNextLineUnIndentedCollection())) {
  771. if (allowOverwrite || data[key] === void 0) {
  772. data[key] = null;
  773. }
  774. } else {
  775. c = this.getRealCurrentLineNb() + 1;
  776. parser = new Parser(c);
  777. parser.refs = this.refs;
  778. val = parser.parse(this.getNextEmbedBlock(), exceptionOnInvalidType, objectDecoder);
  779. if (allowOverwrite || data[key] === void 0) {
  780. data[key] = val;
  781. }
  782. }
  783. } else {
  784. val = this.parseValue(values.value, exceptionOnInvalidType, objectDecoder);
  785. if (allowOverwrite || data[key] === void 0) {
  786. data[key] = val;
  787. }
  788. }
  789. } else {
  790. lineCount = this.lines.length;
  791. if (1 === lineCount || (2 === lineCount && Utils.isEmpty(this.lines[1]))) {
  792. try {
  793. value = Inline.parse(this.lines[0], exceptionOnInvalidType, objectDecoder);
  794. } catch (error1) {
  795. e = error1;
  796. e.parsedLine = this.getRealCurrentLineNb() + 1;
  797. e.snippet = this.currentLine;
  798. throw e;
  799. }
  800. if (typeof value === 'object') {
  801. if (value instanceof Array) {
  802. first = value[0];
  803. } else {
  804. for (key in value) {
  805. first = value[key];
  806. break;
  807. }
  808. }
  809. if (typeof first === 'string' && first.indexOf('*') === 0) {
  810. data = [];
  811. for (n = 0, len3 = value.length; n < len3; n++) {
  812. alias = value[n];
  813. data.push(this.refs[alias.slice(1)]);
  814. }
  815. value = data;
  816. }
  817. }
  818. return value;
  819. } else if ((ref2 = Utils.ltrim(value).charAt(0)) === '[' || ref2 === '{') {
  820. try {
  821. return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
  822. } catch (error2) {
  823. e = error2;
  824. e.parsedLine = this.getRealCurrentLineNb() + 1;
  825. e.snippet = this.currentLine;
  826. throw e;
  827. }
  828. }
  829. throw new ParseException('Unable to parse.', this.getRealCurrentLineNb() + 1, this.currentLine);
  830. }
  831. if (isRef) {
  832. if (data instanceof Array) {
  833. this.refs[isRef] = data[data.length - 1];
  834. } else {
  835. lastKey = null;
  836. for (key in data) {
  837. lastKey = key;
  838. }
  839. this.refs[isRef] = data[lastKey];
  840. }
  841. }
  842. }
  843. if (Utils.isEmpty(data)) {
  844. return null;
  845. } else {
  846. return data;
  847. }
  848. };
  849. Parser.prototype.getRealCurrentLineNb = function() {
  850. return this.currentLineNb + this.offset;
  851. };
  852. Parser.prototype.getCurrentLineIndentation = function() {
  853. return this.currentLine.length - Utils.ltrim(this.currentLine, ' ').length;
  854. };
  855. Parser.prototype.getNextEmbedBlock = function(indentation, includeUnindentedCollection) {
  856. var data, indent, isItUnindentedCollection, newIndent, removeComments, removeCommentsPattern, unindentedEmbedBlock;
  857. if (indentation == null) {
  858. indentation = null;
  859. }
  860. if (includeUnindentedCollection == null) {
  861. includeUnindentedCollection = false;
  862. }
  863. this.moveToNextLine();
  864. if (indentation == null) {
  865. newIndent = this.getCurrentLineIndentation();
  866. unindentedEmbedBlock = this.isStringUnIndentedCollectionItem(this.currentLine);
  867. if (!(this.isCurrentLineEmpty()) && 0 === newIndent && !unindentedEmbedBlock) {
  868. throw new ParseException('Indentation problem.', this.getRealCurrentLineNb() + 1, this.currentLine);
  869. }
  870. } else {
  871. newIndent = indentation;
  872. }
  873. data = [this.currentLine.slice(newIndent)];
  874. if (!includeUnindentedCollection) {
  875. isItUnindentedCollection = this.isStringUnIndentedCollectionItem(this.currentLine);
  876. }
  877. removeCommentsPattern = this.PATTERN_FOLDED_SCALAR_END;
  878. removeComments = !removeCommentsPattern.test(this.currentLine);
  879. while (this.moveToNextLine()) {
  880. indent = this.getCurrentLineIndentation();
  881. if (indent === newIndent) {
  882. removeComments = !removeCommentsPattern.test(this.currentLine);
  883. }
  884. if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) {
  885. this.moveToPreviousLine();
  886. break;
  887. }
  888. if (this.isCurrentLineBlank()) {
  889. data.push(this.currentLine.slice(newIndent));
  890. continue;
  891. }
  892. if (removeComments && this.isCurrentLineComment()) {
  893. if (indent === newIndent) {
  894. continue;
  895. }
  896. }
  897. if (indent >= newIndent) {
  898. data.push(this.currentLine.slice(newIndent));
  899. } else if (Utils.ltrim(this.currentLine).charAt(0) === '#') {
  900. } else if (0 === indent) {
  901. this.moveToPreviousLine();
  902. break;
  903. } else {
  904. throw new ParseException('Indentation problem.', this.getRealCurrentLineNb() + 1, this.currentLine);
  905. }
  906. }
  907. return data.join("\n");
  908. };
  909. Parser.prototype.moveToNextLine = function() {
  910. if (this.currentLineNb >= this.lines.length - 1) {
  911. return false;
  912. }
  913. this.currentLine = this.lines[++this.currentLineNb];
  914. return true;
  915. };
  916. Parser.prototype.moveToPreviousLine = function() {
  917. this.currentLine = this.lines[--this.currentLineNb];
  918. };
  919. Parser.prototype.parseValue = function(value, exceptionOnInvalidType, objectDecoder) {
  920. var e, error, error1, foldedIndent, matches, modifiers, pos, ref, ref1, val;
  921. if (0 === value.indexOf('*')) {
  922. pos = value.indexOf('#');
  923. if (pos !== -1) {
  924. value = value.substr(1, pos - 2);
  925. } else {
  926. value = value.slice(1);
  927. }
  928. if (this.refs[value] === void 0) {
  929. throw new ParseException('Reference "' + value + '" does not exist.', this.currentLine);
  930. }
  931. return this.refs[value];
  932. }
  933. if (matches = this.PATTERN_FOLDED_SCALAR_ALL.exec(value)) {
  934. modifiers = (ref = matches.modifiers) != null ? ref : '';
  935. foldedIndent = Math.abs(parseInt(modifiers));
  936. if (isNaN(foldedIndent)) {
  937. foldedIndent = 0;
  938. }
  939. val = this.parseFoldedScalar(matches.separator, this.PATTERN_DECIMAL.replace(modifiers, ''), foldedIndent);
  940. if (matches.type != null) {
  941. Inline.configure(exceptionOnInvalidType, objectDecoder);
  942. return Inline.parseScalar(matches.type + ' ' + val);
  943. } else {
  944. return val;
  945. }
  946. }
  947. try {
  948. return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
  949. } catch (error) {
  950. e = error;
  951. if (((ref1 = value.charAt(0)) === '[' || ref1 === '{') && e instanceof ParseException && this.isNextLineIndented()) {
  952. value += "\n" + this.getNextEmbedBlock();
  953. try {
  954. return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
  955. } catch (error1) {
  956. e = error1;
  957. e.parsedLine = this.getRealCurrentLineNb() + 1;
  958. e.snippet = this.currentLine;
  959. throw e;
  960. }
  961. } else {
  962. e.parsedLine = this.getRealCurrentLineNb() + 1;
  963. e.snippet = this.currentLine;
  964. throw e;
  965. }
  966. }
  967. };
  968. Parser.prototype.parseFoldedScalar = function(separator, indicator, indentation) {
  969. var isCurrentLineBlank, j, len, line, matches, newText, notEOF, pattern, ref, text;
  970. if (indicator == null) {
  971. indicator = '';
  972. }
  973. if (indentation == null) {
  974. indentation = 0;
  975. }
  976. notEOF = this.moveToNextLine();
  977. if (!notEOF) {
  978. return '';
  979. }
  980. isCurrentLineBlank = this.isCurrentLineBlank();
  981. text = '';
  982. while (notEOF && isCurrentLineBlank) {
  983. if (notEOF = this.moveToNextLine()) {
  984. text += "\n";
  985. isCurrentLineBlank = this.isCurrentLineBlank();
  986. }
  987. }
  988. if (0 === indentation) {
  989. if (matches = this.PATTERN_INDENT_SPACES.exec(this.currentLine)) {
  990. indentation = matches[0].length;
  991. }
  992. }
  993. if (indentation > 0) {
  994. pattern = this.PATTERN_FOLDED_SCALAR_BY_INDENTATION[indentation];
  995. if (pattern == null) {
  996. pattern = new Pattern('^ {' + indentation + '}(.*)$');
  997. Parser.prototype.PATTERN_FOLDED_SCALAR_BY_INDENTATION[indentation] = pattern;
  998. }
  999. while (notEOF && (isCurrentLineBlank || (matches = pattern.exec(this.currentLine)))) {
  1000. if (isCurrentLineBlank) {
  1001. text += this.currentLine.slice(indentation);
  1002. } else {
  1003. text += matches[1];
  1004. }
  1005. if (notEOF = this.moveToNextLine()) {
  1006. text += "\n";
  1007. isCurrentLineBlank = this.isCurrentLineBlank();
  1008. }
  1009. }
  1010. } else if (notEOF) {
  1011. text += "\n";
  1012. }
  1013. if (notEOF) {
  1014. this.moveToPreviousLine();
  1015. }
  1016. if ('>' === separator) {
  1017. newText = '';
  1018. ref = text.split("\n");
  1019. for (j = 0, len = ref.length; j < len; j++) {
  1020. line = ref[j];
  1021. if (line.length === 0 || line.charAt(0) === ' ') {
  1022. newText = Utils.rtrim(newText, ' ') + line + "\n";
  1023. } else {
  1024. newText += line + ' ';
  1025. }
  1026. }
  1027. text = newText;
  1028. }
  1029. if ('+' !== indicator) {
  1030. text = Utils.rtrim(text);
  1031. }
  1032. if ('' === indicator) {
  1033. text = this.PATTERN_TRAILING_LINES.replace(text, "\n");
  1034. } else if ('-' === indicator) {
  1035. text = this.PATTERN_TRAILING_LINES.replace(text, '');
  1036. }
  1037. return text;
  1038. };
  1039. Parser.prototype.isNextLineIndented = function(ignoreComments) {
  1040. var EOF, currentIndentation, ret;
  1041. if (ignoreComments == null) {
  1042. ignoreComments = true;
  1043. }
  1044. currentIndentation = this.getCurrentLineIndentation();
  1045. EOF = !this.moveToNextLine();
  1046. if (ignoreComments) {
  1047. while (!EOF && this.isCurrentLineEmpty()) {
  1048. EOF = !this.moveToNextLine();
  1049. }
  1050. } else {
  1051. while (!EOF && this.isCurrentLineBlank()) {
  1052. EOF = !this.moveToNextLine();
  1053. }
  1054. }
  1055. if (EOF) {
  1056. return false;
  1057. }
  1058. ret = false;
  1059. if (this.getCurrentLineIndentation() > currentIndentation) {
  1060. ret = true;
  1061. }
  1062. this.moveToPreviousLine();
  1063. return ret;
  1064. };
  1065. Parser.prototype.isCurrentLineEmpty = function() {
  1066. var trimmedLine;
  1067. trimmedLine = Utils.trim(this.currentLine, ' ');
  1068. return trimmedLine.length === 0 || trimmedLine.charAt(0) === '#';
  1069. };
  1070. Parser.prototype.isCurrentLineBlank = function() {
  1071. return '' === Utils.trim(this.currentLine, ' ');
  1072. };
  1073. Parser.prototype.isCurrentLineComment = function() {
  1074. var ltrimmedLine;
  1075. ltrimmedLine = Utils.ltrim(this.currentLine, ' ');
  1076. return ltrimmedLine.charAt(0) === '#';
  1077. };
  1078. Parser.prototype.cleanup = function(value) {
  1079. var count, i, indent, j, l, len, len1, line, lines, ref, ref1, ref2, smallestIndent, trimmedValue;
  1080. if (value.indexOf("\r") !== -1) {
  1081. value = value.split("\r\n").join("\n").split("\r").join("\n");
  1082. }
  1083. count = 0;
  1084. ref = this.PATTERN_YAML_HEADER.replaceAll(value, ''), value = ref[0], count = ref[1];
  1085. this.offset += count;
  1086. ref1 = this.PATTERN_LEADING_COMMENTS.replaceAll(value, '', 1), trimmedValue = ref1[0], count = ref1[1];
  1087. if (count === 1) {
  1088. this.offset += Utils.subStrCount(value, "\n") - Utils.subStrCount(trimmedValue, "\n");
  1089. value = trimmedValue;
  1090. }
  1091. ref2 = this.PATTERN_DOCUMENT_MARKER_START.replaceAll(value, '', 1), trimmedValue = ref2[0], count = ref2[1];
  1092. if (count === 1) {
  1093. this.offset += Utils.subStrCount(value, "\n") - Utils.subStrCount(trimmedValue, "\n");
  1094. value = trimmedValue;
  1095. value = this.PATTERN_DOCUMENT_MARKER_END.replace(value, '');
  1096. }
  1097. lines = value.split("\n");
  1098. smallestIndent = -1;
  1099. for (j = 0, len = lines.length; j < len; j++) {
  1100. line = lines[j];
  1101. if (Utils.trim(line, ' ').length === 0) {
  1102. continue;
  1103. }
  1104. indent = line.length - Utils.ltrim(line).length;
  1105. if (smallestIndent === -1 || indent < smallestIndent) {
  1106. smallestIndent = indent;
  1107. }
  1108. }
  1109. if (smallestIndent > 0) {
  1110. for (i = l = 0, len1 = lines.length; l < len1; i = ++l) {
  1111. line = lines[i];
  1112. lines[i] = line.slice(smallestIndent);
  1113. }
  1114. value = lines.join("\n");
  1115. }
  1116. return value;
  1117. };
  1118. Parser.prototype.isNextLineUnIndentedCollection = function(currentIndentation) {
  1119. var notEOF, ret;
  1120. if (currentIndentation == null) {
  1121. currentIndentation = null;
  1122. }
  1123. if (currentIndentation == null) {
  1124. currentIndentation = this.getCurrentLineIndentation();
  1125. }
  1126. notEOF = this.moveToNextLine();
  1127. while (notEOF && this.isCurrentLineEmpty()) {
  1128. notEOF = this.moveToNextLine();
  1129. }
  1130. if (false === notEOF) {
  1131. return false;
  1132. }
  1133. ret = false;
  1134. if (this.getCurrentLineIndentation() === currentIndentation && this.isStringUnIndentedCollectionItem(this.currentLine)) {
  1135. ret = true;
  1136. }
  1137. this.moveToPreviousLine();
  1138. return ret;
  1139. };
  1140. Parser.prototype.isStringUnIndentedCollectionItem = function() {
  1141. return this.currentLine === '-' || this.currentLine.slice(0, 2) === '- ';
  1142. };
  1143. return Parser;
  1144. })();
  1145. module.exports = Parser;
  1146. },{"./Exception/ParseException":4,"./Inline":5,"./Pattern":7,"./Utils":9}],7:[function(require,module,exports){
  1147. var Pattern;
  1148. Pattern = (function() {
  1149. Pattern.prototype.regex = null;
  1150. Pattern.prototype.rawRegex = null;
  1151. Pattern.prototype.cleanedRegex = null;
  1152. Pattern.prototype.mapping = null;
  1153. function Pattern(rawRegex, modifiers) {
  1154. var _char, capturingBracketNumber, cleanedRegex, i, len, mapping, name, part, subChar;
  1155. if (modifiers == null) {
  1156. modifiers = '';
  1157. }
  1158. cleanedRegex = '';
  1159. len = rawRegex.length;
  1160. mapping = null;
  1161. capturingBracketNumber = 0;
  1162. i = 0;
  1163. while (i < len) {
  1164. _char = rawRegex.charAt(i);
  1165. if (_char === '\\') {
  1166. cleanedRegex += rawRegex.slice(i, +(i + 1) + 1 || 9e9);
  1167. i++;
  1168. } else if (_char === '(') {
  1169. if (i < len - 2) {
  1170. part = rawRegex.slice(i, +(i + 2) + 1 || 9e9);
  1171. if (part === '(?:') {
  1172. i += 2;
  1173. cleanedRegex += part;
  1174. } else if (part === '(?<') {
  1175. capturingBracketNumber++;
  1176. i += 2;
  1177. name = '';
  1178. while (i + 1 < len) {
  1179. subChar = rawRegex.charAt(i + 1);
  1180. if (subChar === '>') {
  1181. cleanedRegex += '(';
  1182. i++;
  1183. if (name.length > 0) {
  1184. if (mapping == null) {
  1185. mapping = {};
  1186. }
  1187. mapping[name] = capturingBracketNumber;
  1188. }
  1189. break;
  1190. } else {
  1191. name += subChar;
  1192. }
  1193. i++;
  1194. }
  1195. } else {
  1196. cleanedRegex += _char;
  1197. capturingBracketNumber++;
  1198. }
  1199. } else {
  1200. cleanedRegex += _char;
  1201. }
  1202. } else {
  1203. cleanedRegex += _char;
  1204. }
  1205. i++;
  1206. }
  1207. this.rawRegex = rawRegex;
  1208. this.cleanedRegex = cleanedRegex;
  1209. this.regex = new RegExp(this.cleanedRegex, 'g' + modifiers.replace('g', ''));
  1210. this.mapping = mapping;
  1211. }
  1212. Pattern.prototype.exec = function(str) {
  1213. var index, matches, name, ref;
  1214. this.regex.lastIndex = 0;
  1215. matches = this.regex.exec(str);
  1216. if (matches == null) {
  1217. return null;
  1218. }
  1219. if (this.mapping != null) {
  1220. ref = this.mapping;
  1221. for (name in ref) {
  1222. index = ref[name];
  1223. matches[name] = matches[index];
  1224. }
  1225. }
  1226. return matches;
  1227. };
  1228. Pattern.prototype.test = function(str) {
  1229. this.regex.lastIndex = 0;
  1230. return this.regex.test(str);
  1231. };
  1232. Pattern.prototype.replace = function(str, replacement) {
  1233. this.regex.lastIndex = 0;
  1234. return str.replace(this.regex, replacement);
  1235. };
  1236. Pattern.prototype.replaceAll = function(str, replacement, limit) {
  1237. var count;
  1238. if (limit == null) {
  1239. limit = 0;
  1240. }
  1241. this.regex.lastIndex = 0;
  1242. count = 0;
  1243. while (this.regex.test(str) && (limit === 0 || count < limit)) {
  1244. this.regex.lastIndex = 0;
  1245. str = str.replace(this.regex, '');
  1246. count++;
  1247. }
  1248. return [str, count];
  1249. };
  1250. return Pattern;
  1251. })();
  1252. module.exports = Pattern;
  1253. },{}],8:[function(require,module,exports){
  1254. var Pattern, Unescaper, Utils;
  1255. Utils = require('./Utils');
  1256. Pattern = require('./Pattern');
  1257. Unescaper = (function() {
  1258. function Unescaper() {}
  1259. Unescaper.PATTERN_ESCAPED_CHARACTER = new Pattern('\\\\([0abt\tnvfre "\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})');
  1260. Unescaper.unescapeSingleQuotedString = function(value) {
  1261. return value.replace(/\'\'/g, '\'');
  1262. };
  1263. Unescaper.unescapeDoubleQuotedString = function(value) {
  1264. if (this._unescapeCallback == null) {
  1265. this._unescapeCallback = (function(_this) {
  1266. return function(str) {
  1267. return _this.unescapeCharacter(str);
  1268. };
  1269. })(this);
  1270. }
  1271. return this.PATTERN_ESCAPED_CHARACTER.replace(value, this._unescapeCallback);
  1272. };
  1273. Unescaper.unescapeCharacter = function(value) {
  1274. var ch;
  1275. ch = String.fromCharCode;
  1276. switch (value.charAt(1)) {
  1277. case '0':
  1278. return ch(0);
  1279. case 'a':
  1280. return ch(7);
  1281. case 'b':
  1282. return ch(8);
  1283. case 't':
  1284. return "\t";
  1285. case "\t":
  1286. return "\t";
  1287. case 'n':
  1288. return "\n";
  1289. case 'v':
  1290. return ch(11);
  1291. case 'f':
  1292. return ch(12);
  1293. case 'r':
  1294. return ch(13);
  1295. case 'e':
  1296. return ch(27);
  1297. case ' ':
  1298. return ' ';
  1299. case '"':
  1300. return '"';
  1301. case '/':
  1302. return '/';
  1303. case '\\':
  1304. return '\\';
  1305. case 'N':
  1306. return ch(0x0085);
  1307. case '_':
  1308. return ch(0x00A0);
  1309. case 'L':
  1310. return ch(0x2028);
  1311. case 'P':
  1312. return ch(0x2029);
  1313. case 'x':
  1314. return Utils.utf8chr(Utils.hexDec(value.substr(2, 2)));
  1315. case 'u':
  1316. return Utils.utf8chr(Utils.hexDec(value.substr(2, 4)));
  1317. case 'U':
  1318. return Utils.utf8chr(Utils.hexDec(value.substr(2, 8)));
  1319. default:
  1320. return '';
  1321. }
  1322. };
  1323. return Unescaper;
  1324. })();
  1325. module.exports = Unescaper;
  1326. },{"./Pattern":7,"./Utils":9}],9:[function(require,module,exports){
  1327. var Pattern, Utils;
  1328. Pattern = require('./Pattern');
  1329. Utils = (function() {
  1330. function Utils() {}
  1331. Utils.REGEX_LEFT_TRIM_BY_CHAR = {};
  1332. Utils.REGEX_RIGHT_TRIM_BY_CHAR = {};
  1333. Utils.REGEX_SPACES = /\s+/g;
  1334. Utils.REGEX_DIGITS = /^\d+$/;
  1335. Utils.REGEX_OCTAL = /[^0-7]/gi;
  1336. Utils.REGEX_HEXADECIMAL = /[^a-f0-9]/gi;
  1337. Utils.PATTERN_DATE = new Pattern('^' + '(?<year>[0-9][0-9][0-9][0-9])' + '-(?<month>[0-9][0-9]?)' + '-(?<day>[0-9][0-9]?)' + '(?:(?:[Tt]|[ \t]+)' + '(?<hour>[0-9][0-9]?)' + ':(?<minute>[0-9][0-9])' + ':(?<second>[0-9][0-9])' + '(?:\.(?<fraction>[0-9]*))?' + '(?:[ \t]*(?<tz>Z|(?<tz_sign>[-+])(?<tz_hour>[0-9][0-9]?)' + '(?::(?<tz_minute>[0-9][0-9]))?))?)?' + '$', 'i');
  1338. Utils.LOCAL_TIMEZONE_OFFSET = new Date().getTimezoneOffset() * 60 * 1000;
  1339. Utils.trim = function(str, _char) {
  1340. var regexLeft, regexRight;
  1341. if (_char == null) {
  1342. _char = '\\s';
  1343. }
  1344. return str.trim();
  1345. regexLeft = this.REGEX_LEFT_TRIM_BY_CHAR[_char];
  1346. if (regexLeft == null) {
  1347. this.REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp('^' + _char + '' + _char + '*');
  1348. }
  1349. regexLeft.lastIndex = 0;
  1350. regexRight = this.REGEX_RIGHT_TRIM_BY_CHAR[_char];
  1351. if (regexRight == null) {
  1352. this.REGEX_RIGHT_TRIM_BY_CHAR[_char] = regexRight = new RegExp(_char + '' + _char + '*$');
  1353. }
  1354. regexRight.lastIndex = 0;
  1355. return str.replace(regexLeft, '').replace(regexRight, '');
  1356. };
  1357. Utils.ltrim = function(str, _char) {
  1358. var regexLeft;
  1359. if (_char == null) {
  1360. _char = '\\s';
  1361. }
  1362. regexLeft = this.REGEX_LEFT_TRIM_BY_CHAR[_char];
  1363. if (regexLeft == null) {
  1364. this.REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp('^' + _char + '' + _char + '*');
  1365. }
  1366. regexLeft.lastIndex = 0;
  1367. return str.replace(regexLeft, '');
  1368. };
  1369. Utils.rtrim = function(str, _char) {
  1370. var regexRight;
  1371. if (_char == null) {
  1372. _char = '\\s';
  1373. }
  1374. regexRight = this.REGEX_RIGHT_TRIM_BY_CHAR[_char];
  1375. if (regexRight == null) {
  1376. this.REGEX_RIGHT_TRIM_BY_CHAR[_char] = regexRight = new RegExp(_char + '' + _char + '*$');
  1377. }
  1378. regexRight.lastIndex = 0;
  1379. return str.replace(regexRight, '');
  1380. };
  1381. Utils.isEmpty = function(value) {
  1382. return !value || value === '' || value === '0' || (value instanceof Array && value.length === 0);
  1383. };
  1384. Utils.subStrCount = function(string, subString, start, length) {
  1385. var c, i, j, len, ref, sublen;
  1386. c = 0;
  1387. string = '' + string;
  1388. subString = '' + subString;
  1389. if (start != null) {
  1390. string = string.slice(start);
  1391. }
  1392. if (length != null) {
  1393. string = string.slice(0, length);
  1394. }
  1395. len = string.length;
  1396. sublen = subString.length;
  1397. for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
  1398. if (subString === string.slice(i, sublen)) {
  1399. c++;
  1400. i += sublen - 1;
  1401. }
  1402. }
  1403. return c;
  1404. };
  1405. Utils.isDigits = function(input) {
  1406. this.REGEX_DIGITS.lastIndex = 0;
  1407. return this.REGEX_DIGITS.test(input);
  1408. };
  1409. Utils.octDec = function(input) {
  1410. this.REGEX_OCTAL.lastIndex = 0;
  1411. return parseInt((input + '').replace(this.REGEX_OCTAL, ''), 8);
  1412. };
  1413. Utils.hexDec = function(input) {
  1414. this.REGEX_HEXADECIMAL.lastIndex = 0;
  1415. input = this.trim(input);
  1416. if ((input + '').slice(0, 2) === '0x') {
  1417. input = (input + '').slice(2);
  1418. }
  1419. return parseInt((input + '').replace(this.REGEX_HEXADECIMAL, ''), 16);
  1420. };
  1421. Utils.utf8chr = function(c) {
  1422. var ch;
  1423. ch = String.fromCharCode;
  1424. if (0x80 > (c %= 0x200000)) {
  1425. return ch(c);
  1426. }
  1427. if (0x800 > c) {
  1428. return ch(0xC0 | c >> 6) + ch(0x80 | c & 0x3F);
  1429. }
  1430. if (0x10000 > c) {
  1431. return ch(0xE0 | c >> 12) + ch(0x80 | c >> 6 & 0x3F) + ch(0x80 | c & 0x3F);
  1432. }
  1433. return ch(0xF0 | c >> 18) + ch(0x80 | c >> 12 & 0x3F) + ch(0x80 | c >> 6 & 0x3F) + ch(0x80 | c & 0x3F);
  1434. };
  1435. Utils.parseBoolean = function(input, strict) {
  1436. var lowerInput;
  1437. if (strict == null) {
  1438. strict = true;
  1439. }
  1440. if (typeof input === 'string') {
  1441. lowerInput = input.toLowerCase();
  1442. if (!strict) {
  1443. if (lowerInput === 'no') {
  1444. return false;
  1445. }
  1446. }
  1447. if (lowerInput === '0') {
  1448. return false;
  1449. }
  1450. if (lowerInput === 'false') {
  1451. return false;
  1452. }
  1453. if (lowerInput === '') {
  1454. return false;
  1455. }
  1456. return true;
  1457. }
  1458. return !!input;
  1459. };
  1460. Utils.isNumeric = function(input) {
  1461. this.REGEX_SPACES.lastIndex = 0;
  1462. return typeof input === 'number' || typeof input === 'string' && !isNaN(input) && input.replace(this.REGEX_SPACES, '') !== '';
  1463. };
  1464. Utils.stringToDate = function(str) {
  1465. var date, day, fraction, hour, info, minute, month, second, tz_hour, tz_minute, tz_offset, year;
  1466. if (!(str != null ? str.length : void 0)) {
  1467. return null;
  1468. }
  1469. info = this.PATTERN_DATE.exec(str);
  1470. if (!info) {
  1471. return null;
  1472. }
  1473. year = parseInt(info.year, 10);
  1474. month = parseInt(info.month, 10) - 1;
  1475. day = parseInt(info.day, 10);
  1476. if (info.hour == null) {
  1477. date = new Date(Date.UTC(year, month, day));
  1478. return date;
  1479. }
  1480. hour = parseInt(info.hour, 10);
  1481. minute = parseInt(info.minute, 10);
  1482. second = parseInt(info.second, 10);
  1483. if (info.fraction != null) {
  1484. fraction = info.fraction.slice(0, 3);
  1485. while (fraction.length < 3) {
  1486. fraction += '0';
  1487. }
  1488. fraction = parseInt(fraction, 10);
  1489. } else {
  1490. fraction = 0;
  1491. }
  1492. if (info.tz != null) {
  1493. tz_hour = parseInt(info.tz_hour, 10);
  1494. if (info.tz_minute != null) {
  1495. tz_minute = parseInt(info.tz_minute, 10);
  1496. } else {
  1497. tz_minute = 0;
  1498. }
  1499. tz_offset = (tz_hour * 60 + tz_minute) * 60000;
  1500. if ('-' === info.tz_sign) {
  1501. tz_offset *= -1;
  1502. }
  1503. }
  1504. date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
  1505. if (tz_offset) {
  1506. date.setTime(date.getTime() + tz_offset);
  1507. }
  1508. return date;
  1509. };
  1510. Utils.strRepeat = function(str, number) {
  1511. var i, res;
  1512. res = '';
  1513. i = 0;
  1514. while (i < number) {
  1515. res += str;
  1516. i++;
  1517. }
  1518. return res;
  1519. };
  1520. Utils.getStringFromFile = function(path, callback) {
  1521. var data, fs, j, len1, name, ref, req, xhr;
  1522. if (callback == null) {
  1523. callback = null;
  1524. }
  1525. xhr = null;
  1526. if (typeof window !== "undefined" && window !== null) {
  1527. if (window.XMLHttpRequest) {
  1528. xhr = new XMLHttpRequest();
  1529. } else if (window.ActiveXObject) {
  1530. ref = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
  1531. for (j = 0, len1 = ref.length; j < len1; j++) {
  1532. name = ref[j];
  1533. try {
  1534. xhr = new ActiveXObject(name);
  1535. } catch (undefined) {}
  1536. }
  1537. }
  1538. }
  1539. if (xhr != null) {
  1540. if (callback != null) {
  1541. xhr.onreadystatechange = function() {
  1542. if (xhr.readyState === 4) {
  1543. if (xhr.status === 200 || xhr.status === 0) {
  1544. return callback(xhr.responseText);
  1545. } else {
  1546. return callback(null);
  1547. }
  1548. }
  1549. };
  1550. xhr.open('GET', path, true);
  1551. return xhr.send(null);
  1552. } else {
  1553. xhr.open('GET', path, false);
  1554. xhr.send(null);
  1555. if (xhr.status === 200 || xhr.status === 0) {
  1556. return xhr.responseText;
  1557. }
  1558. return null;
  1559. }
  1560. } else {
  1561. req = require;
  1562. fs = req('fs');
  1563. if (callback != null) {
  1564. return fs.readFile(path, function(err, data) {
  1565. if (err) {
  1566. return callback(null);
  1567. } else {
  1568. return callback(String(data));
  1569. }
  1570. });
  1571. } else {
  1572. data = fs.readFileSync(path);
  1573. if (data != null) {
  1574. return String(data);
  1575. }
  1576. return null;
  1577. }
  1578. }
  1579. };
  1580. return Utils;
  1581. })();
  1582. module.exports = Utils;
  1583. },{"./Pattern":7}],10:[function(require,module,exports){
  1584. var Dumper, Parser, Utils, Yaml;
  1585. Parser = require('./Parser');
  1586. Dumper = require('./Dumper');
  1587. Utils = require('./Utils');
  1588. Yaml = (function() {
  1589. function Yaml() {}
  1590. Yaml.parse = function(input, exceptionOnInvalidType, objectDecoder) {
  1591. if (exceptionOnInvalidType == null) {
  1592. exceptionOnInvalidType = false;
  1593. }
  1594. if (objectDecoder == null) {
  1595. objectDecoder = null;
  1596. }
  1597. return new Parser().parse(input, exceptionOnInvalidType, objectDecoder);
  1598. };
  1599. Yaml.parseFile = function(path, callback, exceptionOnInvalidType, objectDecoder) {
  1600. var input;
  1601. if (callback == null) {
  1602. callback = null;
  1603. }
  1604. if (exceptionOnInvalidType == null) {
  1605. exceptionOnInvalidType = false;
  1606. }
  1607. if (objectDecoder == null) {
  1608. objectDecoder = null;
  1609. }
  1610. if (callback != null) {
  1611. return Utils.getStringFromFile(path, (function(_this) {
  1612. return function(input) {
  1613. var result;
  1614. result = null;
  1615. if (input != null) {
  1616. result = _this.parse(input, exceptionOnInvalidType, objectDecoder);
  1617. }
  1618. callback(result);
  1619. };
  1620. })(this));
  1621. } else {
  1622. input = Utils.getStringFromFile(path);
  1623. if (input != null) {
  1624. return this.parse(input, exceptionOnInvalidType, objectDecoder);
  1625. }
  1626. return null;
  1627. }
  1628. };
  1629. Yaml.dump = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
  1630. var yaml;
  1631. if (inline == null) {
  1632. inline = 2;
  1633. }
  1634. if (indent == null) {
  1635. indent = 4;
  1636. }
  1637. if (exceptionOnInvalidType == null) {
  1638. exceptionOnInvalidType = false;
  1639. }
  1640. if (objectEncoder == null) {
  1641. objectEncoder = null;
  1642. }
  1643. yaml = new Dumper();
  1644. yaml.indentation = indent;
  1645. return yaml.dump(input, inline, 0, exceptionOnInvalidType, objectEncoder);
  1646. };
  1647. Yaml.register = function() {
  1648. var require_handler;
  1649. require_handler = function(module, filename) {
  1650. return module.exports = YAML.parseFile(filename);
  1651. };
  1652. if ((typeof require !== "undefined" && require !== null ? require.extensions : void 0) != null) {
  1653. require.extensions['.yml'] = require_handler;
  1654. return require.extensions['.yaml'] = require_handler;
  1655. }
  1656. };
  1657. Yaml.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
  1658. return this.dump(input, inline, indent, exceptionOnInvalidType, objectEncoder);
  1659. };
  1660. Yaml.load = function(path, callback, exceptionOnInvalidType, objectDecoder) {
  1661. return this.parseFile(path, callback, exceptionOnInvalidType, objectDecoder);
  1662. };
  1663. return Yaml;
  1664. })();
  1665. if (typeof window !== "undefined" && window !== null) {
  1666. window.YAML = Yaml;
  1667. }
  1668. if (typeof window === "undefined" || window === null) {
  1669. this.YAML = Yaml;
  1670. }
  1671. module.exports = Yaml;
  1672. },{"./Dumper":1,"./Parser":6,"./Utils":9}]},{},[10]);