Comparing version 0.1.2 to 0.1.3
@@ -433,3 +433,4 @@ /* | ||
// some comment can end the scalar | ||
if ( value.substr(this.i+1).replace(/^\s+#.*$/, '') != '' ) { | ||
if ( value.substr(this.i+1).replace(/^\s*#.*$/, '') != '' ) { | ||
console.log("oups "+value.substr(this.i+1)); | ||
throw new YamlParseException('Unexpected characters near "'+value.substr(this.i)+'".'); | ||
@@ -666,3 +667,3 @@ } | ||
default: | ||
isQuoted = this.inArray(sequence.charAt(i), ['"', "'"]); | ||
var isQuoted = this.inArray(sequence.charAt(i), ['"', "'"]); | ||
var value = this.parseScalar(sequence, [',', ']'], ['"', "'"], i); | ||
@@ -669,0 +670,0 @@ i = this.i; |
@@ -22,2 +22,2 @@ /* | ||
*/ | ||
(function(){var e=function(e,t,n,r){this.rawMessage=e,this.parsedLine=t!==undefined?t:-1,this.snippet=n!==undefined?n:null,this.parsedFile=r!==undefined?r:null,this.updateRepr(),this.message=e};e.prototype={name:"YamlParseException",message:null,parsedFile:null,parsedLine:-1,snippet:null,rawMessage:null,isDefined:function(e){return e!=undefined&&e!=null},getSnippet:function(){return this.snippet},setSnippet:function(e){this.snippet=e,this.updateRepr()},getParsedFile:function(){return this.parsedFile},setParsedFile:function(e){this.parsedFile=e,this.updateRepr()},getParsedLine:function(){return this.parsedLine},setParsedLine:function(e){this.parsedLine=e,this.updateRepr()},updateRepr:function(){this.message=this.rawMessage;var e=!1;"."===this.message.charAt(this.message.length-1)&&(this.message=this.message.substring(0,this.message.length-1),e=!0),null!==this.parsedFile&&(this.message+=" in "+JSON.stringify(this.parsedFile)),this.parsedLine>=0&&(this.message+=" at line "+this.parsedLine),this.snippet&&(this.message+=' (near "'+this.snippet+'")'),e&&(this.message+=".")}};var t=!1,n=function(){};n.prototype={parseFile:function(t,r){if(r==null){var i=this.getFileContents(t),s=null;try{s=this.parse(i)}catch(o){throw o instanceof e&&o.setParsedFile(t),o}return s}this.getFileContents(t,function(e){r((new n).parse(e))})},parse:function(e){var t=new s;return t.parse(e)},dump:function(e,t,n){t==null&&(t=2);var r=new u;return n&&(r.numSpacesForIndentation=n),r.dump(e,t)},getXHR:function(){if(window.XMLHttpRequest)return new XMLHttpRequest;if(window.ActiveXObject){var e=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(var t=0;t<4;t++)try{return new ActiveXObject(e[t])}catch(n){}}return null},getFileContents:function(e,n){if(t){var r=require("fs");if(n==null){var i=r.readFileSync(e);return i==null?null:""+i}r.readFile(e,function(e,t){e?n(null):n(t)})}else{var s=this.getXHR();if(n==null)return s.open("GET",e,!1),s.send(null),s.status==200||s.status==0?s.responseText:null;s.onreadystatechange=function(){s.readyState==4&&(s.status==200||s.status==0?n(s.responseText):n(null))},s.open("GET",e,!0),s.send(null)}}};var r={stringify:function(e,t,r){return(new n).dump(e,t,r)},parse:function(e){return(new n).parse(e)},load:function(e,t){return(new n).parseFile(e,t)}};typeof exports!="undefined"&&typeof module!="undefined"&&module.exports&&(exports=module.exports=r,t=!0,function(){var e=function(e,t){e.exports=r.load(t)};undefined!==require.extensions&&(require.extensions[".yml"]=e,require.extensions[".yaml"]=e)}()),typeof window!="undefined"&&(window.YAML=r);var i=function(){};i.prototype={i:null,parse:function(t){var n=null;t=this.trim(t);if(0==t.length)return"";switch(t.charAt(0)){case"[":n=this.parseSequence(t);break;case"{":n=this.parseMapping(t);break;default:n=this.parseScalar(t)}if(t.substr(this.i+1).replace(/^\s+#.*$/,"")!="")throw new e('Unexpected characters near "'+t.substr(this.i)+'".');return n},dump:function(e){if(undefined==e||null==e)return"null";if(e instanceof Date)return e.toISOString();if(typeof e=="object")return this.dumpObject(e);if(typeof e=="boolean")return e?"true":"false";if(/^\d+$/.test(e))return typeof e=="string"?"'"+e+"'":parseInt(e);if(this.isNumeric(e))return typeof e=="string"?"'"+e+"'":parseFloat(e);if(typeof e=="number")return e==Infinity?".Inf":e==-Infinity?"-.Inf":isNaN(e)?".NAN":e;var t=new YamlEscaper;return t.requiresDoubleQuoting(e)?t.escapeWithDoubleQuotes(e):t.requiresSingleQuoting(e)?t.escapeWithSingleQuotes(e):""==e?"":this.getTimestampRegex().test(e)?"'"+e+"'":this.inArray(e.toLowerCase(),["null","~","true","false"])?"'"+e+"'":e},dumpObject:function(e){var t=this.getKeys(e),n=null,r,i=t.length;if(e instanceof Array){n=[];for(r=0;r<i;r++)n.push(this.dump(e[t[r]]));return"["+n.join(", ")+"]"}n=[];for(r=0;r<i;r++)n.push(this.dump(t[r])+": "+this.dump(e[t[r]]));return"{ "+n.join(", ")+" }"},parseScalar:function(t,n,r,i,s){n==undefined&&(n=null),r==undefined&&(r=['"',"'"]),i==undefined&&(i=0),s==undefined&&(s=!0);var o=null,u=null,a=null;if(this.inArray(t[i],r)){o=this.parseQuotedScalar(t,i),i=this.i;if(null!==n){var f=t.substr(i).replace(/^\s+/,"");if(!this.inArray(f.charAt(0),n))throw new e("Unexpected characters ("+t.substr(i)+").")}}else{if(!n)o=(t+"").substring(i),i+=o.length,u=o.indexOf(" #"),u!=-1&&(o=o.substr(0,u).replace(/\s+$/g,""));else{if(!(a=(new RegExp("^(.+?)("+n.join("|")+")")).exec((t+"").substring(i))))throw new e("Malformed inline YAML string ("+t+").");o=a[1],i+=o.length}o=s?this.evaluateScalar(o):o}return this.i=i,o},parseQuotedScalar:function(t,n){var r=null;if(!(r=(new RegExp("^"+i.REGEX_QUOTED_STRING)).exec((t+"").substring(n))))throw new e("Malformed inline YAML string ("+(t+"").substring(n)+").");var s=r[0].substr(1,r[0].length-2),u=new o;return'"'==(t+"").charAt(n)?s=u.unescapeDoubleQuotedString(s):s=u.unescapeSingleQuotedString(s),n+=r[0].length,this.i=n,s},parseSequence:function(t,n){n==undefined&&(n=0);var r=[],i=t.length;n+=1;while(n<i){switch(t.charAt(n)){case"[":r.push(this.parseSequence(t,n)),n=this.i;break;case"{":r.push(this.parseMapping(t,n)),n=this.i;break;case"]":return this.i=n,r;case",":case" ":break;default:isQuoted=this.inArray(t.charAt(n),['"',"'"]);var s=this.parseScalar(t,[",","]"],['"',"'"],n);n=this.i;if(!isQuoted&&(s+"").indexOf(": ")!=-1)try{s=this.parseMapping("{"+s+"}")}catch(o){if(!(o instanceof e))throw o}r.push(s),n--}n++}throw new e('Malformed inline YAML string "'+t+'"')},parseMapping:function(t,n){n==undefined&&(n=0);var r={},i=t.length;n+=1;var s=!1,o=!1;while(n<i){o=!1;switch(t.charAt(n)){case" ":case",":n++,o=!0;break;case"}":return this.i=n,r}if(o)continue;var u=this.parseScalar(t,[":"," "],['"',"'"],n,!1);n=this.i,s=!1;while(n<i){switch(t.charAt(n)){case"[":r[u]=this.parseSequence(t,n),n=this.i,s=!0;break;case"{":r[u]=this.parseMapping(t,n),n=this.i,s=!0;break;case":":case" ":break;default:r[u]=this.parseScalar(t,[",","}"],['"',"'"],n),n=this.i,s=!0,n--}++n;if(s){o=!0;break}}if(o)continue}throw new e('Malformed inline YAML string "'+t+'"')},evaluateScalar:function(e){e=this.trim(e);var t=null,n=null;return"null"==e.toLowerCase()||""==e||"~"==e?null:(e+"").indexOf("!str ")==0?(""+e).substring(5):(e+"").indexOf("! ")==0?parseInt(this.parseScalar((e+"").substr(2))):/^\d+$/.test(e)?(t=e,n=parseInt(e),"0"==e.charAt(0)?this.octdec(e):""+t==""+n?n:t):"true"==(e+"").toLowerCase()?!0:"false"==(e+"").toLowerCase()?!1:this.isNumeric(e)?"0x"==(e+"").substr(0,2)?this.hexdec(e):parseFloat(e):e.toLowerCase()==".inf"?Infinity:e.toLowerCase()==".nan"?NaN:e.toLowerCase()=="-.inf"?-Infinity:/^(-|\+)?[0-9,]+(\.[0-9]+)?$/.test(e)?parseFloat(e.split(",").join("")):this.getTimestampRegex().test(e)?new Date(this.strtotime(e)):""+e},getTimestampRegex:function(){return new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ ]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:.([0-9]*))?(?:[ ]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$","gi")},trim:function(e){return(e+"").replace(/^\s+/,"").replace(/\s+$/,"")},isNumeric:function(e){return e-0==e&&e.length>0&&e.replace(/\s+/g,"")!=""},inArray:function(e,t){var n,r=t.length;for(n=0;n<r;n++)if(e==t[n])return!0;return!1},getKeys:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},octdec:function(e){return parseInt((e+"").replace(/[^0-7]/gi,""),8)},hexdec:function(e){return e=this.trim(e),(e+"").substr(0,2)=="0x"&&(e=(e+"").substring(2)),parseInt((e+"").replace(/[^a-f0-9]/gi,""),16)},strtotime:function(e,t){var n,r,i,s,o="";e=(e+"").replace(/\s{2,}|^\s|\s$/g," ").replace(/[\t\r\n]/g,"");if(e==="now")return t===null||isNaN(t)?(new Date).getTime()||0:t||0;if(!isNaN(o=Date.parse(e)))return o||0;t?t=new Date(t):t=new Date,e=e.toLowerCase();var u={day:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},mon:["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]},a=function(e){var n=e[2]&&e[2]==="ago",r=(r=e[0]==="last"?-1:1)*(n?-1:1);switch(e[0]){case"last":case"next":switch(e[1].substring(0,3)){case"yea":t.setFullYear(t.getFullYear()+r);break;case"wee":t.setDate(t.getDate()+r*7);break;case"day":t.setDate(t.getDate()+r);break;case"hou":t.setHours(t.getHours()+r);break;case"min":t.setMinutes(t.getMinutes()+r);break;case"sec":t.setSeconds(t.getSeconds()+r);break;case"mon":if(e[1]==="month"){t.setMonth(t.getMonth()+r);break};default:var i=u.day[e[1].substring(0,3)];if(typeof i!="undefined"){var s=i-t.getDay();s===0?s=7*r:s>0?e[0]==="last"&&(s-=7):e[0]==="next"&&(s+=7),t.setDate(t.getDate()+s),t.setHours(0,0,0,0)}}break;default:if(!/\d+/.test(e[0]))return!1;r*=parseInt(e[0],10);switch(e[1].substring(0,3)){case"yea":t.setFullYear(t.getFullYear()+r);break;case"mon":t.setMonth(t.getMonth()+r);break;case"wee":t.setDate(t.getDate()+r*7);break;case"day":t.setDate(t.getDate()+r);break;case"hou":t.setHours(t.getHours()+r);break;case"min":t.setMinutes(t.getMinutes()+r);break;case"sec":t.setSeconds(t.getSeconds()+r)}}return!0};i=e.match(/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/);if(i!==null)return i[2]?i[3]||(i[2]+=":00"):i[2]="00:00:00",s=i[1].split(/-/g),s[1]=u.mon[s[1]-1]||s[1],s[0]=+s[0],s[0]=s[0]>=0&&s[0]<=69?"20"+(s[0]<10?"0"+s[0]:s[0]+""):s[0]>=70&&s[0]<=99?"19"+s[0]:s[0]+"",parseInt(this.strtotime(s[2]+" "+s[1]+" "+s[0]+" "+i[2])+(i[4]?i[4]:""),10);var f="([+-]?\\d+\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday)|(last|next)\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday))(\\sago)?";i=e.match(new RegExp(f,"gi"));if(i===null)return!1;for(n=0,r=i.length;n<r;n++)if(!a(i[n].split(" ")))return!1;return t.getTime()||0}},i.REGEX_QUOTED_STRING="(?:\"(?:[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"|'(?:[^']*(?:''[^']*)*)')";var s=function(e){this.offset=e!==undefined?e:0};s.prototype={offset:0,lines:[],currentLineNb:-1,currentLine:"",refs:{},parse:function(t){this.currentLineNb=-1,this.currentLine="",this.lines=this.cleanup(t).split("\n");var n=null,r=null;while(this.moveToNextLine()){if(this.isCurrentLineEmpty())continue;if(this.currentLine.charAt(0)==" ")throw new e("A YAML file cannot contain tabs as indentation.",this.getRealCurrentLineNb()+1,this.currentLine);var o=!1,u=!1,a=!1,f=null,l=null,c=null,h=null,p=null,d=null,v=null,m=null,g=null;if(f=/^\-((\s+)(.+?))?\s*$/.exec(this.currentLine)){if(r&&"mapping"==r)throw new e("You cannot define a sequence item when in a mapping",this.getRealCurrentLineNb()+1,this.currentLine);r="sequence",this.isDefined(n)||(n=[]),f={leadspaces:f[2],value:f[3]},this.isDefined(f.value)&&(l=/^&([^ ]+) *(.*)/.exec(f.value))&&(l={ref:l[1],value:l[2]},o=l.ref,f.value=l.value),!this.isDefined(f.value)||""==this.trim(f.value)||f.value.replace(/^ +/,"").charAt(0)=="#"?(c=this.getRealCurrentLineNb()+1,h=new s(c),h.refs=this.refs,n.push(h.parse(this.getNextEmbedBlock())),this.refs=h.refs):this.isDefined(f.leadspaces)&&" "==f.leadspaces&&(l=(new RegExp("^("+i.REGEX_QUOTED_STRING+"|[^ '\"{[].*?) *:(\\s+(.+?))?\\s*$")).exec(f.value))?(l={key:l[1],value:l[3]},c=this.getRealCurrentLineNb(),h=new s(c),h.refs=this.refs,p=f.value,this.isNextLineIndented()||(p+="\n"+this.getNextEmbedBlock(this.getCurrentLineIndentation()+2)),n.push(h.parse(p)),this.refs=h.refs):n.push(this.parseValue(f.value))}else{if(!(f=(new RegExp("^("+i.REGEX_QUOTED_STRING+"|[^ '\"[{].*?) *:(\\s+(.+?))?\\s*$")).exec(this.currentLine))){if(2==this.lines.length&&this.isEmpty(this.lines[1])){try{t=(new i).parse(this.lines[0])}catch(y){throw y instanceof e&&(y.setParsedLine(this.getRealCurrentLineNb()+1),y.setSnippet(this.currentLine)),y}if(this.isObject(t)){var S=t[0];if(typeof t=="string"&&"*"==S.charAt(0)){n=[],m=t.length;for(var w=0;w<m;w++)n.push(this.refs[t[w].substr(1)]);t=n}}return t}throw new e("Unable to parse.",this.getRealCurrentLineNb()+1,this.currentLine)}this.isDefined(n)||(n={});if(r&&"sequence"==r)throw new e("You cannot define a mapping item when in a sequence",this.getRealCurrentLineNb()+1,this.currentLine);r="mapping",f={key:f[1],value:f[3]};try{d=(new i).parseScalar(f.key)}catch(y){throw y instanceof e&&(y.setParsedLine(this.getRealCurrentLineNb()+1),y.setSnippet(this.currentLine)),y}if("<<"==d)if(this.isDefined(f.value)&&"*"==(f.value+"").charAt(0)){u=f.value.substr(1);if(this.refs[u]==undefined)throw new e('Reference "'+t+'" does not exist',this.getRealCurrentLineNb()+1,this.currentLine)}else{this.isDefined(f.value)&&f.value!=""?t=f.value:t=this.getNextEmbedBlock(),c=this.getRealCurrentLineNb()+1,h=new s(c),h.refs=this.refs,v=h.parse(t),this.refs=h.refs;var b=[];if(!this.isObject(v))throw new e("YAML merge keys used with a scalar value instead of an array",this.getRealCurrentLineNb()+1,this.currentLine);if(this.isDefined(v[0])){g=this.reverseArray(v),m=g.length;for(var w=0;w<m;w++){var E=g[w];if(!this.isObject(g[w]))throw new e("Merge items must be arrays",this.getRealCurrentLineNb()+1,this.currentLine);b=this.mergeObject(g[w],b)}}else b=this.mergeObject(b,v);a=b}else this.isDefined(f.value)&&(l=/^&([^ ]+) *(.*)/.exec(f.value))&&(l={ref:l[1],value:l[2]},o=l.ref,f.value=l.value);a?n=a:!this.isDefined(f.value)||""==this.trim(f.value)||this.trim(f.value).charAt(0)=="#"?this.isNextLineIndented()&&!this.isNextLineUnIndentedCollection()?n[d]=null:(c=this.getRealCurrentLineNb()+1,h=new s(c),h.refs=this.refs,n[d]=h.parse(this.getNextEmbedBlock()),this.refs=h.refs):u?n=this.refs[u]:n[d]=this.parseValue(f.value)}if(o)if(n instanceof Array)this.refs[o]=n[n.length-1];else{var x=null;for(var T in n)n.hasOwnProperty(T)&&(x=T);this.refs[o]=n[T]}}return this.isEmpty(n)?null:n},getRealCurrentLineNb:function(){return this.currentLineNb+this.offset},getCurrentLineIndentation:function(){return this.currentLine.length-this.currentLine.replace(/^ +/g,"").length},getNextEmbedBlock:function(t){this.moveToNextLine();var n=null,r=null;if(!this.isDefined(t)){n=this.getCurrentLineIndentation();var i=this.isStringUnIndentedCollectionItem(this.currentLine);if(!this.isCurrentLineEmpty()&&0==n&&!i)throw new e("Indentation problem A",this.getRealCurrentLineNb()+1,this.currentLine)}else n=t;var s=[this.currentLine.substr(n)],o=this.isStringUnIndentedCollectionItem(this.currentLine);while(this.moveToNextLine()){if(o&&!this.isStringUnIndentedCollectionItem(this.currentLine)){this.moveToPreviousLine();break}if(this.isCurrentLineEmpty()){this.isCurrentLineBlank()&&s.push(this.currentLine.substr(n));continue}r=this.getCurrentLineIndentation();var u;if(u=/^( *)$/.exec(this.currentLine))s.push(u[1]);else{if(!(r>=n)){if(0==r){this.moveToPreviousLine();break}throw new e("Indentation problem B",this.getRealCurrentLineNb()+1,this.currentLine)}s.push(this.currentLine.substr(n))}}return s.join("\n")},moveToNextLine:function(){return this.currentLineNb>=this.lines.length-1?!1:(this.currentLineNb++,this.currentLine=this.lines[this.currentLineNb],!0)},moveToPreviousLine:function(){this.currentLineNb--,this.currentLine=this.lines[this.currentLineNb]},parseValue:function(t){if("*"==(t+"").charAt(0)){this.trim(t).charAt(0)=="#"?t=(t+"").substr(1,t.indexOf("#")-2):t=(t+"").substr(1);if(this.refs[t]==undefined)throw new e('Reference "'+t+'" does not exist',this.getRealCurrentLineNb()+1,this.currentLine);return this.refs[t]}var n=null;if(n=/^(\||>)(\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?( +#.*)?$/.exec(t)){n={separator:n[1],modifiers:n[2],comments:n[3]};var r=this.isDefined(n.modifiers)?n.modifiers:"";return this.parseFoldedScalar(n.separator,r.replace(/\d+/g,""),Math.abs(parseInt(r)))}try{return(new i).parse(t)}catch(s){throw s instanceof e&&(s.setParsedLine(this.getRealCurrentLineNb()+1),s.setSnippet(this.currentLine)),s}},parseFoldedScalar:function(e,t,n){t==undefined&&(t=""),n==undefined&&(n=0),e="|"==e?"\n":" ";var r="",i=null,s=this.moveToNextLine();while(s&&this.isCurrentLineBlank())r+="\n",s=this.moveToNextLine();if(!s)return"";var o=null;if(!(o=(new RegExp("^("+(n?this.strRepeat(" ",n):" +")+")(.*)$")).exec(this.currentLine)))return this.moveToPreviousLine(),"";o={indent:o[1],text:o[2]};var u=o.indent,a=0;r+=o.text+e;while(this.currentLineNb+1<this.lines.length){this.moveToNextLine();if(o=(new RegExp("^( {"+u.length+",})(.+)$")).exec(this.currentLine))o={indent:o[1],text:o[2]}," "==e&&a!=o.indent&&(r=r.substr(0,r.length-1)+"\n"),a=o.indent,i=o.indent.length-u.length,r+=this.strRepeat(" ",i)+o.text+(i!=0?"\n":e);else{if(!(o=/^( *)$/.exec(this.currentLine))){this.moveToPreviousLine();break}r+=o[1].replace(new RegExp("^ {1,"+u.length+"}","g"),"")+"\n"}}" "==e&&(r=r.replace(/ (\n*)$/g,"\n$1"));switch(t){case"":r=r.replace(/\n+$/g,"\n");break;case"+":break;case"-":r=r.replace(/\n+$/g,"")}return r},isNextLineIndented:function(){var e=this.getCurrentLineIndentation(),t=this.moveToNextLine();while(t&&this.isCurrentLineEmpty())t=this.moveToNextLine();if(0==t)return!1;var n=!1;return this.getCurrentLineIndentation()<=e&&(n=!0),this.moveToPreviousLine(),n},isCurrentLineEmpty:function(){return this.isCurrentLineBlank()||this.isCurrentLineComment()},isCurrentLineBlank:function(){return""==this.trim(this.currentLine)},isCurrentLineComment:function(){var e=this.currentLine.replace(/^ +/g,"");return e.charAt(0)=="#"},cleanup:function(e){e=e.split("\r\n").join("\n").split("\r").join("\n"),/\n$/.test(e)||(e+="\n");var t=0,n=/^\%YAML[: ][\d\.]+.*\n/;while(n.test(e))e=e.replace(n,""),t++;this.offset+=t,n=/^(#.*?\n)+/;if(n.test(e)){var r=e.replace(n,"");this.offset+=this.subStrCount(e,"\n")-this.subStrCount(r,"\n"),e=r}return n=/^\-\-\-.*?\n/,n.test(e)&&(r=e.replace(n,""),this.offset+=this.subStrCount(e,"\n")-this.subStrCount(r,"\n"),e=r,e=e.replace(/\.\.\.\s*$/g,"")),e},isNextLineUnIndentedCollection:function(){var e=this.getCurrentLineIndentation(),t=this.moveToNextLine();while(t&&this.isCurrentLineEmpty())t=this.moveToNextLine();if(!1===t)return!1;var n=!1;return this.getCurrentLineIndentation()==e&&this.isStringUnIndentedCollectionItem(this.currentLine)&&(n=!0),this.moveToPreviousLine(),n},isStringUnIndentedCollectionItem:function(e){return 0===this.currentLine.indexOf("- ")},isObject:function(e){return typeof e=="object"&&this.isDefined(e)},isEmpty:function(e){return e==undefined||e==null||e==""||e==0||e=="0"||e==0},isDefined:function(e){return e!=undefined&&e!=null},reverseArray:function(e){var t=[],n=e.length;for(var r=n-1;r>=0;r--)t.push(e[r]);return t},merge:function(e,t){var n={},r;for(r in e)e.hasOwnProperty(r)&&(/^\d+$/.test(r)?n.push(e):n[r]=e[r]);for(r in t)t.hasOwnProperty(r)&&(/^\d+$/.test(r)?n.push(t):n[r]=t[r]);return n},strRepeat:function(e,t){var n,r="";for(n=0;n<t;n++)r+=e;return r},subStrCount:function(e,t,n,r){var i=0;e=""+e,t=""+t,n!=undefined&&(e=e.substr(n)),r!=undefined&&(e=e.substr(0,r));var s=e.length,o=t.length;for(var u=0;u<s;u++)t==e.substr(u,o)&&i++,u+=o-1;return i},trim:function(e){return(e+"").replace(/^ +/,"").replace(/ +$/,"")}},YamlEscaper=function(){},YamlEscaper.prototype={requiresDoubleQuoting:function(e){return(new RegExp(YamlEscaper.REGEX_CHARACTER_TO_ESCAPE)).test(e)},escapeWithDoubleQuotes:function(e){e+="";var t=YamlEscaper.escapees.length,n=YamlEscaper.escaped.length,r=YamlEscaper.escaped;for(var i=0;i<t;++i)i>=n&&r.push("");var s="";return s=e.replace(new RegExp(YamlEscaper.escapees.join("|"),"g"),function(e){for(var n=0;n<t;++n)if(e==YamlEscaper.escapees[n])return r[n]}),'"'+s+'"'},requiresSingleQuoting:function(e){return/[\s'":{}[\],&*#?]|^[-?|<>=!%@`]/.test(e)},escapeWithSingleQuotes:function(e){return"'"+e.replace(/'/g,"''")+"'"}},YamlEscaper.REGEX_CHARACTER_TO_ESCAPE="[\\x00-\\x1f]| | |â¨|â©",YamlEscaper.escapees=["\\\\",'\\"','"',"\0","","","","","","","","\b"," ","\n","","\f","\r","","","","","","","","","","","","","","","","","",""," "," ","â¨","â©"],YamlEscaper.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"];var o=function(){};o.prototype={unescapeSingleQuotedString:function(e){return e.replace(/''/g,"'")},unescapeDoubleQuotedString:function(e){var t=function(e){return(new o).unescapeCharacter(e)};return e.replace(new RegExp(o.REGEX_ESCAPED_CHARACTER,"g"),t)},unescapeCharacter:function(e){switch(e.charAt(1)){case"0":return String.fromCharCode(0);case"a":return String.fromCharCode(7);case"b":return String.fromCharCode(8);case"t":return" ";case" ":return" ";case"n":return"\n";case"v":return String.fromCharCode(11);case"f":return String.fromCharCode(12);case"r":return String.fromCharCode(13);case"e":return"";case" ":return" ";case'"':return'"';case"/":return"/";case"\\":return"\\";case"N":return"\0 ";case"_":return"\0 ";case"L":return" (";case"P":return" )";case"x":return this.pack("n",(new i).hexdec(e.substr(2,2)));case"u":return this.pack("n",(new i).hexdec(e.substr(2,4)));case"U":return this.pack("N",(new i).hexdec(e.substr(2,8)))}},pack:function(e){var t=0,n=1,r="",i="",s=0,o=[],u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A;while(t<e.length){u=e.charAt(t),a="",t++;while(t<e.length&&e.charAt(t).match(/[\d\*]/)!==null)a+=e.charAt(t),t++;a===""&&(a="1");switch(u){case"n":a==="*"&&(a=arguments.length-n);if(a>arguments.length-n)throw new Error("Warning: pack() Type "+u+": too few arguments");for(s=0;s<a;s++)r+=String.fromCharCode(arguments[n]>>8&255),r+=String.fromCharCode(arguments[n]&255),n++;break;case"N":a==="*"&&(a=arguments.length-n);if(a>arguments.length-n)throw new Error("Warning: pack() Type "+u+": too few arguments");for(s=0;s<a;s++)r+=String.fromCharCode(arguments[n]>>24&255),r+=String.fromCharCode(arguments[n]>>16&255),r+=String.fromCharCode(arguments[n]>>8&255),r+=String.fromCharCode(arguments[n]&255),n++;break;default:throw new Error("Warning: pack() Type "+u+": unknown format code")}}if(n<arguments.length)throw new Error("Warning: pack(): "+(arguments.length-n)+" arguments unused");return r}},o.REGEX_ESCAPED_CHARACTER='\\\\([0abt nvfre "\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})';var u=function(){};u.prototype={dump:function(e,t,n){t==null&&(t=0),n==null&&(n=0);var r="",s=n?this.strRepeat(" ",n):"",o;this.numSpacesForIndentation||(this.numSpacesForIndentation=2);if(t<=0||!this.isObject(e)||this.isEmpty(e))o=new i,r+=s+o.dump(e);else{var u=!this.arrayEquals(this.getKeys(e),this.range(0,e.length-1)),a;for(var f in e)e.hasOwnProperty(f)&&(a=t-1<=0||!this.isObject(e[f])||this.isEmpty(e[f]),u&&(o=new i),r+=s+""+(u?o.dump(f)+":":"-")+""+(a?" ":"\n")+""+this.dump(e[f],t-1,a?0:n+this.numSpacesForIndentation)+""+(a?"\n":""))}return r},strRepeat:function(e,t){var n,r="";for(n=0;n<t;n++)r+=e;return r},isObject:function(e){return this.isDefined(e)&&typeof e=="object"},isEmpty:function(e){var t=e==undefined||e==null||e==""||e==0||e=="0"||e==0;if(!t&&typeof e=="object"&&!(e instanceof Array)){var n=0;for(var r in e)e.hasOwnProperty(r)&&n++;t=!n}return t},isDefined:function(e){return e!=undefined&&e!=null},getKeys:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},range:function(e,t){if(e>t)return[];var n=[];for(var r=e;r<=t;r++)n.push(r);return n},arrayEquals:function(e,t){if(e.length!=t.length)return!1;var n=e.length;for(var r=0;r<n;r++)if(e[r]!=t[r])return!1;return!0}}})(); | ||
(function(){var e=function(e,t,n,r){this.rawMessage=e,this.parsedLine=t!==undefined?t:-1,this.snippet=n!==undefined?n:null,this.parsedFile=r!==undefined?r:null,this.updateRepr(),this.message=e};e.prototype={name:"YamlParseException",message:null,parsedFile:null,parsedLine:-1,snippet:null,rawMessage:null,isDefined:function(e){return e!=undefined&&e!=null},getSnippet:function(){return this.snippet},setSnippet:function(e){this.snippet=e,this.updateRepr()},getParsedFile:function(){return this.parsedFile},setParsedFile:function(e){this.parsedFile=e,this.updateRepr()},getParsedLine:function(){return this.parsedLine},setParsedLine:function(e){this.parsedLine=e,this.updateRepr()},updateRepr:function(){this.message=this.rawMessage;var e=!1;"."===this.message.charAt(this.message.length-1)&&(this.message=this.message.substring(0,this.message.length-1),e=!0),null!==this.parsedFile&&(this.message+=" in "+JSON.stringify(this.parsedFile)),this.parsedLine>=0&&(this.message+=" at line "+this.parsedLine),this.snippet&&(this.message+=' (near "'+this.snippet+'")'),e&&(this.message+=".")}};var t=!1,n=function(){};n.prototype={parseFile:function(t,r){if(r==null){var i=this.getFileContents(t),s=null;try{s=this.parse(i)}catch(o){throw o instanceof e&&o.setParsedFile(t),o}return s}this.getFileContents(t,function(e){r((new n).parse(e))})},parse:function(e){var t=new s;return t.parse(e)},dump:function(e,t,n){t==null&&(t=2);var r=new u;return n&&(r.numSpacesForIndentation=n),r.dump(e,t)},getXHR:function(){if(window.XMLHttpRequest)return new XMLHttpRequest;if(window.ActiveXObject){var e=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(var t=0;t<4;t++)try{return new ActiveXObject(e[t])}catch(n){}}return null},getFileContents:function(e,n){if(t){var r=require("fs");if(n==null){var i=r.readFileSync(e);return i==null?null:""+i}r.readFile(e,function(e,t){e?n(null):n(t)})}else{var s=this.getXHR();if(n==null)return s.open("GET",e,!1),s.send(null),s.status==200||s.status==0?s.responseText:null;s.onreadystatechange=function(){s.readyState==4&&(s.status==200||s.status==0?n(s.responseText):n(null))},s.open("GET",e,!0),s.send(null)}}};var r={stringify:function(e,t,r){return(new n).dump(e,t,r)},parse:function(e){return(new n).parse(e)},load:function(e,t){return(new n).parseFile(e,t)}};typeof exports!="undefined"&&typeof module!="undefined"&&module.exports&&(exports=module.exports=r,t=!0,function(){var e=function(e,t){e.exports=r.load(t)};undefined!==require.extensions&&(require.extensions[".yml"]=e,require.extensions[".yaml"]=e)}()),typeof window!="undefined"&&(window.YAML=r);var i=function(){};i.prototype={i:null,parse:function(t){var n=null;t=this.trim(t);if(0==t.length)return"";switch(t.charAt(0)){case"[":n=this.parseSequence(t);break;case"{":n=this.parseMapping(t);break;default:n=this.parseScalar(t)}if(t.substr(this.i+1).replace(/^\s*#.*$/,"")!="")throw console.log("oups "+t.substr(this.i+1)),new e('Unexpected characters near "'+t.substr(this.i)+'".');return n},dump:function(e){if(undefined==e||null==e)return"null";if(e instanceof Date)return e.toISOString();if(typeof e=="object")return this.dumpObject(e);if(typeof e=="boolean")return e?"true":"false";if(/^\d+$/.test(e))return typeof e=="string"?"'"+e+"'":parseInt(e);if(this.isNumeric(e))return typeof e=="string"?"'"+e+"'":parseFloat(e);if(typeof e=="number")return e==Infinity?".Inf":e==-Infinity?"-.Inf":isNaN(e)?".NAN":e;var t=new YamlEscaper;return t.requiresDoubleQuoting(e)?t.escapeWithDoubleQuotes(e):t.requiresSingleQuoting(e)?t.escapeWithSingleQuotes(e):""==e?"":this.getTimestampRegex().test(e)?"'"+e+"'":this.inArray(e.toLowerCase(),["null","~","true","false"])?"'"+e+"'":e},dumpObject:function(e){var t=this.getKeys(e),n=null,r,i=t.length;if(e instanceof Array){n=[];for(r=0;r<i;r++)n.push(this.dump(e[t[r]]));return"["+n.join(", ")+"]"}n=[];for(r=0;r<i;r++)n.push(this.dump(t[r])+": "+this.dump(e[t[r]]));return"{ "+n.join(", ")+" }"},parseScalar:function(t,n,r,i,s){n==undefined&&(n=null),r==undefined&&(r=['"',"'"]),i==undefined&&(i=0),s==undefined&&(s=!0);var o=null,u=null,a=null;if(this.inArray(t[i],r)){o=this.parseQuotedScalar(t,i),i=this.i;if(null!==n){var f=t.substr(i).replace(/^\s+/,"");if(!this.inArray(f.charAt(0),n))throw new e("Unexpected characters ("+t.substr(i)+").")}}else{if(!n)o=(t+"").substring(i),i+=o.length,u=o.indexOf(" #"),u!=-1&&(o=o.substr(0,u).replace(/\s+$/g,""));else{if(!(a=(new RegExp("^(.+?)("+n.join("|")+")")).exec((t+"").substring(i))))throw new e("Malformed inline YAML string ("+t+").");o=a[1],i+=o.length}o=s?this.evaluateScalar(o):o}return this.i=i,o},parseQuotedScalar:function(t,n){var r=null;if(!(r=(new RegExp("^"+i.REGEX_QUOTED_STRING)).exec((t+"").substring(n))))throw new e("Malformed inline YAML string ("+(t+"").substring(n)+").");var s=r[0].substr(1,r[0].length-2),u=new o;return'"'==(t+"").charAt(n)?s=u.unescapeDoubleQuotedString(s):s=u.unescapeSingleQuotedString(s),n+=r[0].length,this.i=n,s},parseSequence:function(t,n){n==undefined&&(n=0);var r=[],i=t.length;n+=1;while(n<i){switch(t.charAt(n)){case"[":r.push(this.parseSequence(t,n)),n=this.i;break;case"{":r.push(this.parseMapping(t,n)),n=this.i;break;case"]":return this.i=n,r;case",":case" ":break;default:var s=this.inArray(t.charAt(n),['"',"'"]),o=this.parseScalar(t,[",","]"],['"',"'"],n);n=this.i;if(!s&&(o+"").indexOf(": ")!=-1)try{o=this.parseMapping("{"+o+"}")}catch(u){if(!(u instanceof e))throw u}r.push(o),n--}n++}throw new e('Malformed inline YAML string "'+t+'"')},parseMapping:function(t,n){n==undefined&&(n=0);var r={},i=t.length;n+=1;var s=!1,o=!1;while(n<i){o=!1;switch(t.charAt(n)){case" ":case",":n++,o=!0;break;case"}":return this.i=n,r}if(o)continue;var u=this.parseScalar(t,[":"," "],['"',"'"],n,!1);n=this.i,s=!1;while(n<i){switch(t.charAt(n)){case"[":r[u]=this.parseSequence(t,n),n=this.i,s=!0;break;case"{":r[u]=this.parseMapping(t,n),n=this.i,s=!0;break;case":":case" ":break;default:r[u]=this.parseScalar(t,[",","}"],['"',"'"],n),n=this.i,s=!0,n--}++n;if(s){o=!0;break}}if(o)continue}throw new e('Malformed inline YAML string "'+t+'"')},evaluateScalar:function(e){e=this.trim(e);var t=null,n=null;return"null"==e.toLowerCase()||""==e||"~"==e?null:(e+"").indexOf("!str ")==0?(""+e).substring(5):(e+"").indexOf("! ")==0?parseInt(this.parseScalar((e+"").substr(2))):/^\d+$/.test(e)?(t=e,n=parseInt(e),"0"==e.charAt(0)?this.octdec(e):""+t==""+n?n:t):"true"==(e+"").toLowerCase()?!0:"false"==(e+"").toLowerCase()?!1:this.isNumeric(e)?"0x"==(e+"").substr(0,2)?this.hexdec(e):parseFloat(e):e.toLowerCase()==".inf"?Infinity:e.toLowerCase()==".nan"?NaN:e.toLowerCase()=="-.inf"?-Infinity:/^(-|\+)?[0-9,]+(\.[0-9]+)?$/.test(e)?parseFloat(e.split(",").join("")):this.getTimestampRegex().test(e)?new Date(this.strtotime(e)):""+e},getTimestampRegex:function(){return new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ ]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:.([0-9]*))?(?:[ ]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$","gi")},trim:function(e){return(e+"").replace(/^\s+/,"").replace(/\s+$/,"")},isNumeric:function(e){return e-0==e&&e.length>0&&e.replace(/\s+/g,"")!=""},inArray:function(e,t){var n,r=t.length;for(n=0;n<r;n++)if(e==t[n])return!0;return!1},getKeys:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},octdec:function(e){return parseInt((e+"").replace(/[^0-7]/gi,""),8)},hexdec:function(e){return e=this.trim(e),(e+"").substr(0,2)=="0x"&&(e=(e+"").substring(2)),parseInt((e+"").replace(/[^a-f0-9]/gi,""),16)},strtotime:function(e,t){var n,r,i,s,o="";e=(e+"").replace(/\s{2,}|^\s|\s$/g," ").replace(/[\t\r\n]/g,"");if(e==="now")return t===null||isNaN(t)?(new Date).getTime()||0:t||0;if(!isNaN(o=Date.parse(e)))return o||0;t?t=new Date(t):t=new Date,e=e.toLowerCase();var u={day:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},mon:["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]},a=function(e){var n=e[2]&&e[2]==="ago",r=(r=e[0]==="last"?-1:1)*(n?-1:1);switch(e[0]){case"last":case"next":switch(e[1].substring(0,3)){case"yea":t.setFullYear(t.getFullYear()+r);break;case"wee":t.setDate(t.getDate()+r*7);break;case"day":t.setDate(t.getDate()+r);break;case"hou":t.setHours(t.getHours()+r);break;case"min":t.setMinutes(t.getMinutes()+r);break;case"sec":t.setSeconds(t.getSeconds()+r);break;case"mon":if(e[1]==="month"){t.setMonth(t.getMonth()+r);break};default:var i=u.day[e[1].substring(0,3)];if(typeof i!="undefined"){var s=i-t.getDay();s===0?s=7*r:s>0?e[0]==="last"&&(s-=7):e[0]==="next"&&(s+=7),t.setDate(t.getDate()+s),t.setHours(0,0,0,0)}}break;default:if(!/\d+/.test(e[0]))return!1;r*=parseInt(e[0],10);switch(e[1].substring(0,3)){case"yea":t.setFullYear(t.getFullYear()+r);break;case"mon":t.setMonth(t.getMonth()+r);break;case"wee":t.setDate(t.getDate()+r*7);break;case"day":t.setDate(t.getDate()+r);break;case"hou":t.setHours(t.getHours()+r);break;case"min":t.setMinutes(t.getMinutes()+r);break;case"sec":t.setSeconds(t.getSeconds()+r)}}return!0};i=e.match(/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/);if(i!==null)return i[2]?i[3]||(i[2]+=":00"):i[2]="00:00:00",s=i[1].split(/-/g),s[1]=u.mon[s[1]-1]||s[1],s[0]=+s[0],s[0]=s[0]>=0&&s[0]<=69?"20"+(s[0]<10?"0"+s[0]:s[0]+""):s[0]>=70&&s[0]<=99?"19"+s[0]:s[0]+"",parseInt(this.strtotime(s[2]+" "+s[1]+" "+s[0]+" "+i[2])+(i[4]?i[4]:""),10);var f="([+-]?\\d+\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday)|(last|next)\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday))(\\sago)?";i=e.match(new RegExp(f,"gi"));if(i===null)return!1;for(n=0,r=i.length;n<r;n++)if(!a(i[n].split(" ")))return!1;return t.getTime()||0}},i.REGEX_QUOTED_STRING="(?:\"(?:[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"|'(?:[^']*(?:''[^']*)*)')";var s=function(e){this.offset=e!==undefined?e:0};s.prototype={offset:0,lines:[],currentLineNb:-1,currentLine:"",refs:{},parse:function(t){this.currentLineNb=-1,this.currentLine="",this.lines=this.cleanup(t).split("\n");var n=null,r=null;while(this.moveToNextLine()){if(this.isCurrentLineEmpty())continue;if(this.currentLine.charAt(0)==" ")throw new e("A YAML file cannot contain tabs as indentation.",this.getRealCurrentLineNb()+1,this.currentLine);var o=!1,u=!1,a=!1,f=null,l=null,c=null,h=null,p=null,d=null,v=null,m=null,g=null;if(f=/^\-((\s+)(.+?))?\s*$/.exec(this.currentLine)){if(r&&"mapping"==r)throw new e("You cannot define a sequence item when in a mapping",this.getRealCurrentLineNb()+1,this.currentLine);r="sequence",this.isDefined(n)||(n=[]),f={leadspaces:f[2],value:f[3]},this.isDefined(f.value)&&(l=/^&([^ ]+) *(.*)/.exec(f.value))&&(l={ref:l[1],value:l[2]},o=l.ref,f.value=l.value),!this.isDefined(f.value)||""==this.trim(f.value)||f.value.replace(/^ +/,"").charAt(0)=="#"?(c=this.getRealCurrentLineNb()+1,h=new s(c),h.refs=this.refs,n.push(h.parse(this.getNextEmbedBlock())),this.refs=h.refs):this.isDefined(f.leadspaces)&&" "==f.leadspaces&&(l=(new RegExp("^("+i.REGEX_QUOTED_STRING+"|[^ '\"{[].*?) *:(\\s+(.+?))?\\s*$")).exec(f.value))?(l={key:l[1],value:l[3]},c=this.getRealCurrentLineNb(),h=new s(c),h.refs=this.refs,p=f.value,this.isNextLineIndented()||(p+="\n"+this.getNextEmbedBlock(this.getCurrentLineIndentation()+2)),n.push(h.parse(p)),this.refs=h.refs):n.push(this.parseValue(f.value))}else{if(!(f=(new RegExp("^("+i.REGEX_QUOTED_STRING+"|[^ '\"[{].*?) *:(\\s+(.+?))?\\s*$")).exec(this.currentLine))){if(2==this.lines.length&&this.isEmpty(this.lines[1])){try{t=(new i).parse(this.lines[0])}catch(y){throw y instanceof e&&(y.setParsedLine(this.getRealCurrentLineNb()+1),y.setSnippet(this.currentLine)),y}if(this.isObject(t)){var S=t[0];if(typeof t=="string"&&"*"==S.charAt(0)){n=[],m=t.length;for(var w=0;w<m;w++)n.push(this.refs[t[w].substr(1)]);t=n}}return t}throw new e("Unable to parse.",this.getRealCurrentLineNb()+1,this.currentLine)}this.isDefined(n)||(n={});if(r&&"sequence"==r)throw new e("You cannot define a mapping item when in a sequence",this.getRealCurrentLineNb()+1,this.currentLine);r="mapping",f={key:f[1],value:f[3]};try{d=(new i).parseScalar(f.key)}catch(y){throw y instanceof e&&(y.setParsedLine(this.getRealCurrentLineNb()+1),y.setSnippet(this.currentLine)),y}if("<<"==d)if(this.isDefined(f.value)&&"*"==(f.value+"").charAt(0)){u=f.value.substr(1);if(this.refs[u]==undefined)throw new e('Reference "'+t+'" does not exist',this.getRealCurrentLineNb()+1,this.currentLine)}else{this.isDefined(f.value)&&f.value!=""?t=f.value:t=this.getNextEmbedBlock(),c=this.getRealCurrentLineNb()+1,h=new s(c),h.refs=this.refs,v=h.parse(t),this.refs=h.refs;var b=[];if(!this.isObject(v))throw new e("YAML merge keys used with a scalar value instead of an array",this.getRealCurrentLineNb()+1,this.currentLine);if(this.isDefined(v[0])){g=this.reverseArray(v),m=g.length;for(var w=0;w<m;w++){var E=g[w];if(!this.isObject(g[w]))throw new e("Merge items must be arrays",this.getRealCurrentLineNb()+1,this.currentLine);b=this.mergeObject(g[w],b)}}else b=this.mergeObject(b,v);a=b}else this.isDefined(f.value)&&(l=/^&([^ ]+) *(.*)/.exec(f.value))&&(l={ref:l[1],value:l[2]},o=l.ref,f.value=l.value);a?n=a:!this.isDefined(f.value)||""==this.trim(f.value)||this.trim(f.value).charAt(0)=="#"?this.isNextLineIndented()&&!this.isNextLineUnIndentedCollection()?n[d]=null:(c=this.getRealCurrentLineNb()+1,h=new s(c),h.refs=this.refs,n[d]=h.parse(this.getNextEmbedBlock()),this.refs=h.refs):u?n=this.refs[u]:n[d]=this.parseValue(f.value)}if(o)if(n instanceof Array)this.refs[o]=n[n.length-1];else{var x=null;for(var T in n)n.hasOwnProperty(T)&&(x=T);this.refs[o]=n[T]}}return this.isEmpty(n)?null:n},getRealCurrentLineNb:function(){return this.currentLineNb+this.offset},getCurrentLineIndentation:function(){return this.currentLine.length-this.currentLine.replace(/^ +/g,"").length},getNextEmbedBlock:function(t){this.moveToNextLine();var n=null,r=null;if(!this.isDefined(t)){n=this.getCurrentLineIndentation();var i=this.isStringUnIndentedCollectionItem(this.currentLine);if(!this.isCurrentLineEmpty()&&0==n&&!i)throw new e("Indentation problem A",this.getRealCurrentLineNb()+1,this.currentLine)}else n=t;var s=[this.currentLine.substr(n)],o=this.isStringUnIndentedCollectionItem(this.currentLine);while(this.moveToNextLine()){if(o&&!this.isStringUnIndentedCollectionItem(this.currentLine)){this.moveToPreviousLine();break}if(this.isCurrentLineEmpty()){this.isCurrentLineBlank()&&s.push(this.currentLine.substr(n));continue}r=this.getCurrentLineIndentation();var u;if(u=/^( *)$/.exec(this.currentLine))s.push(u[1]);else{if(!(r>=n)){if(0==r){this.moveToPreviousLine();break}throw new e("Indentation problem B",this.getRealCurrentLineNb()+1,this.currentLine)}s.push(this.currentLine.substr(n))}}return s.join("\n")},moveToNextLine:function(){return this.currentLineNb>=this.lines.length-1?!1:(this.currentLineNb++,this.currentLine=this.lines[this.currentLineNb],!0)},moveToPreviousLine:function(){this.currentLineNb--,this.currentLine=this.lines[this.currentLineNb]},parseValue:function(t){if("*"==(t+"").charAt(0)){this.trim(t).charAt(0)=="#"?t=(t+"").substr(1,t.indexOf("#")-2):t=(t+"").substr(1);if(this.refs[t]==undefined)throw new e('Reference "'+t+'" does not exist',this.getRealCurrentLineNb()+1,this.currentLine);return this.refs[t]}var n=null;if(n=/^(\||>)(\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?( +#.*)?$/.exec(t)){n={separator:n[1],modifiers:n[2],comments:n[3]};var r=this.isDefined(n.modifiers)?n.modifiers:"";return this.parseFoldedScalar(n.separator,r.replace(/\d+/g,""),Math.abs(parseInt(r)))}try{return(new i).parse(t)}catch(s){throw s instanceof e&&(s.setParsedLine(this.getRealCurrentLineNb()+1),s.setSnippet(this.currentLine)),s}},parseFoldedScalar:function(e,t,n){t==undefined&&(t=""),n==undefined&&(n=0),e="|"==e?"\n":" ";var r="",i=null,s=this.moveToNextLine();while(s&&this.isCurrentLineBlank())r+="\n",s=this.moveToNextLine();if(!s)return"";var o=null;if(!(o=(new RegExp("^("+(n?this.strRepeat(" ",n):" +")+")(.*)$")).exec(this.currentLine)))return this.moveToPreviousLine(),"";o={indent:o[1],text:o[2]};var u=o.indent,a=0;r+=o.text+e;while(this.currentLineNb+1<this.lines.length){this.moveToNextLine();if(o=(new RegExp("^( {"+u.length+",})(.+)$")).exec(this.currentLine))o={indent:o[1],text:o[2]}," "==e&&a!=o.indent&&(r=r.substr(0,r.length-1)+"\n"),a=o.indent,i=o.indent.length-u.length,r+=this.strRepeat(" ",i)+o.text+(i!=0?"\n":e);else{if(!(o=/^( *)$/.exec(this.currentLine))){this.moveToPreviousLine();break}r+=o[1].replace(new RegExp("^ {1,"+u.length+"}","g"),"")+"\n"}}" "==e&&(r=r.replace(/ (\n*)$/g,"\n$1"));switch(t){case"":r=r.replace(/\n+$/g,"\n");break;case"+":break;case"-":r=r.replace(/\n+$/g,"")}return r},isNextLineIndented:function(){var e=this.getCurrentLineIndentation(),t=this.moveToNextLine();while(t&&this.isCurrentLineEmpty())t=this.moveToNextLine();if(0==t)return!1;var n=!1;return this.getCurrentLineIndentation()<=e&&(n=!0),this.moveToPreviousLine(),n},isCurrentLineEmpty:function(){return this.isCurrentLineBlank()||this.isCurrentLineComment()},isCurrentLineBlank:function(){return""==this.trim(this.currentLine)},isCurrentLineComment:function(){var e=this.currentLine.replace(/^ +/g,"");return e.charAt(0)=="#"},cleanup:function(e){e=e.split("\r\n").join("\n").split("\r").join("\n"),/\n$/.test(e)||(e+="\n");var t=0,n=/^\%YAML[: ][\d\.]+.*\n/;while(n.test(e))e=e.replace(n,""),t++;this.offset+=t,n=/^(#.*?\n)+/;if(n.test(e)){var r=e.replace(n,"");this.offset+=this.subStrCount(e,"\n")-this.subStrCount(r,"\n"),e=r}return n=/^\-\-\-.*?\n/,n.test(e)&&(r=e.replace(n,""),this.offset+=this.subStrCount(e,"\n")-this.subStrCount(r,"\n"),e=r,e=e.replace(/\.\.\.\s*$/g,"")),e},isNextLineUnIndentedCollection:function(){var e=this.getCurrentLineIndentation(),t=this.moveToNextLine();while(t&&this.isCurrentLineEmpty())t=this.moveToNextLine();if(!1===t)return!1;var n=!1;return this.getCurrentLineIndentation()==e&&this.isStringUnIndentedCollectionItem(this.currentLine)&&(n=!0),this.moveToPreviousLine(),n},isStringUnIndentedCollectionItem:function(e){return 0===this.currentLine.indexOf("- ")},isObject:function(e){return typeof e=="object"&&this.isDefined(e)},isEmpty:function(e){return e==undefined||e==null||e==""||e==0||e=="0"||e==0},isDefined:function(e){return e!=undefined&&e!=null},reverseArray:function(e){var t=[],n=e.length;for(var r=n-1;r>=0;r--)t.push(e[r]);return t},merge:function(e,t){var n={},r;for(r in e)e.hasOwnProperty(r)&&(/^\d+$/.test(r)?n.push(e):n[r]=e[r]);for(r in t)t.hasOwnProperty(r)&&(/^\d+$/.test(r)?n.push(t):n[r]=t[r]);return n},strRepeat:function(e,t){var n,r="";for(n=0;n<t;n++)r+=e;return r},subStrCount:function(e,t,n,r){var i=0;e=""+e,t=""+t,n!=undefined&&(e=e.substr(n)),r!=undefined&&(e=e.substr(0,r));var s=e.length,o=t.length;for(var u=0;u<s;u++)t==e.substr(u,o)&&i++,u+=o-1;return i},trim:function(e){return(e+"").replace(/^ +/,"").replace(/ +$/,"")}},YamlEscaper=function(){},YamlEscaper.prototype={requiresDoubleQuoting:function(e){return(new RegExp(YamlEscaper.REGEX_CHARACTER_TO_ESCAPE)).test(e)},escapeWithDoubleQuotes:function(e){e+="";var t=YamlEscaper.escapees.length,n=YamlEscaper.escaped.length,r=YamlEscaper.escaped;for(var i=0;i<t;++i)i>=n&&r.push("");var s="";return s=e.replace(new RegExp(YamlEscaper.escapees.join("|"),"g"),function(e){for(var n=0;n<t;++n)if(e==YamlEscaper.escapees[n])return r[n]}),'"'+s+'"'},requiresSingleQuoting:function(e){return/[\s'":{}[\],&*#?]|^[-?|<>=!%@`]/.test(e)},escapeWithSingleQuotes:function(e){return"'"+e.replace(/'/g,"''")+"'"}},YamlEscaper.REGEX_CHARACTER_TO_ESCAPE="[\\x00-\\x1f]| | |â¨|â©",YamlEscaper.escapees=["\\\\",'\\"','"',"\0","","","","","","","","\b"," ","\n","","\f","\r","","","","","","","","","","","","","","","","","",""," "," ","â¨","â©"],YamlEscaper.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"];var o=function(){};o.prototype={unescapeSingleQuotedString:function(e){return e.replace(/''/g,"'")},unescapeDoubleQuotedString:function(e){var t=function(e){return(new o).unescapeCharacter(e)};return e.replace(new RegExp(o.REGEX_ESCAPED_CHARACTER,"g"),t)},unescapeCharacter:function(e){switch(e.charAt(1)){case"0":return String.fromCharCode(0);case"a":return String.fromCharCode(7);case"b":return String.fromCharCode(8);case"t":return" ";case" ":return" ";case"n":return"\n";case"v":return String.fromCharCode(11);case"f":return String.fromCharCode(12);case"r":return String.fromCharCode(13);case"e":return"";case" ":return" ";case'"':return'"';case"/":return"/";case"\\":return"\\";case"N":return"\0 ";case"_":return"\0 ";case"L":return" (";case"P":return" )";case"x":return this.pack("n",(new i).hexdec(e.substr(2,2)));case"u":return this.pack("n",(new i).hexdec(e.substr(2,4)));case"U":return this.pack("N",(new i).hexdec(e.substr(2,8)))}},pack:function(e){var t=0,n=1,r="",i="",s=0,o=[],u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A;while(t<e.length){u=e.charAt(t),a="",t++;while(t<e.length&&e.charAt(t).match(/[\d\*]/)!==null)a+=e.charAt(t),t++;a===""&&(a="1");switch(u){case"n":a==="*"&&(a=arguments.length-n);if(a>arguments.length-n)throw new Error("Warning: pack() Type "+u+": too few arguments");for(s=0;s<a;s++)r+=String.fromCharCode(arguments[n]>>8&255),r+=String.fromCharCode(arguments[n]&255),n++;break;case"N":a==="*"&&(a=arguments.length-n);if(a>arguments.length-n)throw new Error("Warning: pack() Type "+u+": too few arguments");for(s=0;s<a;s++)r+=String.fromCharCode(arguments[n]>>24&255),r+=String.fromCharCode(arguments[n]>>16&255),r+=String.fromCharCode(arguments[n]>>8&255),r+=String.fromCharCode(arguments[n]&255),n++;break;default:throw new Error("Warning: pack() Type "+u+": unknown format code")}}if(n<arguments.length)throw new Error("Warning: pack(): "+(arguments.length-n)+" arguments unused");return r}},o.REGEX_ESCAPED_CHARACTER='\\\\([0abt nvfre "\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})';var u=function(){};u.prototype={dump:function(e,t,n){t==null&&(t=0),n==null&&(n=0);var r="",s=n?this.strRepeat(" ",n):"",o;this.numSpacesForIndentation||(this.numSpacesForIndentation=2);if(t<=0||!this.isObject(e)||this.isEmpty(e))o=new i,r+=s+o.dump(e);else{var u=!this.arrayEquals(this.getKeys(e),this.range(0,e.length-1)),a;for(var f in e)e.hasOwnProperty(f)&&(a=t-1<=0||!this.isObject(e[f])||this.isEmpty(e[f]),u&&(o=new i),r+=s+""+(u?o.dump(f)+":":"-")+""+(a?" ":"\n")+""+this.dump(e[f],t-1,a?0:n+this.numSpacesForIndentation)+""+(a?"\n":""))}return r},strRepeat:function(e,t){var n,r="";for(n=0;n<t;n++)r+=e;return r},isObject:function(e){return this.isDefined(e)&&typeof e=="object"},isEmpty:function(e){var t=e==undefined||e==null||e==""||e==0||e=="0"||e==0;if(!t&&typeof e=="object"&&!(e instanceof Array)){var n=0;for(var r in e)e.hasOwnProperty(r)&&n++;t=!n}return t},isDefined:function(e){return e!=undefined&&e!=null},getKeys:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},range:function(e,t){if(e>t)return[];var n=[];for(var r=e;r<=t;r++)n.push(r);return n},arrayEquals:function(e,t){if(e.length!=t.length)return!1;var n=e.length;for(var r=0;r<n;r++)if(e[r]!=t[r])return!1;return!0}}})(); |
{ | ||
"name": "yamljs", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -40,3 +40,4 @@ | ||
// some comment can end the scalar | ||
if ( value.substr(this.i+1).replace(/^\s+#.*$/, '') != '' ) { | ||
if ( value.substr(this.i+1).replace(/^\s*#.*$/, '') != '' ) { | ||
console.log("oups "+value.substr(this.i+1)); | ||
throw new YamlParseException('Unexpected characters near "'+value.substr(this.i)+'".'); | ||
@@ -273,3 +274,3 @@ } | ||
default: | ||
isQuoted = this.inArray(sequence.charAt(i), ['"', "'"]); | ||
var isQuoted = this.inArray(sequence.charAt(i), ['"', "'"]); | ||
var value = this.parseScalar(sequence, [',', ']'], ['"', "'"], i); | ||
@@ -276,0 +277,0 @@ i = this.i; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
264739
27
7425
0
1