Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import yaml from '../index.js' | ||
| const { | ||
| Type, | ||
| Schema, | ||
| FAILSAFE_SCHEMA, | ||
| JSON_SCHEMA, | ||
| CORE_SCHEMA, | ||
| DEFAULT_SCHEMA, | ||
| load, | ||
| loadAll, | ||
| dump, | ||
| YAMLException, | ||
| types, | ||
| safeLoad, | ||
| safeLoadAll, | ||
| safeDump | ||
| } = yaml | ||
| export { | ||
| Type, | ||
| Schema, | ||
| FAILSAFE_SCHEMA, | ||
| JSON_SCHEMA, | ||
| CORE_SCHEMA, | ||
| DEFAULT_SCHEMA, | ||
| load, | ||
| loadAll, | ||
| dump, | ||
| YAMLException, | ||
| types, | ||
| safeLoad, | ||
| safeLoadAll, | ||
| safeDump | ||
| } | ||
| export default yaml |
+53
-62
| #!/usr/bin/env node | ||
| 'use strict' | ||
| 'use strict'; | ||
| const fs = require('fs') | ||
| const argparse = require('argparse') | ||
| const yaml = require('..') | ||
| /*eslint-disable no-console*/ | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| const cli = new argparse.ArgumentParser({ | ||
| prog: 'js-yaml', | ||
| add_help: true | ||
| }) | ||
| var fs = require('fs'); | ||
| var argparse = require('argparse'); | ||
| var yaml = require('..'); | ||
| //////////////////////////////////////////////////////////////////////////////// | ||
| var cli = new argparse.ArgumentParser({ | ||
| prog: 'js-yaml', | ||
| add_help: true | ||
| }); | ||
| cli.add_argument('-v', '--version', { | ||
| action: 'version', | ||
| version: require('../package.json').version | ||
| }); | ||
| }) | ||
| cli.add_argument('-c', '--compact', { | ||
| help: 'Display errors in compact mode', | ||
| help: 'Display errors in compact mode', | ||
| action: 'store_true' | ||
| }); | ||
| }) | ||
@@ -35,42 +29,39 @@ // deprecated (not needed after we removed output colors) | ||
| cli.add_argument('-j', '--to-json', { | ||
| help: argparse.SUPPRESS, | ||
| dest: 'json', | ||
| help: argparse.SUPPRESS, | ||
| dest: 'json', | ||
| action: 'store_true' | ||
| }); | ||
| }) | ||
| cli.add_argument('-t', '--trace', { | ||
| help: 'Show stack trace on error', | ||
| help: 'Show stack trace on error', | ||
| action: 'store_true' | ||
| }); | ||
| }) | ||
| cli.add_argument('file', { | ||
| help: 'File to read, utf-8 encoded without BOM', | ||
| nargs: '?', | ||
| help: 'File to read, utf-8 encoded without BOM', | ||
| nargs: '?', | ||
| default: '-' | ||
| }); | ||
| }) | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| //////////////////////////////////////////////////////////////////////////////// | ||
| const options = cli.parse_args() | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| var options = cli.parse_args(); | ||
| //////////////////////////////////////////////////////////////////////////////// | ||
| function readFile(filename, encoding, callback) { | ||
| function readFile (filename, encoding, callback) { | ||
| if (options.file === '-') { | ||
| // read from stdin | ||
| var chunks = []; | ||
| const chunks = [] | ||
| process.stdin.on('data', function (chunk) { | ||
| chunks.push(chunk); | ||
| }); | ||
| chunks.push(chunk) | ||
| }) | ||
| process.stdin.on('end', function () { | ||
| return callback(null, Buffer.concat(chunks).toString(encoding)); | ||
| }); | ||
| return callback(null, Buffer.concat(chunks).toString(encoding)) | ||
| }) | ||
| } else { | ||
| fs.readFile(filename, encoding, callback); | ||
| fs.readFile(filename, encoding, callback) | ||
| } | ||
@@ -80,49 +71,49 @@ } | ||
| readFile(options.file, 'utf8', function (error, input) { | ||
| var output, isYaml; | ||
| let output | ||
| let isYaml | ||
| if (error) { | ||
| if (error.code === 'ENOENT') { | ||
| console.error('File not found: ' + options.file); | ||
| process.exit(2); | ||
| console.error('File not found: ' + options.file) | ||
| process.exit(2) | ||
| } | ||
| console.error( | ||
| options.trace && error.stack || | ||
| (options.trace && error.stack) || | ||
| error.message || | ||
| String(error)); | ||
| String(error)) | ||
| process.exit(1); | ||
| process.exit(1) | ||
| } | ||
| try { | ||
| output = JSON.parse(input); | ||
| isYaml = false; | ||
| output = JSON.parse(input) | ||
| isYaml = false | ||
| } catch (err) { | ||
| if (err instanceof SyntaxError) { | ||
| try { | ||
| output = []; | ||
| yaml.loadAll(input, function (doc) { output.push(doc); }, {}); | ||
| isYaml = true; | ||
| output = [] | ||
| yaml.loadAll(input, function (doc) { output.push(doc) }, {}) | ||
| isYaml = true | ||
| if (output.length === 0) output = null; | ||
| else if (output.length === 1) output = output[0]; | ||
| if (output.length === 0) output = null | ||
| else if (output.length === 1) output = output[0] | ||
| } catch (e) { | ||
| if (options.trace && err.stack) console.error(e.stack); | ||
| else console.error(e.toString(options.compact)); | ||
| if (options.trace && err.stack) console.error(e.stack) | ||
| else console.error(e.toString(options.compact)) | ||
| process.exit(1); | ||
| process.exit(1) | ||
| } | ||
| } else { | ||
| console.error( | ||
| options.trace && err.stack || | ||
| (options.trace && err.stack) || | ||
| err.message || | ||
| String(err)); | ||
| String(err)) | ||
| process.exit(1); | ||
| process.exit(1) | ||
| } | ||
| } | ||
| if (isYaml) console.log(JSON.stringify(output, null, ' ')); | ||
| else console.log(yaml.dump(output)); | ||
| }); | ||
| if (isYaml) console.log(JSON.stringify(output, null, ' ')) | ||
| else console.log(yaml.dump(output)) | ||
| }) |
+33
-2
@@ -1,2 +0,33 @@ | ||
| /*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */ | ||
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jsyaml={})}(this,function(e){"use strict";function t(e){return null==e}var n={isNothing:t,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:t(e)?[]:[e]},repeat:function(e,t){var n,i="";for(n=0;n<t;n+=1)i+=e;return i},isNegativeZero:function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},extend:function(e,t){var n,i,r,o;if(t)for(n=0,i=(o=Object.keys(t)).length;n<i;n+=1)e[r=o[n]]=t[r];return e}};function i(e,t){var n="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+="\n\n"+e.mark.snippet),i+" "+n):i}function r(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=i(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.prototype.toString=function(e){return this.name+": "+i(this,e)};var o=r;function a(e,t,n,i,r){var o="",a="",l=Math.floor(r/2)-1;return i-t>l&&(t=i-l+(o=" ... ").length),n-i>l&&(n=i+l-(a=" ...").length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:i-t+o.length}}function l(e,t){return n.repeat(" ",t-e.length)+e}var c=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var i,r=/\r?\n|\r|\0/g,o=[0],c=[],s=-1;i=r.exec(e.buffer);)c.push(i.index),o.push(i.index+i[0].length),e.position<=i.index&&s<0&&(s=o.length-2);s<0&&(s=o.length-1);var u,p,f="",d=Math.min(e.line+t.linesAfter,c.length).toString().length,h=t.maxLength-(t.indent+d+3);for(u=1;u<=t.linesBefore&&!(s-u<0);u++)p=a(e.buffer,o[s-u],c[s-u],e.position-(o[s]-o[s-u]),h),f=n.repeat(" ",t.indent)+l((e.line-u+1).toString(),d)+" | "+p.str+"\n"+f;for(p=a(e.buffer,o[s],c[s],e.position,h),f+=n.repeat(" ",t.indent)+l((e.line+1).toString(),d)+" | "+p.str+"\n",f+=n.repeat("-",t.indent+d+3+p.pos)+"^\n",u=1;u<=t.linesAfter&&!(s+u>=c.length);u++)p=a(e.buffer,o[s+u],c[s+u],e.position-(o[s]-o[s+u]),h),f+=n.repeat(" ",t.indent)+l((e.line+u+1).toString(),d)+" | "+p.str+"\n";return f.replace(/\n$/,"")},s=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],u=["scalar","sequence","mapping"];var p=function(e,t){if(t=t||{},Object.keys(t).forEach(function(t){if(-1===s.indexOf(t))throw new o('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}(t.styleAliases||null),-1===u.indexOf(this.kind))throw new o('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function f(e,t){var n=[];return e[t].forEach(function(e){var t=n.length;n.forEach(function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)}),n[t]=e}),n}function d(e){return this.extend(e)}d.prototype.extend=function(e){var t=[],n=[];if(e instanceof p)n.push(e);else if(Array.isArray(e))n=n.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new o("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit))}t.forEach(function(e){if(!(e instanceof p))throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new o("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new o("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),n.forEach(function(e){if(!(e instanceof p))throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(d.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(n),i.compiledImplicit=f(i,"implicit"),i.compiledExplicit=f(i,"explicit"),i.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function i(e){e.multi?(n.multi[e.kind].push(e),n.multi.fallback.push(e)):n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(i);return n}(i.compiledImplicit,i.compiledExplicit),i};var h=d,g=new p("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}}),m=new p("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}}),y=new p("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}}),b=new h({explicit:[g,m,y]});var A=new p("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});var v=new p("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function w(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function k(e){return 48<=e&&e<=55}function C(e){return 48<=e&&e<=57}var x=new p("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n=e.length,i=0,r=!1;if(!n)return!1;if("-"!==(t=e[i])&&"+"!==t||(t=e[++i]),"0"===t){if(i+1===n)return!0;if("b"===(t=e[++i])){for(i++;i<n;i++)if("_"!==(t=e[i])){if("0"!==t&&"1"!==t)return!1;r=!0}return r&&"_"!==t}if("x"===t){for(i++;i<n;i++)if("_"!==(t=e[i])){if(!w(e.charCodeAt(i)))return!1;r=!0}return r&&"_"!==t}if("o"===t){for(i++;i<n;i++)if("_"!==(t=e[i])){if(!k(e.charCodeAt(i)))return!1;r=!0}return r&&"_"!==t}}if("_"===t)return!1;for(;i<n;i++)if("_"!==(t=e[i])){if(!C(e.charCodeAt(i)))return!1;r=!0}return!(!r||"_"===t)},construct:function(e){var t,n=e,i=1;if(-1!==n.indexOf("_")&&(n=n.replace(/_/g,"")),"-"!==(t=n[0])&&"+"!==t||("-"===t&&(i=-1),t=(n=n.slice(1))[0]),"0"===n)return 0;if("0"===t){if("b"===n[1])return i*parseInt(n.slice(2),2);if("x"===n[1])return i*parseInt(n.slice(2),16);if("o"===n[1])return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&e%1==0&&!n.isNegativeZero(e)},represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),I=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var S=/^[-+]?[0-9]+e/;var O=new p("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!I.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||n.isNegativeZero(e))},represent:function(e,t){var i;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(n.isNegativeZero(e))return"-0.0";return i=e.toString(10),S.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),j=b.extend({implicit:[A,v,x,O]}),T=j,N=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),F=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");var E=new p("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==N.exec(e)||null!==F.exec(e))},construct:function(e){var t,n,i,r,o,a,l,c,s=0,u=null;if(null===(t=N.exec(e))&&(t=F.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],i=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(n,i,r));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(s=t[7].slice(0,3);s.length<3;)s+="0";s=+s}return t[9]&&(u=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(u=-u)),c=new Date(Date.UTC(n,i,r,o,a,l,s)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(e){return e.toISOString()}});var M=new p("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),L="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";var _=new p("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i=0,r=e.length,o=L;for(n=0;n<r;n++)if(!((t=o.indexOf(e.charAt(n)))>64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),r=i.length,o=L,a=0,l=[];for(t=0;t<r;t++)t%4==0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return 0===(n=r%4*6)?(l.push(a>>16&255),l.push(a>>8&255),l.push(255&a)):18===n?(l.push(a>>10&255),l.push(a>>2&255)):12===n&&l.push(a>>4&255),new Uint8Array(l)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,n,i="",r=0,o=e.length,a=L;for(t=0;t<o;t++)t%3==0&&t&&(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return 0===(n=o%3)?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2===n?(i+=a[r>>10&63],i+=a[r>>4&63],i+=a[r<<2&63],i+=a[64]):1===n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}}),D=Object.prototype.hasOwnProperty,U=Object.prototype.toString;var q=new p("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=[],l=e;for(t=0,n=l.length;t<n;t+=1){if(i=l[t],o=!1,"[object Object]"!==U.call(i))return!1;for(r in i)if(D.call(i,r)){if(o)return!1;o=!0}if(!o)return!1;if(-1!==a.indexOf(r))return!1;a.push(r)}return!0},construct:function(e){return null!==e?e:[]}}),Y=Object.prototype.toString;var R=new p("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(i=a[t],"[object Object]"!==Y.call(i))return!1;if(1!==(r=Object.keys(i)).length)return!1;o[t]=[r[0],i[r[0]]]}return!0},construct:function(e){if(null===e)return[];var t,n,i,r,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1)i=a[t],r=Object.keys(i),o[t]=[r[0],i[r[0]]];return o}}),B=Object.prototype.hasOwnProperty;var K=new p("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;var t,n=e;for(t in n)if(B.call(n,t)&&null!==n[t])return!1;return!0},construct:function(e){return null!==e?e:{}}}),P=T.extend({implicit:[E,M],explicit:[_,q,R,K]}),W=Object.prototype.hasOwnProperty,H=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,$=/[\x85\u2028\u2029]/,G=/[,\[\]\{\}]/,V=/^(?:!|!!|![a-z\-]+!)$/i,Z=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function J(e){return Object.prototype.toString.call(e)}function Q(e){return 10===e||13===e}function z(e){return 9===e||32===e}function X(e){return 9===e||32===e||10===e||13===e}function ee(e){return 44===e||91===e||93===e||123===e||125===e}function te(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function ne(e){return 120===e?2:117===e?4:85===e?8:0}function ie(e){return 48<=e&&e<=57?e-48:-1}function re(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?" ":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function oe(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}function ae(e,t,n){"__proto__"===t?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}for(var le=new Array(256),ce=new Array(256),se=0;se<256;se++)le[se]=re(se)?1:0,ce[se]=re(se);function ue(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||P,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function pe(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=c(n),new o(t,n)}function fe(e,t){throw pe(e,t)}function de(e,t){e.onWarning&&e.onWarning.call(null,pe(e,t))}var he={YAML:function(e,t,n){var i,r,o;null!==e.version&&fe(e,"duplication of %YAML directive"),1!==n.length&&fe(e,"YAML directive accepts exactly one argument"),null===(i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&fe(e,"ill-formed argument of the YAML directive"),r=parseInt(i[1],10),o=parseInt(i[2],10),1!==r&&fe(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&de(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var i,r;2!==n.length&&fe(e,"TAG directive accepts exactly two arguments"),i=n[0],r=n[1],V.test(i)||fe(e,"ill-formed tag handle (first argument) of the TAG directive"),W.call(e.tagMap,i)&&fe(e,'there is a previously declared suffix for "'+i+'" tag handle'),Z.test(r)||fe(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(t){fe(e,"tag prefix is malformed: "+r)}e.tagMap[i]=r}};function ge(e,t,n,i){var r,o,a,l;if(t<n){if(l=e.input.slice(t,n),i)for(r=0,o=l.length;r<o;r+=1)9===(a=l.charCodeAt(r))||32<=a&&a<=1114111||fe(e,"expected valid JSON character");else H.test(l)&&fe(e,"the stream contains non-printable characters");e.result+=l}}function me(e,t,i,r){var o,a,l,c;for(n.isObject(i)||fe(e,"cannot merge mappings; the provided source object is unacceptable"),l=0,c=(o=Object.keys(i)).length;l<c;l+=1)a=o[l],W.call(t,a)||(ae(t,a,i[a]),r[a]=!0)}function ye(e,t,n,i,r,o,a,l,c){var s,u;if(Array.isArray(r))for(s=0,u=(r=Array.prototype.slice.call(r)).length;s<u;s+=1)Array.isArray(r[s])&&fe(e,"nested arrays are not supported inside keys"),"object"==typeof r&&"[object Object]"===J(r[s])&&(r[s]="[object Object]");if("object"==typeof r&&"[object Object]"===J(r)&&(r="[object Object]"),r=String(r),null===t&&(t={}),"tag:yaml.org,2002:merge"===i)if(Array.isArray(o))for(s=0,u=o.length;s<u;s+=1)me(e,t,o[s],n);else me(e,t,o,n);else e.json||W.call(n,r)||!W.call(t,r)||(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,fe(e,"duplicated mapping key")),ae(t,r,o),delete n[r];return t}function be(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):fe(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Ae(e,t,n){for(var i=0,r=e.input.charCodeAt(e.position);0!==r;){for(;z(r);)9===r&&-1===e.firstTabInLine&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(t&&35===r)do{r=e.input.charCodeAt(++e.position)}while(10!==r&&13!==r&&0!==r);if(!Q(r))break;for(be(e),r=e.input.charCodeAt(e.position),i++,e.lineIndent=0;32===r;)e.lineIndent++,r=e.input.charCodeAt(++e.position)}return-1!==n&&0!==i&&e.lineIndent<n&&de(e,"deficient indentation"),i}function ve(e){var t,n=e.position;return!(45!==(t=e.input.charCodeAt(n))&&46!==t||t!==e.input.charCodeAt(n+1)||t!==e.input.charCodeAt(n+2)||(n+=3,0!==(t=e.input.charCodeAt(n))&&!X(t)))}function we(e,t){1===t?e.result+=" ":t>1&&(e.result+=n.repeat("\n",t-1))}function ke(e,t){var n,i,r=e.tag,o=e.anchor,a=[],l=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),i=e.input.charCodeAt(e.position);0!==i&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,fe(e,"tab characters must not be used in indentation")),45===i)&&X(e.input.charCodeAt(e.position+1));)if(l=!0,e.position++,Ae(e,!0,-1)&&e.lineIndent<=t)a.push(null),i=e.input.charCodeAt(e.position);else if(n=e.line,Ie(e,t,3,!1,!0),a.push(e.result),Ae(e,!0,-1),i=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==i)fe(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return!!l&&(e.tag=r,e.anchor=o,e.kind="sequence",e.result=a,!0)}function Ce(e){var t,n,i,r,o=!1,a=!1;if(33!==(r=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&fe(e,"duplication of a tag property"),60===(r=e.input.charCodeAt(++e.position))?(o=!0,r=e.input.charCodeAt(++e.position)):33===r?(a=!0,n="!!",r=e.input.charCodeAt(++e.position)):n="!",t=e.position,o){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&62!==r);e.position<e.length?(i=e.input.slice(t,e.position),r=e.input.charCodeAt(++e.position)):fe(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==r&&!X(r);)33===r&&(a?fe(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),V.test(n)||fe(e,"named tag handle cannot contain such characters"),a=!0,t=e.position+1)),r=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),G.test(i)&&fe(e,"tag suffix cannot contain flow indicator characters")}i&&!Z.test(i)&&fe(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch(t){fe(e,"tag name is malformed: "+i)}return o?e.tag=i:W.call(e.tagMap,n)?e.tag=e.tagMap[n]+i:"!"===n?e.tag="!"+i:"!!"===n?e.tag="tag:yaml.org,2002:"+i:fe(e,'undeclared tag handle "'+n+'"'),!0}function xe(e){var t,n;if(38!==(n=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&fe(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!X(n)&&!ee(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&fe(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function Ie(e,t,i,r,o){var a,l,c,s,u,p,f,d,h,g=1,m=!1,y=!1;if(null!==e.listener&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,a=l=c=4===i||3===i,r&&Ae(e,!0,-1)&&(m=!0,e.lineIndent>t?g=1:e.lineIndent===t?g=0:e.lineIndent<t&&(g=-1)),1===g)for(;Ce(e)||xe(e);)Ae(e,!0,-1)?(m=!0,c=a,e.lineIndent>t?g=1:e.lineIndent===t?g=0:e.lineIndent<t&&(g=-1)):c=!1;if(c&&(c=m||o),1!==g&&4!==i||(d=1===i||2===i?t:t+1,h=e.position-e.lineStart,1===g?c&&(ke(e,h)||function(e,t,n){var i,r,o,a,l,c,s,u=e.tag,p=e.anchor,f={},d=Object.create(null),h=null,g=null,m=null,y=!1,b=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=f),s=e.input.charCodeAt(e.position);0!==s;){if(y||-1===e.firstTabInLine||(e.position=e.firstTabInLine,fe(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),o=e.line,63!==s&&58!==s||!X(i)){if(a=e.line,l=e.lineStart,c=e.position,!Ie(e,n,2,!1,!0))break;if(e.line===o){for(s=e.input.charCodeAt(e.position);z(s);)s=e.input.charCodeAt(++e.position);if(58===s)X(s=e.input.charCodeAt(++e.position))||fe(e,"a whitespace character is expected after the key-value separator within a block mapping"),y&&(ye(e,f,d,h,g,null,a,l,c),h=g=m=null),b=!0,y=!1,r=!1,h=e.tag,g=e.result;else{if(!b)return e.tag=u,e.anchor=p,!0;fe(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!b)return e.tag=u,e.anchor=p,!0;fe(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===s?(y&&(ye(e,f,d,h,g,null,a,l,c),h=g=m=null),b=!0,y=!0,r=!0):y?(y=!1,r=!0):fe(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,s=i;if((e.line===o||e.lineIndent>t)&&(y&&(a=e.line,l=e.lineStart,c=e.position),Ie(e,t,4,!0,r)&&(y?g=e.result:m=e.result),y||(ye(e,f,d,h,g,m,a,l,c),h=g=m=null),Ae(e,!0,-1),s=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&0!==s)fe(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return y&&ye(e,f,d,h,g,null,a,l,c),b&&(e.tag=u,e.anchor=p,e.kind="mapping",e.result=f),b}(e,h,d))||function(e,t){var n,i,r,o,a,l,c,s,u,p,f,d,h=!0,g=e.tag,m=e.anchor,y=Object.create(null);if(91===(d=e.input.charCodeAt(e.position)))a=93,s=!1,o=[];else{if(123!==d)return!1;a=125,s=!0,o={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=o),d=e.input.charCodeAt(++e.position);0!==d;){if(Ae(e,!0,t),(d=e.input.charCodeAt(e.position))===a)return e.position++,e.tag=g,e.anchor=m,e.kind=s?"mapping":"sequence",e.result=o,!0;h?44===d&&fe(e,"expected the node content, but found ','"):fe(e,"missed comma between flow collection entries"),f=null,l=c=!1,63===d&&X(e.input.charCodeAt(e.position+1))&&(l=c=!0,e.position++,Ae(e,!0,t)),n=e.line,i=e.lineStart,r=e.position,Ie(e,t,1,!1,!0),p=e.tag,u=e.result,Ae(e,!0,t),d=e.input.charCodeAt(e.position),!c&&e.line!==n||58!==d||(l=!0,d=e.input.charCodeAt(++e.position),Ae(e,!0,t),Ie(e,t,1,!1,!0),f=e.result),s?ye(e,o,y,p,u,f,n,i,r):l?o.push(ye(e,null,y,p,u,f,n,i,r)):o.push(u),Ae(e,!0,t),44===(d=e.input.charCodeAt(e.position))?(h=!0,d=e.input.charCodeAt(++e.position)):h=!1}fe(e,"unexpected end of the stream within a flow collection")}(e,d)?y=!0:(l&&function(e,t){var i,r,o,a,l=1,c=!1,s=!1,u=t,p=0,f=!1;if(124===(a=e.input.charCodeAt(e.position)))r=!1;else{if(62!==a)return!1;r=!0}for(e.kind="scalar",e.result="";0!==a;)if(43===(a=e.input.charCodeAt(++e.position))||45===a)1===l?l=43===a?3:2:fe(e,"repeat of a chomping mode identifier");else{if(!((o=ie(a))>=0))break;0===o?fe(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?fe(e,"repeat of an indentation width identifier"):(u=t+o-1,s=!0)}if(z(a)){do{a=e.input.charCodeAt(++e.position)}while(z(a));if(35===a)do{a=e.input.charCodeAt(++e.position)}while(!Q(a)&&0!==a)}for(;0!==a;){for(be(e),e.lineIndent=0,a=e.input.charCodeAt(e.position);(!s||e.lineIndent<u)&&32===a;)e.lineIndent++,a=e.input.charCodeAt(++e.position);if(!s&&e.lineIndent>u&&(u=e.lineIndent),Q(a))p++;else{if(e.lineIndent<u){3===l?e.result+=n.repeat("\n",c?1+p:p):1===l&&c&&(e.result+="\n");break}for(r?z(a)?(f=!0,e.result+=n.repeat("\n",c?1+p:p)):f?(f=!1,e.result+=n.repeat("\n",p+1)):0===p?c&&(e.result+=" "):e.result+=n.repeat("\n",p):e.result+=n.repeat("\n",c?1+p:p),c=!0,s=!0,p=0,i=e.position;!Q(a)&&0!==a;)a=e.input.charCodeAt(++e.position);ge(e,i,e.position,!1)}}return!0}(e,d)||function(e,t){var n,i,r;if(39!==(n=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,i=r=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(ge(e,i,e.position,!0),39!==(n=e.input.charCodeAt(++e.position)))return!0;i=e.position,e.position++,r=e.position}else Q(n)?(ge(e,i,r,!0),we(e,Ae(e,!1,t)),i=r=e.position):e.position===e.lineStart&&ve(e)?fe(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);fe(e,"unexpected end of the stream within a single quoted scalar")}(e,d)||function(e,t){var n,i,r,o,a,l;if(34!==(l=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;0!==(l=e.input.charCodeAt(e.position));){if(34===l)return ge(e,n,e.position,!0),e.position++,!0;if(92===l){if(ge(e,n,e.position,!0),Q(l=e.input.charCodeAt(++e.position)))Ae(e,!1,t);else if(l<256&&le[l])e.result+=ce[l],e.position++;else if((a=ne(l))>0){for(r=a,o=0;r>0;r--)(a=te(l=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+a:fe(e,"expected hexadecimal character");e.result+=oe(o),e.position++}else fe(e,"unknown escape sequence");n=i=e.position}else Q(l)?(ge(e,n,i,!0),we(e,Ae(e,!1,t)),n=i=e.position):e.position===e.lineStart&&ve(e)?fe(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}fe(e,"unexpected end of the stream within a double quoted scalar")}(e,d)?y=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!X(i)&&!ee(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&fe(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),W.call(e.anchorMap,n)||fe(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Ae(e,!0,-1),!0}(e)?function(e,t,n){var i,r,o,a,l,c,s,u,p=e.kind,f=e.result;if(X(u=e.input.charCodeAt(e.position))||ee(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(X(i=e.input.charCodeAt(e.position+1))||n&&ee(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==u;){if(58===u){if(X(i=e.input.charCodeAt(e.position+1))||n&&ee(i))break}else if(35===u){if(X(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&ve(e)||n&&ee(u))break;if(Q(u)){if(l=e.line,c=e.lineStart,s=e.lineIndent,Ae(e,!1,-1),e.lineIndent>=t){a=!0,u=e.input.charCodeAt(e.position);continue}e.position=o,e.line=l,e.lineStart=c,e.lineIndent=s;break}}a&&(ge(e,r,o,!1),we(e,e.line-l),r=o=e.position,a=!1),z(u)||(o=e.position+1),u=e.input.charCodeAt(++e.position)}return ge(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,d,1===i)&&(y=!0,null===e.tag&&(e.tag="?")):(y=!0,null===e.tag&&null===e.anchor||fe(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===g&&(y=c&&ke(e,h))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&fe(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),s=0,u=e.implicitTypes.length;s<u;s+=1)if((f=e.implicitTypes[s]).resolve(e.result)){e.result=f.construct(e.result),e.tag=f.tag,null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);break}}else if("!"!==e.tag){if(W.call(e.typeMap[e.kind||"fallback"],e.tag))f=e.typeMap[e.kind||"fallback"][e.tag];else for(f=null,s=0,u=(p=e.typeMap.multi[e.kind||"fallback"]).length;s<u;s+=1)if(e.tag.slice(0,p[s].tag.length)===p[s].tag){f=p[s];break}f||fe(e,"unknown tag !<"+e.tag+">"),null!==e.result&&f.kind!==e.kind&&fe(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result,e.tag)?(e.result=f.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):fe(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||y}function Se(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(Ae(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!X(r);)r=e.input.charCodeAt(++e.position);for(i=[],(n=e.input.slice(t,e.position)).length<1&&fe(e,"directive name must not be less than one character in length");0!==r;){for(;z(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!Q(r));break}if(Q(r))break;for(t=e.position;0!==r&&!X(r);)r=e.input.charCodeAt(++e.position);i.push(e.input.slice(t,e.position))}0!==r&&be(e),W.call(he,n)?he[n](e,n,i):de(e,'unknown document directive "'+n+'"')}Ae(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,Ae(e,!0,-1)):a&&fe(e,"directives end mark is expected"),Ie(e,e.lineIndent-1,4,!1,!0),Ae(e,!0,-1),e.checkLineBreaks&&$.test(e.input.slice(o,e.position))&&de(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ve(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,Ae(e,!0,-1)):e.position<e.length-1&&fe(e,"end of the stream or a document separator is expected")}function Oe(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new ue(e,t),i=e.indexOf("\0");for(-1!==i&&(n.position=i,fe(n,"null byte is not allowed in input")),n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)Se(n);return n.documents}var je={loadAll:function(e,t,n){null!==t&&"object"==typeof t&&void 0===n&&(n=t,t=null);var i=Oe(e,n);if("function"!=typeof t)return i;for(var r=0,o=i.length;r<o;r+=1)t(i[r])},load:function(e,t){var n=Oe(e,t);if(0!==n.length){if(1===n.length)return n[0];throw new o("expected a single document in the stream, but found more")}}},Te=Object.prototype.toString,Ne=Object.prototype.hasOwnProperty,Fe=65279,Ee={0:"\\0",7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r",27:"\\e",34:'\\"',92:"\\\\",133:"\\N",160:"\\_",8232:"\\L",8233:"\\P"},Me=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Le=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function _e(e){var t,i,r;if(t=e.toString(16).toUpperCase(),e<=255)i="x",r=2;else if(e<=65535)i="u",r=4;else{if(!(e<=4294967295))throw new o("code point within a string may not be greater than 0xFFFFFFFF");i="U",r=8}return"\\"+i+n.repeat("0",r-t.length)+t}function De(e){this.schema=e.schema||P,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=n.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=function(e,t){var n,i,r,o,a,l,c;if(null===t)return{};for(n={},r=0,o=(i=Object.keys(t)).length;r<o;r+=1)a=i[r],l=String(t[a]),"!!"===a.slice(0,2)&&(a="tag:yaml.org,2002:"+a.slice(2)),(c=e.compiledTypeMap.fallback[a])&&Ne.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[a]=l;return n}(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType='"'===e.quotingType?2:1,this.forceQuotes=e.forceQuotes||!1,this.replacer="function"==typeof e.replacer?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Ue(e,t){for(var i,r=n.repeat(" ",t),o=0,a=-1,l="",c=e.length;o<c;)-1===(a=e.indexOf("\n",o))?(i=e.slice(o),o=c):(i=e.slice(o,a+1),o=a+1),i.length&&"\n"!==i&&(l+=r),l+=i;return l}function qe(e,t){return"\n"+n.repeat(" ",e.indent*t)}function Ye(e){return 32===e||9===e}function Re(e){return 32<=e&&e<=126||161<=e&&e<=55295&&8232!==e&&8233!==e||57344<=e&&e<=65533&&e!==Fe||65536<=e&&e<=1114111}function Be(e){return Re(e)&&e!==Fe&&13!==e&&10!==e}function Ke(e,t,n){var i=Be(e),r=i&&!Ye(e);return(n?i:i&&44!==e&&91!==e&&93!==e&&123!==e&&125!==e)&&35!==e&&!(58===t&&!r)||Be(t)&&!Ye(t)&&35===e||58===t&&r}function Pe(e,t){var n,i=e.charCodeAt(t);return i>=55296&&i<=56319&&t+1<e.length&&(n=e.charCodeAt(t+1))>=56320&&n<=57343?1024*(i-55296)+n-56320+65536:i}function We(e){return/^\n* /.test(e)}function He(e,t,n,i,r,o,a,l){var c,s,u=0,p=null,f=!1,d=!1,h=-1!==i,g=-1,m=Re(s=Pe(e,0))&&s!==Fe&&!Ye(s)&&45!==s&&63!==s&&58!==s&&44!==s&&91!==s&&93!==s&&123!==s&&125!==s&&35!==s&&38!==s&&42!==s&&33!==s&&124!==s&&61!==s&&62!==s&&39!==s&&34!==s&&37!==s&&64!==s&&96!==s&&function(e){return!Ye(e)&&58!==e}(Pe(e,e.length-1));if(t||a)for(c=0;c<e.length;u>=65536?c+=2:c++){if(!Re(u=Pe(e,c)))return 5;m=m&&Ke(u,p,l),p=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(10===(u=Pe(e,c)))f=!0,h&&(d=d||c-g-1>i&&" "!==e[g+1],g=c);else if(!Re(u))return 5;m=m&&Ke(u,p,l),p=u}d=d||h&&c-g-1>i&&" "!==e[g+1]}return f||d?n>9&&We(e)?5:a?2===o?5:2:d?4:3:!m||a||r(e)?2===o?5:2:1}function $e(e,t,n,i,r){e.dump=function(){if(0===t.length)return 2===e.quotingType?'""':"''";if(!e.noCompatMode&&(-1!==Me.indexOf(t)||Le.test(t)))return 2===e.quotingType?'"'+t+'"':"'"+t+"'";var a=e.indent*Math.max(1,n),l=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),c=i||e.flowLevel>-1&&n>=e.flowLevel;switch(He(t,c,e.indent,l,function(t){return function(e,t){var n,i;for(n=0,i=e.implicitTypes.length;n<i;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}(e,t)},e.quotingType,e.forceQuotes&&!i,r)){case 1:return t;case 2:return"'"+t.replace(/'/g,"''")+"'";case 3:return"|"+Ge(t,e.indent)+Ve(Ue(t,a));case 4:return">"+Ge(t,e.indent)+Ve(Ue(function(e,t){var n,i,r=/(\n+)([^\n]*)/g,o=(l=e.indexOf("\n"),l=-1!==l?l:e.length,r.lastIndex=l,Ze(e.slice(0,l),t)),a="\n"===e[0]||" "===e[0];var l;for(;i=r.exec(e);){var c=i[1],s=i[2];n=" "===s[0],o+=c+(a||n||""===s?"":"\n")+Ze(s,t),a=n}return o}(t,l),a));case 5:return'"'+function(e){for(var t,n="",i=0,r=0;r<e.length;i>=65536?r+=2:r++)i=Pe(e,r),!(t=Ee[i])&&Re(i)?(n+=e[r],i>=65536&&(n+=e[r+1])):n+=t||_e(i);return n}(t)+'"';default:throw new o("impossible error: invalid scalar style")}}()}function Ge(e,t){var n=We(e)?String(t):"",i="\n"===e[e.length-1];return n+(i&&("\n"===e[e.length-2]||"\n"===e)?"+":i?"":"-")+"\n"}function Ve(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function Ze(e,t){if(""===e||" "===e[0])return e;for(var n,i,r=/ [^ ]/g,o=0,a=0,l=0,c="";n=r.exec(e);)(l=n.index)-o>t&&(i=a>o?a:l,c+="\n"+e.slice(o,i),o=i+1),a=l;return c+="\n",e.length-o>t&&a>o?c+=e.slice(o,a)+"\n"+e.slice(a+1):c+=e.slice(o),c.slice(1)}function Je(e,t,n,i){var r,o,a,l="",c=e.tag;for(r=0,o=n.length;r<o;r+=1)a=n[r],e.replacer&&(a=e.replacer.call(n,String(r),a)),(ze(e,t+1,a,!0,!0,!1,!0)||void 0===a&&ze(e,t+1,null,!0,!0,!1,!0))&&(i&&""===l||(l+=qe(e,t)),e.dump&&10===e.dump.charCodeAt(0)?l+="-":l+="- ",l+=e.dump);e.tag=c,e.dump=l||"[]"}function Qe(e,t,n){var i,r,a,l,c,s;for(a=0,l=(r=n?e.explicitTypes:e.implicitTypes).length;a<l;a+=1)if(((c=r[a]).instanceOf||c.predicate)&&(!c.instanceOf||"object"==typeof t&&t instanceof c.instanceOf)&&(!c.predicate||c.predicate(t))){if(n?c.multi&&c.representName?e.tag=c.representName(t):e.tag=c.tag:e.tag="?",c.represent){if(s=e.styleMap[c.tag]||c.defaultStyle,"[object Function]"===Te.call(c.represent))i=c.represent(t,s);else{if(!Ne.call(c.represent,s))throw new o("!<"+c.tag+'> tag resolver accepts not "'+s+'" style');i=c.represent[s](t,s)}e.dump=i}return!0}return!1}function ze(e,t,n,i,r,a,l){e.tag=null,e.dump=n,Qe(e,n,!1)||Qe(e,n,!0);var c,s=Te.call(e.dump),u=i;i&&(i=e.flowLevel<0||e.flowLevel>t);var p,f,d="[object Object]"===s||"[object Array]"===s;if(d&&(f=-1!==(p=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||f||2!==e.indent&&t>0)&&(r=!1),f&&e.usedDuplicates[p])e.dump="*ref_"+p;else{if(d&&f&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),"[object Object]"===s)i&&0!==Object.keys(e.dump).length?(!function(e,t,n,i){var r,a,l,c,s,u,p="",f=e.tag,d=Object.keys(n);if(!0===e.sortKeys)d.sort();else if("function"==typeof e.sortKeys)d.sort(e.sortKeys);else if(e.sortKeys)throw new o("sortKeys must be a boolean or a function");for(r=0,a=d.length;r<a;r+=1)u="",i&&""===p||(u+=qe(e,t)),c=n[l=d[r]],e.replacer&&(c=e.replacer.call(n,l,c)),ze(e,t+1,l,!0,!0,!0)&&((s=null!==e.tag&&"?"!==e.tag||e.dump&&e.dump.length>1024)&&(e.dump&&10===e.dump.charCodeAt(0)?u+="?":u+="? "),u+=e.dump,s&&(u+=qe(e,t)),ze(e,t+1,c,!0,s)&&(e.dump&&10===e.dump.charCodeAt(0)?u+=":":u+=": ",p+=u+=e.dump));e.tag=f,e.dump=p||"{}"}(e,t,e.dump,r),f&&(e.dump="&ref_"+p+e.dump)):(!function(e,t,n){var i,r,o,a,l,c="",s=e.tag,u=Object.keys(n);for(i=0,r=u.length;i<r;i+=1)l="",""!==c&&(l+=", "),e.condenseFlow&&(l+='"'),a=n[o=u[i]],e.replacer&&(a=e.replacer.call(n,o,a)),ze(e,t,o,!1,!1)&&(e.dump.length>1024&&(l+="? "),l+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),ze(e,t,a,!1,!1)&&(c+=l+=e.dump));e.tag=s,e.dump="{"+c+"}"}(e,t,e.dump),f&&(e.dump="&ref_"+p+" "+e.dump));else if("[object Array]"===s)i&&0!==e.dump.length?(e.noArrayIndent&&!l&&t>0?Je(e,t-1,e.dump,r):Je(e,t,e.dump,r),f&&(e.dump="&ref_"+p+e.dump)):(!function(e,t,n){var i,r,o,a="",l=e.tag;for(i=0,r=n.length;i<r;i+=1)o=n[i],e.replacer&&(o=e.replacer.call(n,String(i),o)),(ze(e,t,o,!1,!1)||void 0===o&&ze(e,t,null,!1,!1))&&(""!==a&&(a+=","+(e.condenseFlow?"":" ")),a+=e.dump);e.tag=l,e.dump="["+a+"]"}(e,t,e.dump),f&&(e.dump="&ref_"+p+" "+e.dump));else{if("[object String]"!==s){if("[object Undefined]"===s)return!1;if(e.skipInvalid)return!1;throw new o("unacceptable kind of an object to dump "+s)}"?"!==e.tag&&$e(e,e.dump,t,a,u)}null!==e.tag&&"?"!==e.tag&&(c=encodeURI("!"===e.tag[0]?e.tag.slice(1):e.tag).replace(/!/g,"%21"),c="!"===e.tag[0]?"!"+c:"tag:yaml.org,2002:"===c.slice(0,18)?"!!"+c.slice(18):"!<"+c+">",e.dump=c+" "+e.dump)}return!0}function Xe(e,t){var n,i,r=[],o=[];for(et(e,r,o),n=0,i=o.length;n<i;n+=1)t.duplicates.push(r[o[n]]);t.usedDuplicates=new Array(i)}function et(e,t,n){var i,r,o;if(null!==e&&"object"==typeof e)if(-1!==(r=t.indexOf(e)))-1===n.indexOf(r)&&n.push(r);else if(t.push(e),Array.isArray(e))for(r=0,o=e.length;r<o;r+=1)et(e[r],t,n);else for(r=0,o=(i=Object.keys(e)).length;r<o;r+=1)et(e[i[r]],t,n)}function tt(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var nt=p,it=h,rt=b,ot=j,at=T,lt=P,ct=je.load,st=je.loadAll,ut={dump:function(e,t){var n=new De(t=t||{});n.noRefs||Xe(e,n);var i=e;return n.replacer&&(i=n.replacer.call({"":i},"",i)),ze(n,0,i,!0,!0)?n.dump+"\n":""}}.dump,pt=o,ft={binary:_,float:O,map:y,null:A,pairs:R,set:K,timestamp:E,bool:v,int:x,merge:M,omap:q,seq:m,str:g},dt=tt("safeLoad","load"),ht=tt("safeLoadAll","loadAll"),gt=tt("safeDump","dump"),mt={Type:nt,Schema:it,FAILSAFE_SCHEMA:rt,JSON_SCHEMA:ot,CORE_SCHEMA:at,DEFAULT_SCHEMA:lt,load:ct,loadAll:st,dump:ut,YAMLException:pt,types:ft,safeLoad:dt,safeLoadAll:ht,safeDump:gt};e.CORE_SCHEMA=at,e.DEFAULT_SCHEMA=lt,e.FAILSAFE_SCHEMA=rt,e.JSON_SCHEMA=ot,e.Schema=it,e.Type=nt,e.YAMLException=pt,e.default=mt,e.dump=ut,e.load=ct,e.loadAll=st,e.safeDump=gt,e.safeLoad=dt,e.safeLoadAll=ht,e.types=ft,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
| (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.jsyaml={}))})(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),u=s(((e,t)=>{function n(e){return e==null}function r(e){return typeof e==`object`&&!!e}function i(e){return Array.isArray(e)?e:n(e)?[]:[e]}function a(e,t){if(t){let n=Object.keys(t);for(let r=0,i=n.length;r<i;r+=1){let i=n[r];e[i]=t[i]}}return e}function o(e,t){let n=``;for(let r=0;r<t;r+=1)n+=e;return n}function s(e){return e===0&&1/e==-1/0}t.exports.isNothing=n,t.exports.isObject=r,t.exports.toArray=i,t.exports.repeat=o,t.exports.isNegativeZero=s,t.exports.extend=a})),d=s(((e,t)=>{function n(e,t){let n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=` | ||
| `+e.mark.snippet),r+` `+n):r}function r(e,t){Error.call(this),this.name=`YAMLException`,this.reason=e,this.mark=t,this.message=n(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=Error().stack||``}r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.prototype.toString=function(e){return this.name+`: `+n(this,e)},t.exports=r})),f=s(((e,t)=>{var n=u();function r(e,t,n,r,i){let a=``,o=``,s=Math.floor(i/2)-1;return r-t>s&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function i(e,t){return n.repeat(` `,t-e.length)+e}function a(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!=`number`&&(t.indent=1),typeof t.linesBefore!=`number`&&(t.linesBefore=3),typeof t.linesAfter!=`number`&&(t.linesAfter=2);let a=/\r?\n|\r|\0/g,o=[0],s=[],c,l=-1;for(;c=a.exec(e.buffer);)s.push(c.index),o.push(c.index+c[0].length),e.position<=c.index&&l<0&&(l=o.length-2);l<0&&(l=o.length-1);let u=``,d=Math.min(e.line+t.linesAfter,s.length).toString().length,f=t.maxLength-(t.indent+d+3);for(let a=1;a<=t.linesBefore&&!(l-a<0);a++){let c=r(e.buffer,o[l-a],s[l-a],e.position-(o[l]-o[l-a]),f);u=n.repeat(` `,t.indent)+i((e.line-a+1).toString(),d)+` | `+c.str+` | ||
| `+u}let p=r(e.buffer,o[l],s[l],e.position,f);u+=n.repeat(` `,t.indent)+i((e.line+1).toString(),d)+` | `+p.str+` | ||
| `,u+=n.repeat(`-`,t.indent+d+3+p.pos)+`^ | ||
| `;for(let a=1;a<=t.linesAfter&&!(l+a>=s.length);a++){let c=r(e.buffer,o[l+a],s[l+a],e.position-(o[l]-o[l+a]),f);u+=n.repeat(` `,t.indent)+i((e.line+a+1).toString(),d)+` | `+c.str+` | ||
| `}return u.replace(/\n$/,``)}t.exports=a})),p=s(((e,t)=>{var n=d(),r=[`kind`,`multi`,`resolve`,`construct`,`instanceOf`,`predicate`,`represent`,`representName`,`defaultStyle`,`styleAliases`],i=[`scalar`,`sequence`,`mapping`];function a(e){let t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function o(e,t){if(t=t||{},Object.keys(t).forEach(function(t){if(r.indexOf(t)===-1)throw new n(`Unknown option "`+t+`" is met in definition of "`+e+`" YAML type.`)}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=a(t.styleAliases||null),i.indexOf(this.kind)===-1)throw new n(`Unknown kind "`+this.kind+`" is specified for "`+e+`" YAML type.`)}t.exports=o})),m=s(((e,t)=>{var n=d(),r=p();function i(e,t){let n=[];return e[t].forEach(function(e){let t=n.length;n.forEach(function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)}),n[t]=e}),n}function a(){let e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function t(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(let e=0,n=arguments.length;e<n;e+=1)arguments[e].forEach(t);return e}function o(e){return this.extend(e)}o.prototype.extend=function(e){let t=[],s=[];if(e instanceof r)s.push(e);else if(Array.isArray(e))s=s.concat(e);else if(e&&(Array.isArray(e.implicit)||Array.isArray(e.explicit)))e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(s=s.concat(e.explicit));else throw new n(`Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })`);t.forEach(function(e){if(!(e instanceof r))throw new n(`Specified list of YAML types (or a single Type object) contains a non-Type object.`);if(e.loadKind&&e.loadKind!==`scalar`)throw new n(`There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.`);if(e.multi)throw new n(`There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.`)}),s.forEach(function(e){if(!(e instanceof r))throw new n(`Specified list of YAML types (or a single Type object) contains a non-Type object.`)});let c=Object.create(o.prototype);return c.implicit=(this.implicit||[]).concat(t),c.explicit=(this.explicit||[]).concat(s),c.compiledImplicit=i(c,`implicit`),c.compiledExplicit=i(c,`explicit`),c.compiledTypeMap=a(c.compiledImplicit,c.compiledExplicit),c},t.exports=o})),h=s(((e,t)=>{t.exports=new(p())(`tag:yaml.org,2002:str`,{kind:`scalar`,construct:function(e){return e===null?``:e}})})),g=s(((e,t)=>{t.exports=new(p())(`tag:yaml.org,2002:seq`,{kind:`sequence`,construct:function(e){return e===null?[]:e}})})),_=s(((e,t)=>{t.exports=new(p())(`tag:yaml.org,2002:map`,{kind:`mapping`,construct:function(e){return e===null?{}:e}})})),v=s(((e,t)=>{t.exports=new(m())({explicit:[h(),g(),_()]})})),y=s(((e,t)=>{var n=p();function r(e){if(e===null)return!0;let t=e.length;return t===1&&e===`~`||t===4&&(e===`null`||e===`Null`||e===`NULL`)}function i(){return null}function a(e){return e===null}t.exports=new n(`tag:yaml.org,2002:null`,{kind:`scalar`,resolve:r,construct:i,predicate:a,represent:{canonical:function(){return`~`},lowercase:function(){return`null`},uppercase:function(){return`NULL`},camelcase:function(){return`Null`},empty:function(){return``}},defaultStyle:`lowercase`})})),b=s(((e,t)=>{var n=p();function r(e){if(e===null)return!1;let t=e.length;return t===4&&(e===`true`||e===`True`||e===`TRUE`)||t===5&&(e===`false`||e===`False`||e===`FALSE`)}function i(e){return e===`true`||e===`True`||e===`TRUE`}function a(e){return Object.prototype.toString.call(e)===`[object Boolean]`}t.exports=new n(`tag:yaml.org,2002:bool`,{kind:`scalar`,resolve:r,construct:i,predicate:a,represent:{lowercase:function(e){return e?`true`:`false`},uppercase:function(e){return e?`TRUE`:`FALSE`},camelcase:function(e){return e?`True`:`False`}},defaultStyle:`lowercase`})})),x=s(((e,t)=>{var n=u(),r=p();function i(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function a(e){return e>=48&&e<=55}function o(e){return e>=48&&e<=57}function s(e){if(e===null)return!1;let t=e.length,n=0,r=!1;if(!t)return!1;let s=e[n];if((s===`-`||s===`+`)&&(s=e[++n]),s===`0`){if(n+1===t)return!0;if(s=e[++n],s===`b`){for(n++;n<t;n++){if(s=e[n],s!==`0`&&s!==`1`)return!1;r=!0}return r&&Number.isFinite(c(e))}if(s===`x`){for(n++;n<t;n++){if(!i(e.charCodeAt(n)))return!1;r=!0}return r&&Number.isFinite(c(e))}if(s===`o`){for(n++;n<t;n++){if(!a(e.charCodeAt(n)))return!1;r=!0}return r&&Number.isFinite(c(e))}}for(;n<t;n++){if(!o(e.charCodeAt(n)))return!1;r=!0}return r?Number.isFinite(c(e)):!1}function c(e){let t=e,n=1,r=t[0];if((r===`-`||r===`+`)&&(r===`-`&&(n=-1),t=t.slice(1),r=t[0]),t===`0`)return 0;if(r===`0`){if(t[1]===`b`)return n*parseInt(t.slice(2),2);if(t[1]===`x`)return n*parseInt(t.slice(2),16);if(t[1]===`o`)return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function l(e){return c(e)}function d(e){return Object.prototype.toString.call(e)===`[object Number]`&&e%1==0&&!n.isNegativeZero(e)}t.exports=new r(`tag:yaml.org,2002:int`,{kind:`scalar`,resolve:s,construct:l,predicate:d,represent:{binary:function(e){return e>=0?`0b`+e.toString(2):`-0b`+e.toString(2).slice(1)},octal:function(e){return e>=0?`0o`+e.toString(8):`-0o`+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?`0x`+e.toString(16).toUpperCase():`-0x`+e.toString(16).toUpperCase().slice(1)}},defaultStyle:`decimal`,styleAliases:{binary:[2,`bin`],octal:[8,`oct`],decimal:[10,`dec`],hexadecimal:[16,`hex`]}})})),S=s(((e,t)=>{var n=u(),r=p(),i=RegExp(`^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),a=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function o(e){return e===null||!i.test(e)?!1:Number.isFinite(parseFloat(e,10))?!0:a.test(e)}function s(e){let t=e.toLowerCase(),n=t[0]===`-`?-1:1;return`+-`.indexOf(t[0])>=0&&(t=t.slice(1)),t===`.inf`?n===1?1/0:-1/0:t===`.nan`?NaN:n*parseFloat(t,10)}var c=/^[-+]?[0-9]+e/;function l(e,t){if(isNaN(e))switch(t){case`lowercase`:return`.nan`;case`uppercase`:return`.NAN`;case`camelcase`:return`.NaN`}else if(e===1/0)switch(t){case`lowercase`:return`.inf`;case`uppercase`:return`.INF`;case`camelcase`:return`.Inf`}else if(e===-1/0)switch(t){case`lowercase`:return`-.inf`;case`uppercase`:return`-.INF`;case`camelcase`:return`-.Inf`}else if(n.isNegativeZero(e))return`-0.0`;let r=e.toString(10);return c.test(r)?r.replace(`e`,`.e`):r}function d(e){return Object.prototype.toString.call(e)===`[object Number]`&&(e%1!=0||n.isNegativeZero(e))}t.exports=new r(`tag:yaml.org,2002:float`,{kind:`scalar`,resolve:o,construct:s,predicate:d,represent:l,defaultStyle:`lowercase`})})),C=s(((e,t)=>{t.exports=v().extend({implicit:[y(),b(),x(),S()]})})),w=s(((e,t)=>{t.exports=C()})),T=s(((e,t)=>{var n=p(),r=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),i=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function a(e){return e===null?!1:r.exec(e)!==null||i.exec(e)!==null}function o(e){let t=0,n=null,a=r.exec(e);if(a===null&&(a=i.exec(e)),a===null)throw Error(`Date resolve error`);let o=+a[1],s=a[2]-1,c=+a[3];if(!a[4])return new Date(Date.UTC(o,s,c));let l=+a[4],u=+a[5],d=+a[6];if(a[7]){for(t=a[7].slice(0,3);t.length<3;)t+=`0`;t=+t}if(a[9]){let e=+a[10],t=+(a[11]||0);n=(e*60+t)*6e4,a[9]===`-`&&(n=-n)}let f=new Date(Date.UTC(o,s,c,l,u,d,t));return n&&f.setTime(f.getTime()-n),f}function s(e){return e.toISOString()}t.exports=new n(`tag:yaml.org,2002:timestamp`,{kind:`scalar`,resolve:a,construct:o,instanceOf:Date,represent:s})})),E=s(((e,t)=>{var n=p();function r(e){return e===`<<`||e===null}t.exports=new n(`tag:yaml.org,2002:merge`,{kind:`scalar`,resolve:r})})),D=s(((e,t)=>{var n=p(),r=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= | ||
| \r`;function i(e){if(e===null)return!1;let t=0,n=e.length,i=r;for(let r=0;r<n;r++){let n=i.indexOf(e.charAt(r));if(!(n>64)){if(n<0)return!1;t+=6}}return t%8==0}function a(e){let t=e.replace(/[\r\n=]/g,``),n=t.length,i=r,a=0,o=[];for(let e=0;e<n;e++)e%4==0&&e&&(o.push(a>>16&255),o.push(a>>8&255),o.push(a&255)),a=a<<6|i.indexOf(t.charAt(e));let s=n%4*6;return s===0?(o.push(a>>16&255),o.push(a>>8&255),o.push(a&255)):s===18?(o.push(a>>10&255),o.push(a>>2&255)):s===12&&o.push(a>>4&255),new Uint8Array(o)}function o(e){let t=``,n=0,i=e.length,a=r;for(let r=0;r<i;r++)r%3==0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];let o=i%3;return o===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):o===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):o===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function s(e){return Object.prototype.toString.call(e)===`[object Uint8Array]`}t.exports=new n(`tag:yaml.org,2002:binary`,{kind:`scalar`,resolve:i,construct:a,predicate:s,represent:o})})),O=s(((e,t)=>{var n=p(),r=Object.prototype.hasOwnProperty,i=Object.prototype.toString;function a(e){if(e===null)return!0;let t=[],n=e;for(let e=0,a=n.length;e<a;e+=1){let a=n[e],o=!1;if(i.call(a)!==`[object Object]`)return!1;let s;for(s in a)if(r.call(a,s))if(!o)o=!0;else return!1;if(!o)return!1;if(t.indexOf(s)===-1)t.push(s);else return!1}return!0}function o(e){return e===null?[]:e}t.exports=new n(`tag:yaml.org,2002:omap`,{kind:`sequence`,resolve:a,construct:o})})),k=s(((e,t)=>{var n=p(),r=Object.prototype.toString;function i(e){if(e===null)return!0;let t=e,n=Array(t.length);for(let e=0,i=t.length;e<i;e+=1){let i=t[e];if(r.call(i)!==`[object Object]`)return!1;let a=Object.keys(i);if(a.length!==1)return!1;n[e]=[a[0],i[a[0]]]}return!0}function a(e){if(e===null)return[];let t=e,n=Array(t.length);for(let e=0,r=t.length;e<r;e+=1){let r=t[e],i=Object.keys(r);n[e]=[i[0],r[i[0]]]}return n}t.exports=new n(`tag:yaml.org,2002:pairs`,{kind:`sequence`,resolve:i,construct:a})})),A=s(((e,t)=>{var n=p(),r=Object.prototype.hasOwnProperty;function i(e){if(e===null)return!0;let t=e;for(let e in t)if(r.call(t,e)&&t[e]!==null)return!1;return!0}function a(e){return e===null?{}:e}t.exports=new n(`tag:yaml.org,2002:set`,{kind:`mapping`,resolve:i,construct:a})})),ee=s(((e,t)=>{t.exports=w().extend({implicit:[T(),E()],explicit:[D(),O(),k(),A()]})})),j=s(((e,t)=>{var n=u(),r=d(),i=f(),a=ee(),o=Object.prototype.hasOwnProperty,s=1,c=2,l=3,p=4,m=1,h=2,g=3,_=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,v=/[\x85\u2028\u2029]/,y=/[,\[\]{}]/,b=/^(?:!|!!|![0-9A-Za-z-]+!)$/,x=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function S(e){return Object.prototype.toString.call(e)}function C(e){return e===10||e===13}function w(e){return e===9||e===32}function T(e){return e===9||e===32||e===10||e===13}function E(e){return e===44||e===91||e===93||e===123||e===125}function D(e){if(e>=48&&e<=57)return e-48;let t=e|32;return t>=97&&t<=102?t-97+10:-1}function O(e){return e===120?2:e===117?4:e===85?8:0}function k(e){return e>=48&&e<=57?e-48:-1}function A(e){switch(e){case 48:return`\0`;case 97:return`\x07`;case 98:return`\b`;case 116:return` `;case 9:return` `;case 110:return` | ||
| `;case 118:return`\v`;case 102:return`\f`;case 114:return`\r`;case 101:return`\x1B`;case 32:return` `;case 34:return`"`;case 47:return`/`;case 92:return`\\`;case 78:return` `;case 95:return`\xA0`;case 76:return`\u2028`;case 80:return`\u2029`;default:return``}}function j(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function te(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var M=Array(256),N=Array(256);for(let e=0;e<256;e++)M[e]=+!!A(e),N[e]=A(e);function ne(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||a,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.maxDepth=typeof t.maxDepth==`number`?t.maxDepth:100,this.maxMergeSeqLength=typeof t.maxMergeSeqLength==`number`?t.maxMergeSeqLength:20,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function P(e,t){let n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=i(n),new r(t,n)}function F(e,t){throw P(e,t)}function I(e,t){e.onWarning&&e.onWarning.call(null,P(e,t))}function L(e,t,n){let r=e.anchorMapTransactions;if(r.length!==0){let n=r[r.length-1];o.call(n,t)||(n[t]={existed:o.call(e.anchorMap,t),value:e.anchorMap[t]})}e.anchorMap[t]=n}function R(e){e.anchorMapTransactions.push(Object.create(null))}function re(e){let t=e.anchorMapTransactions.pop(),n=e.anchorMapTransactions;if(n.length===0)return;let r=n[n.length-1],i=Object.keys(t);for(let e=0,n=i.length;e<n;e+=1){let n=i[e];o.call(r,n)||(r[n]=t[n])}}function z(e){let t=e.anchorMapTransactions.pop(),n=Object.keys(t);for(let r=n.length-1;r>=0;--r){let i=t[n[r]];i.existed?e.anchorMap[n[r]]=i.value:delete e.anchorMap[n[r]]}}function B(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,tag:e.tag,anchor:e.anchor,kind:e.kind,result:e.result}}function V(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.tag=t.tag,e.anchor=t.anchor,e.kind=t.kind,e.result=t.result}var H={YAML:function(e,t,n){e.version!==null&&F(e,`duplication of %YAML directive`),n.length!==1&&F(e,`YAML directive accepts exactly one argument`);let r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]);r===null&&F(e,`ill-formed argument of the YAML directive`);let i=parseInt(r[1],10),a=parseInt(r[2],10);i!==1&&F(e,`unacceptable YAML version of the document`),e.version=n[0],e.checkLineBreaks=a<2,a!==1&&a!==2&&I(e,`unsupported YAML version of the document`)},TAG:function(e,t,n){let r;n.length!==2&&F(e,`TAG directive accepts exactly two arguments`);let i=n[0];r=n[1],b.test(i)||F(e,`ill-formed tag handle (first argument) of the TAG directive`),o.call(e.tagMap,i)&&F(e,`there is a previously declared suffix for "`+i+`" tag handle`),x.test(r)||F(e,`ill-formed tag prefix (second argument) of the TAG directive`);try{r=decodeURIComponent(r)}catch(t){F(e,`tag prefix is malformed: `+r)}e.tagMap[i]=r}};function U(e,t,n,r){if(t<n){let i=e.input.slice(t,n);if(r)for(let t=0,n=i.length;t<n;t+=1){let n=i.charCodeAt(t);n===9||n>=32&&n<=1114111||F(e,`expected valid JSON character`)}else _.test(i)&&F(e,`the stream contains non-printable characters`);e.result+=i}}function W(e,t,r,i){n.isObject(r)||F(e,`cannot merge mappings; the provided source object is unacceptable`);let a=Object.keys(r);for(let e=0,n=a.length;e<n;e+=1){let n=a[e];o.call(t,n)||(te(t,n,r[n]),i[n]=!0)}}function G(e,t,n,r,i,a,s,c,l){if(Array.isArray(i)){i=Array.prototype.slice.call(i);for(let t=0,n=i.length;t<n;t+=1)Array.isArray(i[t])&&F(e,`nested arrays are not supported inside keys`),typeof i==`object`&&S(i[t])===`[object Object]`&&(i[t]=`[object Object]`)}if(typeof i==`object`&&S(i)===`[object Object]`&&(i=`[object Object]`),i=String(i),t===null&&(t={}),r===`tag:yaml.org,2002:merge`)if(Array.isArray(a)){a.length>e.maxMergeSeqLength&&F(e,`merge sequence length exceeded maxMergeSeqLength (`+e.maxMergeSeqLength+`)`);let r=new Set;for(let i=0,o=a.length;i<o;i+=1){let o=a[i];r.has(o)||(r.add(o),W(e,t,o,n))}}else W(e,t,a,n);else !e.json&&!o.call(n,i)&&o.call(t,i)&&(e.line=s||e.line,e.lineStart=c||e.lineStart,e.position=l||e.position,F(e,`duplicated mapping key`)),te(t,i,a),delete n[i];return t}function K(e){let t=e.input.charCodeAt(e.position);t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):F(e,`a line break is expected`),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function q(e,t,n){let r=0,i=e.input.charCodeAt(e.position);for(;i!==0;){for(;w(i);)i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(t&&i===35)do i=e.input.charCodeAt(++e.position);while(i!==10&&i!==13&&i!==0);if(C(i))for(K(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&I(e,`deficient indentation`),r}function J(e){let t=e.position,n=e.input.charCodeAt(t);return!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||T(n)))}function Y(e,t){t===1?e.result+=` `:t>1&&(e.result+=n.repeat(` | ||
| `,t-1))}function ie(e,t,n){let r,i,a,o,s,c,l=e.kind,u=e.result,d=e.input.charCodeAt(e.position);if(T(d)||E(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96)return!1;if(d===63||d===45){let t=e.input.charCodeAt(e.position+1);if(T(t)||n&&E(t))return!1}for(e.kind=`scalar`,e.result=``,r=i=e.position,a=!1;d!==0;){if(d===58){let t=e.input.charCodeAt(e.position+1);if(T(t)||n&&E(t))break}else if(d===35){if(T(e.input.charCodeAt(e.position-1)))break}else if(e.position===e.lineStart&&J(e)||n&&E(d))break;else if(C(d))if(o=e.line,s=e.lineStart,c=e.lineIndent,q(e,!1,-1),e.lineIndent>=t){a=!0,d=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=o,e.lineStart=s,e.lineIndent=c;break}a&&(U(e,r,i,!1),Y(e,e.line-o),r=i=e.position,a=!1),w(d)||(i=e.position+1),d=e.input.charCodeAt(++e.position)}return U(e,r,i,!1),e.result?!0:(e.kind=l,e.result=u,!1)}function X(e,t){let n,r,i=e.input.charCodeAt(e.position);if(i!==39)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39)if(U(e,n,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)n=e.position,e.position++,r=e.position;else return!0;else C(i)?(U(e,n,r,!0),Y(e,q(e,!1,t)),n=r=e.position):e.position===e.lineStart&&J(e)?F(e,`unexpected end of the document within a single quoted scalar`):(e.position++,w(i)||(r=e.position));F(e,`unexpected end of the stream within a single quoted scalar`)}function ae(e,t){let n,r,i,a=e.input.charCodeAt(e.position);if(a!==34)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(a=e.input.charCodeAt(e.position))!==0;)if(a===34)return U(e,n,e.position,!0),e.position++,!0;else if(a===92){if(U(e,n,e.position,!0),a=e.input.charCodeAt(++e.position),C(a))q(e,!1,t);else if(a<256&&M[a])e.result+=N[a],e.position++;else if((i=O(a))>0){let t=i,n=0;for(;t>0;t--)a=e.input.charCodeAt(++e.position),(i=D(a))>=0?n=(n<<4)+i:F(e,`expected hexadecimal character`);e.result+=j(n),e.position++}else F(e,`unknown escape sequence`);n=r=e.position}else C(a)?(U(e,n,r,!0),Y(e,q(e,!1,t)),n=r=e.position):e.position===e.lineStart&&J(e)?F(e,`unexpected end of the document within a double quoted scalar`):(e.position++,w(a)||(r=e.position));F(e,`unexpected end of the stream within a double quoted scalar`)}function oe(e,t){let n=!0,r,i,a,o=e.tag,c,l=e.anchor,u,d,f,p,m=Object.create(null),h,g,_,v=e.input.charCodeAt(e.position);if(v===91)u=93,p=!1,c=[];else if(v===123)u=125,p=!0,c={};else return!1;for(e.anchor!==null&&L(e,e.anchor,c),v=e.input.charCodeAt(++e.position);v!==0;){if(q(e,!0,t),v=e.input.charCodeAt(e.position),v===u)return e.position++,e.tag=o,e.anchor=l,e.kind=p?`mapping`:`sequence`,e.result=c,!0;n?v===44&&F(e,`expected the node content, but found ','`):F(e,`missed comma between flow collection entries`),g=h=_=null,d=f=!1,v===63&&T(e.input.charCodeAt(e.position+1))&&(d=f=!0,e.position++,q(e,!0,t)),r=e.line,i=e.lineStart,a=e.position,Q(e,t,s,!1,!0),g=e.tag,h=e.result,q(e,!0,t),v=e.input.charCodeAt(e.position),(f||e.line===r)&&v===58&&(d=!0,v=e.input.charCodeAt(++e.position),q(e,!0,t),Q(e,t,s,!1,!0),_=e.result),p?G(e,c,m,g,h,_,r,i,a):d?c.push(G(e,null,m,g,h,_,r,i,a)):c.push(h),q(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}F(e,`unexpected end of the stream within a flow collection`)}function Z(e,t){let r,i=m,a=!1,o=!1,s=t,c=0,l=!1,u,d=e.input.charCodeAt(e.position);if(d===124)r=!1;else if(d===62)r=!0;else return!1;for(e.kind=`scalar`,e.result=``;d!==0;)if(d=e.input.charCodeAt(++e.position),d===43||d===45)m===i?i=d===43?g:h:F(e,`repeat of a chomping mode identifier`);else if((u=k(d))>=0)u===0?F(e,`bad explicit indentation width of a block scalar; it cannot be less than one`):o?F(e,`repeat of an indentation width identifier`):(s=t+u-1,o=!0);else break;if(w(d)){do d=e.input.charCodeAt(++e.position);while(w(d));if(d===35)do d=e.input.charCodeAt(++e.position);while(!C(d)&&d!==0)}for(;d!==0;){for(K(e),e.lineIndent=0,d=e.input.charCodeAt(e.position);(!o||e.lineIndent<s)&&d===32;)e.lineIndent++,d=e.input.charCodeAt(++e.position);if(!o&&e.lineIndent>s&&(s=e.lineIndent),C(d)){c++;continue}if(!o&&s===0&&F(e,`missing indentation for block scalar`),e.lineIndent<s){i===g?e.result+=n.repeat(` | ||
| `,a?1+c:c):i===m&&a&&(e.result+=` | ||
| `);break}r?w(d)?(l=!0,e.result+=n.repeat(` | ||
| `,a?1+c:c)):l?(l=!1,e.result+=n.repeat(` | ||
| `,c+1)):c===0?a&&(e.result+=` `):e.result+=n.repeat(` | ||
| `,c):e.result+=n.repeat(` | ||
| `,a?1+c:c),a=!0,o=!0,c=0;let t=e.position;for(;!C(d)&&d!==0;)d=e.input.charCodeAt(++e.position);U(e,t,e.position,!1)}return!0}function se(e,t){let n=e.tag,r=e.anchor,i=[],a=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&L(e,e.anchor,i);let o=e.input.charCodeAt(e.position);for(;o!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,F(e,`tab characters must not be used in indentation`)),!(o!==45||!T(e.input.charCodeAt(e.position+1))));){if(a=!0,e.position++,q(e,!0,-1)&&e.lineIndent<=t){i.push(null),o=e.input.charCodeAt(e.position);continue}let n=e.line;if(Q(e,t,l,!1,!0),i.push(e.result),q(e,!0,-1),o=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&o!==0)F(e,`bad indentation of a sequence entry`);else if(e.lineIndent<t)break}return a?(e.tag=n,e.anchor=r,e.kind=`sequence`,e.result=i,!0):!1}function ce(e,t,n){let r,i,a,o,s=e.tag,l=e.anchor,u={},d=Object.create(null),f=null,m=null,h=null,g=!1,_=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&L(e,e.anchor,u);let v=e.input.charCodeAt(e.position);for(;v!==0;){!g&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,F(e,`tab characters must not be used in indentation`));let y=e.input.charCodeAt(e.position+1),b=e.line;if((v===63||v===58)&&T(y))v===63?(g&&(G(e,u,d,f,m,null,i,a,o),f=m=h=null),_=!0,g=!0,r=!0):g?(g=!1,r=!0):F(e,`incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line`),e.position+=1,v=y;else{if(i=e.line,a=e.lineStart,o=e.position,!Q(e,n,c,!1,!0))break;if(e.line===b){for(v=e.input.charCodeAt(e.position);w(v);)v=e.input.charCodeAt(++e.position);if(v===58)v=e.input.charCodeAt(++e.position),T(v)||F(e,`a whitespace character is expected after the key-value separator within a block mapping`),g&&(G(e,u,d,f,m,null,i,a,o),f=m=h=null),_=!0,g=!1,r=!1,f=e.tag,m=e.result;else if(_)F(e,`can not read an implicit mapping pair; a colon is missed`);else return e.tag=s,e.anchor=l,!0}else if(_)F(e,`can not read a block mapping entry; a multiline key may not be an implicit key`);else return e.tag=s,e.anchor=l,!0}if((e.line===b||e.lineIndent>t)&&(g&&(i=e.line,a=e.lineStart,o=e.position),Q(e,t,p,!0,r)&&(g?m=e.result:h=e.result),g||(G(e,u,d,f,m,h,i,a,o),f=m=h=null),q(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===b||e.lineIndent>t)&&v!==0)F(e,`bad indentation of a mapping entry`);else if(e.lineIndent<t)break}return g&&G(e,u,d,f,m,null,i,a,o),_&&(e.tag=s,e.anchor=l,e.kind=`mapping`,e.result=u),_}function le(e){let t=!1,n=!1,r,i,a=e.input.charCodeAt(e.position);if(a!==33)return!1;e.tag!==null&&F(e,`duplication of a tag property`),a=e.input.charCodeAt(++e.position),a===60?(t=!0,a=e.input.charCodeAt(++e.position)):a===33?(n=!0,r=`!!`,a=e.input.charCodeAt(++e.position)):r=`!`;let s=e.position;if(t){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(i=e.input.slice(s,e.position),a=e.input.charCodeAt(++e.position)):F(e,`unexpected end of the stream within a verbatim tag`)}else{for(;a!==0&&!T(a);)a===33&&(n?F(e,`tag suffix cannot contain exclamation marks`):(r=e.input.slice(s-1,e.position+1),b.test(r)||F(e,`named tag handle cannot contain such characters`),n=!0,s=e.position+1)),a=e.input.charCodeAt(++e.position);i=e.input.slice(s,e.position),y.test(i)&&F(e,`tag suffix cannot contain flow indicator characters`)}i&&!x.test(i)&&F(e,`tag name cannot contain such characters: `+i);try{i=decodeURIComponent(i)}catch(t){F(e,`tag name is malformed: `+i)}return t?e.tag=i:o.call(e.tagMap,r)?e.tag=e.tagMap[r]+i:r===`!`?e.tag=`!`+i:r===`!!`?e.tag=`tag:yaml.org,2002:`+i:F(e,`undeclared tag handle "`+r+`"`),!0}function ue(e){let t=e.input.charCodeAt(e.position);if(t!==38)return!1;e.anchor!==null&&F(e,`duplication of an anchor property`),t=e.input.charCodeAt(++e.position);let n=e.position;for(;t!==0&&!T(t)&&!E(t);)t=e.input.charCodeAt(++e.position);return e.position===n&&F(e,`name of an anchor node must contain at least one character`),e.anchor=e.input.slice(n,e.position),!0}function de(e){let t=e.input.charCodeAt(e.position);if(t!==42)return!1;t=e.input.charCodeAt(++e.position);let n=e.position;for(;t!==0&&!T(t)&&!E(t);)t=e.input.charCodeAt(++e.position);e.position===n&&F(e,`name of an alias node must contain at least one character`);let r=e.input.slice(n,e.position);return o.call(e.anchorMap,r)||F(e,`unidentified alias "`+r+`"`),e.result=e.anchorMap[r],q(e,!0,-1),!0}function fe(e,t,n,r){let i=B(e);return R(e),V(e,t),e.tag=null,e.anchor=null,e.kind=null,e.result=null,ce(e,n,r)&&e.kind===`mapping`?(re(e),!0):(z(e),V(e,i),!1)}function Q(e,t,n,r,i){let a,u,d=1,f=!1,m=!1,h=null,g,_,v;e.depth>=e.maxDepth&&F(e,`nesting exceeded maxDepth (`+e.maxDepth+`)`),e.depth+=1,e.listener!==null&&e.listener(`open`,e),e.tag=null,e.anchor=null,e.kind=null,e.result=null;let y=a=u=p===n||l===n;if(r&&q(e,!0,-1)&&(f=!0,e.lineIndent>t?d=1:e.lineIndent===t?d=0:e.lineIndent<t&&(d=-1)),d===1)for(;;){let n=e.input.charCodeAt(e.position),r=B(e);if(f&&(n===33&&e.tag!==null||n===38&&e.anchor!==null)||!le(e)&&!ue(e))break;h===null&&(h=r),q(e,!0,-1)?(f=!0,u=y,e.lineIndent>t?d=1:e.lineIndent===t?d=0:e.lineIndent<t&&(d=-1)):u=!1}if(u&&(u=f||i),d===1||p===n)if(_=s===n||c===n?t:t+1,v=e.position-e.lineStart,d===1)if(u&&(se(e,v)||ce(e,v,_))||oe(e,_))m=!0;else{let t=e.input.charCodeAt(e.position);h!==null&&y&&!u&&t!==124&&t!==62&&fe(e,h,h.position-h.lineStart,_)||a&&Z(e,_)||X(e,_)||ae(e,_)?m=!0:de(e)?(m=!0,(e.tag!==null||e.anchor!==null)&&F(e,`alias node should not have any properties`)):ie(e,_,s===n)&&(m=!0,e.tag===null&&(e.tag=`?`)),e.anchor!==null&&L(e,e.anchor,e.result)}else d===0&&(m=u&&se(e,v));if(e.tag===null)e.anchor!==null&&L(e,e.anchor,e.result);else if(e.tag===`?`){e.result!==null&&e.kind!==`scalar`&&F(e,`unacceptable node kind for !<?> tag; it should be "scalar", not "`+e.kind+`"`);for(let t=0,n=e.implicitTypes.length;t<n;t+=1)if(g=e.implicitTypes[t],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&L(e,e.anchor,e.result);break}}else if(e.tag!==`!`){if(o.call(e.typeMap[e.kind||`fallback`],e.tag))g=e.typeMap[e.kind||`fallback`][e.tag];else{g=null;let t=e.typeMap.multi[e.kind||`fallback`];for(let n=0,r=t.length;n<r;n+=1)if(e.tag.slice(0,t[n].tag.length)===t[n].tag){g=t[n];break}}g||F(e,`unknown tag !<`+e.tag+`>`),e.result!==null&&g.kind!==e.kind&&F(e,`unacceptable node kind for !<`+e.tag+`> tag; it should be "`+g.kind+`", not "`+e.kind+`"`),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&L(e,e.anchor,e.result)):F(e,`cannot resolve a node with !<`+e.tag+`> explicit tag`)}return e.listener!==null&&e.listener(`close`,e),--e.depth,e.tag!==null||e.anchor!==null||m}function pe(e){let t=e.position,n=!1,r;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(r=e.input.charCodeAt(e.position))!==0&&(q(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||r!==37));){n=!0,r=e.input.charCodeAt(++e.position);let t=e.position;for(;r!==0&&!T(r);)r=e.input.charCodeAt(++e.position);let i=e.input.slice(t,e.position),a=[];for(i.length<1&&F(e,`directive name must not be less than one character in length`);r!==0;){for(;w(r);)r=e.input.charCodeAt(++e.position);if(r===35){do r=e.input.charCodeAt(++e.position);while(r!==0&&!C(r));break}if(C(r))break;for(t=e.position;r!==0&&!T(r);)r=e.input.charCodeAt(++e.position);a.push(e.input.slice(t,e.position))}r!==0&&K(e),o.call(H,i)?H[i](e,i,a):I(e,`unknown document directive "`+i+`"`)}if(q(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,q(e,!0,-1)):n&&F(e,`directives end mark is expected`),Q(e,e.lineIndent-1,p,!1,!0),q(e,!0,-1),e.checkLineBreaks&&v.test(e.input.slice(t,e.position))&&I(e,`non-ASCII line breaks are interpreted as content`),e.documents.push(e.result),e.position===e.lineStart&&J(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,q(e,!0,-1));return}e.position<e.length-1&&F(e,`end of the stream or a document separator is expected`)}function me(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=` | ||
| `),e.charCodeAt(0)===65279&&(e=e.slice(1)));let n=new ne(e,t),r=e.indexOf(`\0`);for(r!==-1&&(n.position=r,F(n,`null byte is not allowed in input`)),n.input+=`\0`;n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)pe(n);return n.documents}function he(e,t,n){typeof t==`object`&&t&&n===void 0&&(n=t,t=null);let r=me(e,n);if(typeof t!=`function`)return r;for(let e=0,n=r.length;e<n;e+=1)t(r[e])}function ge(e,t){let n=me(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new r(`expected a single document in the stream, but found more`)}}t.exports.loadAll=he,t.exports.load=ge})),te=s(((e,t)=>{var n=u(),r=d(),i=ee(),a=Object.prototype.toString,o=Object.prototype.hasOwnProperty,s=65279,c=9,l=10,f=13,p=32,m=33,h=34,g=35,_=37,v=38,y=39,b=42,x=44,S=45,C=58,w=61,T=62,E=63,D=64,O=91,k=93,A=96,j=123,te=124,M=125,N={};N[0]=`\\0`,N[7]=`\\a`,N[8]=`\\b`,N[9]=`\\t`,N[10]=`\\n`,N[11]=`\\v`,N[12]=`\\f`,N[13]=`\\r`,N[27]=`\\e`,N[34]=`\\"`,N[92]=`\\\\`,N[133]=`\\N`,N[160]=`\\_`,N[8232]=`\\L`,N[8233]=`\\P`;var ne=[`y`,`Y`,`yes`,`Yes`,`YES`,`on`,`On`,`ON`,`n`,`N`,`no`,`No`,`NO`,`off`,`Off`,`OFF`],P=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function F(e,t){if(t===null)return{};let n={},r=Object.keys(t);for(let i=0,a=r.length;i<a;i+=1){let a=r[i],s=String(t[a]);a.slice(0,2)===`!!`&&(a=`tag:yaml.org,2002:`+a.slice(2));let c=e.compiledTypeMap.fallback[a];c&&o.call(c.styleAliases,s)&&(s=c.styleAliases[s]),n[a]=s}return n}function I(e){let t,i,a=e.toString(16).toUpperCase();if(e<=255)t=`x`,i=2;else if(e<=65535)t=`u`,i=4;else if(e<=4294967295)t=`U`,i=8;else throw new r(`code point within a string may not be greater than 0xFFFFFFFF`);return`\\`+t+n.repeat(`0`,i-a.length)+a}var L=1,R=2;function re(e){this.schema=e.schema||i,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=n.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=F(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType===`"`?R:L,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer==`function`?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result=``,this.duplicates=[],this.usedDuplicates=null}function z(e,t){let r=n.repeat(` `,t),i=0,a=``,o=e.length;for(;i<o;){let t,n=e.indexOf(` | ||
| `,i);n===-1?(t=e.slice(i),i=o):(t=e.slice(i,n+1),i=n+1),t.length&&t!==` | ||
| `&&(a+=r),a+=t}return a}function B(e,t){return` | ||
| `+n.repeat(` `,e.indent*t)}function V(e,t){for(let n=0,r=e.implicitTypes.length;n<r;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}function H(e){return e===p||e===c}function U(e){return e>=32&&e<=126||e>=161&&e<=55295&&e!==8232&&e!==8233||e>=57344&&e<=65533&&e!==s||e>=65536&&e<=1114111}function W(e){return U(e)&&e!==s&&e!==f&&e!==l}function G(e,t,n){let r=W(e),i=r&&!H(e);return(n?r:r&&e!==x&&e!==O&&e!==k&&e!==j&&e!==M)&&e!==g&&!(t===C&&!i)||W(t)&&!H(t)&&e===g||t===C&&i}function K(e){return U(e)&&e!==s&&!H(e)&&e!==S&&e!==E&&e!==C&&e!==x&&e!==O&&e!==k&&e!==j&&e!==M&&e!==g&&e!==v&&e!==b&&e!==m&&e!==te&&e!==w&&e!==T&&e!==y&&e!==h&&e!==_&&e!==D&&e!==A}function q(e){return!H(e)&&e!==C}function J(e,t){let n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function Y(e){return/^\n* /.test(e)}var ie=1,X=2,ae=3,oe=4,Z=5;function se(e,t,n,r,i,a,o,s){let c,u=0,d=null,f=!1,p=!1,m=r!==-1,h=-1,g=K(J(e,0))&&q(J(e,e.length-1));if(t||o)for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=J(e,c),!U(u))return Z;g=g&&G(u,d,s),d=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=J(e,c),u===l)f=!0,m&&(p=p||c-h-1>r&&e[h+1]!==` `,h=c);else if(!U(u))return Z;g=g&&G(u,d,s),d=u}p=p||m&&c-h-1>r&&e[h+1]!==` `}return!f&&!p?g&&!o&&!i(e)?ie:a===R?Z:X:n>9&&Y(e)?Z:o?a===R?Z:X:p?oe:ae}function ce(e,t,n,i,a){e.dump=function(){if(t.length===0)return e.quotingType===R?`""`:`''`;if(!e.noCompatMode&&(ne.indexOf(t)!==-1||P.test(t)))return e.quotingType===R?`"`+t+`"`:`'`+t+`'`;let o=e.indent*Math.max(1,n),s=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),c=i||e.flowLevel>-1&&n>=e.flowLevel;function l(t){return V(e,t)}switch(se(t,c,e.indent,s,l,e.quotingType,e.forceQuotes&&!i,a)){case ie:return t;case X:return`'`+t.replace(/'/g,`''`)+`'`;case ae:return`|`+le(t,e.indent)+ue(z(t,o));case oe:return`>`+le(t,e.indent)+ue(z(de(t,s),o));case Z:return`"`+Q(t,s)+`"`;default:throw new r(`impossible error: invalid scalar style`)}}()}function le(e,t){let n=Y(e)?String(t):``,r=e[e.length-1]===` | ||
| `;return n+(r&&(e[e.length-2]===` | ||
| `||e===` | ||
| `)?`+`:r?``:`-`)+` | ||
| `}function ue(e){return e[e.length-1]===` | ||
| `?e.slice(0,-1):e}function de(e,t){let n=/(\n+)([^\n]*)/g,r=function(){let r=e.indexOf(` | ||
| `);return r=r===-1?e.length:r,n.lastIndex=r,fe(e.slice(0,r),t)}(),i=e[0]===` | ||
| `||e[0]===` `,a,o;for(;o=n.exec(e);){let e=o[1],n=o[2];a=n[0]===` `,r+=e+(!i&&!a&&n!==``?` | ||
| `:``)+fe(n,t),i=a}return r}function fe(e,t){if(e===``||e[0]===` `)return e;let n=/ [^ ]/g,r,i=0,a,o=0,s=0,c=``;for(;r=n.exec(e);)s=r.index,s-i>t&&(a=o>i?o:s,c+=` | ||
| `+e.slice(i,a),i=a+1),o=s;return c+=` | ||
| `,e.length-i>t&&o>i?c+=e.slice(i,o)+` | ||
| `+e.slice(o+1):c+=e.slice(i),c.slice(1)}function Q(e){let t=``,n=0;for(let r=0;r<e.length;n>=65536?r+=2:r++){n=J(e,r);let i=N[n];!i&&U(n)?(t+=e[r],n>=65536&&(t+=e[r+1])):t+=i||I(n)}return t}function pe(e,t,n){let r=``,i=e.tag;for(let i=0,a=n.length;i<a;i+=1){let a=n[i];e.replacer&&(a=e.replacer.call(n,String(i),a)),($(e,t,a,!1,!1)||a===void 0&&$(e,t,null,!1,!1))&&(r!==``&&(r+=`,`+(e.condenseFlow?``:` `)),r+=e.dump)}e.tag=i,e.dump=`[`+r+`]`}function me(e,t,n,r){let i=``,a=e.tag;for(let a=0,o=n.length;a<o;a+=1){let o=n[a];e.replacer&&(o=e.replacer.call(n,String(a),o)),($(e,t+1,o,!0,!0,!1,!0)||o===void 0&&$(e,t+1,null,!0,!0,!1,!0))&&((!r||i!==``)&&(i+=B(e,t)),e.dump&&l===e.dump.charCodeAt(0)?i+=`-`:i+=`- `,i+=e.dump)}e.tag=a,e.dump=i||`[]`}function he(e,t,n){let r=``,i=e.tag,a=Object.keys(n);for(let i=0,o=a.length;i<o;i+=1){let o=``;r!==``&&(o+=`, `),e.condenseFlow&&(o+=`"`);let s=a[i],c=n[s];e.replacer&&(c=e.replacer.call(n,s,c)),$(e,t,s,!1,!1)&&(e.dump.length>1024&&(o+=`? `),o+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),$(e,t,c,!1,!1)&&(o+=e.dump,r+=o))}e.tag=i,e.dump=`{`+r+`}`}function ge(e,t,n,i){let a=``,o=e.tag,s=Object.keys(n);if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys==`function`)s.sort(e.sortKeys);else if(e.sortKeys)throw new r(`sortKeys must be a boolean or a function`);for(let r=0,o=s.length;r<o;r+=1){let o=``;(!i||a!==``)&&(o+=B(e,t));let c=s[r],u=n[c];if(e.replacer&&(u=e.replacer.call(n,c,u)),!$(e,t+1,c,!0,!0,!0))continue;let d=e.tag!==null&&e.tag!==`?`||e.dump&&e.dump.length>1024;d&&(e.dump&&l===e.dump.charCodeAt(0)?o+=`?`:o+=`? `),o+=e.dump,d&&(o+=B(e,t)),$(e,t+1,u,!0,d)&&(e.dump&&l===e.dump.charCodeAt(0)?o+=`:`:o+=`: `,o+=e.dump,a+=o)}e.tag=o,e.dump=a||`{}`}function _e(e,t,n){let i=n?e.explicitTypes:e.implicitTypes;for(let s=0,c=i.length;s<c;s+=1){let c=i[s];if((c.instanceOf||c.predicate)&&(!c.instanceOf||typeof t==`object`&&t instanceof c.instanceOf)&&(!c.predicate||c.predicate(t))){if(n?c.multi&&c.representName?e.tag=c.representName(t):e.tag=c.tag:e.tag=`?`,c.represent){let n=e.styleMap[c.tag]||c.defaultStyle,i;if(a.call(c.represent)===`[object Function]`)i=c.represent(t,n);else if(o.call(c.represent,n))i=c.represent[n](t,n);else throw new r(`!<`+c.tag+`> tag resolver accepts not "`+n+`" style`);e.dump=i}return!0}}return!1}function $(e,t,n,i,o,s,c){e.tag=null,e.dump=n,_e(e,n,!1)||_e(e,n,!0);let l=a.call(e.dump),u=i;i&&(i=e.flowLevel<0||e.flowLevel>t);let d=l===`[object Object]`||l===`[object Array]`,f,p;if(d&&(f=e.duplicates.indexOf(n),p=f!==-1),(e.tag!==null&&e.tag!==`?`||p||e.indent!==2&&t>0)&&(o=!1),p&&e.usedDuplicates[f])e.dump=`*ref_`+f;else{if(d&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l===`[object Object]`)i&&Object.keys(e.dump).length!==0?(ge(e,t,e.dump,o),p&&(e.dump=`&ref_`+f+e.dump)):(he(e,t,e.dump),p&&(e.dump=`&ref_`+f+` `+e.dump));else if(l===`[object Array]`)i&&e.dump.length!==0?(e.noArrayIndent&&!c&&t>0?me(e,t-1,e.dump,o):me(e,t,e.dump,o),p&&(e.dump=`&ref_`+f+e.dump)):(pe(e,t,e.dump),p&&(e.dump=`&ref_`+f+` `+e.dump));else if(l===`[object String]`)e.tag!==`?`&&ce(e,e.dump,t,s,u);else if(l===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new r(`unacceptable kind of an object to dump `+l)}if(e.tag!==null&&e.tag!==`?`){let t=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`);t=e.tag[0]===`!`?`!`+t:t.slice(0,18)===`tag:yaml.org,2002:`?`!!`+t.slice(18):`!<`+t+`>`,e.dump=t+` `+e.dump}}return!0}function ve(e,t){let n=[],r=[];ye(e,n,r);let i=r.length;for(let e=0;e<i;e+=1)t.duplicates.push(n[r[e]]);t.usedDuplicates=Array(i)}function ye(e,t,n){if(typeof e==`object`&&e){let r=t.indexOf(e);if(r!==-1)n.indexOf(r)===-1&&n.push(r);else if(t.push(e),Array.isArray(e))for(let r=0,i=e.length;r<i;r+=1)ye(e[r],t,n);else{let r=Object.keys(e);for(let i=0,a=r.length;i<a;i+=1)ye(e[r[i]],t,n)}}}function be(e,t){t=t||{};let n=new re(t);n.noRefs||ve(e,n);let r=e;return n.replacer&&(r=n.replacer.call({"":r},``,r)),$(n,0,r,!0,!0)?n.dump+` | ||
| `:``}t.exports.dump=be})),M=l(s(((e,t)=>{var n=j(),r=te();function i(e,t){return function(){throw Error(`Function yaml.`+e+` is removed in js-yaml 4. Use yaml.`+t+` instead, which is now safe by default.`)}}t.exports.Type=p(),t.exports.Schema=m(),t.exports.FAILSAFE_SCHEMA=v(),t.exports.JSON_SCHEMA=C(),t.exports.CORE_SCHEMA=w(),t.exports.DEFAULT_SCHEMA=ee(),t.exports.load=n.load,t.exports.loadAll=n.loadAll,t.exports.dump=r.dump,t.exports.YAMLException=d(),t.exports.types={binary:D(),float:S(),map:_(),null:y(),pairs:k(),set:A(),timestamp:T(),bool:b(),int:x(),merge:E(),omap:O(),seq:g(),str:h()},t.exports.safeLoad=i(`safeLoad`,`load`),t.exports.safeLoadAll=i(`safeLoadAll`,`loadAll`),t.exports.safeDump=i(`safeDump`,`dump`)}))(),1),{Type:N,Schema:ne,FAILSAFE_SCHEMA:P,JSON_SCHEMA:F,CORE_SCHEMA:I,DEFAULT_SCHEMA:L,load:R,loadAll:re,dump:z,YAMLException:B,types:V,safeLoad:H,safeLoadAll:U,safeDump:W}=M.default,G=M.default;e.CORE_SCHEMA=I,e.DEFAULT_SCHEMA=L,e.FAILSAFE_SCHEMA=P,e.JSON_SCHEMA=F,e.Schema=ne,e.Type=N,e.YAMLException=B,e.default=G,e.dump=z,e.load=R,e.loadAll=re,e.safeDump=W,e.safeLoad=H,e.safeLoadAll=U,e.types=V}); | ||
| //# sourceMappingURL=js-yaml.min.js.map |
+32
-35
@@ -1,47 +0,44 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| const loader = require('./lib/loader') | ||
| const dumper = require('./lib/dumper') | ||
| var loader = require('./lib/loader'); | ||
| var dumper = require('./lib/dumper'); | ||
| function renamed(from, to) { | ||
| function renamed (from, to) { | ||
| return function () { | ||
| throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + | ||
| 'Use yaml.' + to + ' instead, which is now safe by default.'); | ||
| }; | ||
| 'Use yaml.' + to + ' instead, which is now safe by default.') | ||
| } | ||
| } | ||
| module.exports.Type = require('./lib/type') | ||
| module.exports.Schema = require('./lib/schema') | ||
| module.exports.FAILSAFE_SCHEMA = require('./lib/schema/failsafe') | ||
| module.exports.JSON_SCHEMA = require('./lib/schema/json') | ||
| module.exports.CORE_SCHEMA = require('./lib/schema/core') | ||
| module.exports.DEFAULT_SCHEMA = require('./lib/schema/default') | ||
| module.exports.load = loader.load | ||
| module.exports.loadAll = loader.loadAll | ||
| module.exports.dump = dumper.dump | ||
| module.exports.YAMLException = require('./lib/exception') | ||
| module.exports.Type = require('./lib/type'); | ||
| module.exports.Schema = require('./lib/schema'); | ||
| module.exports.FAILSAFE_SCHEMA = require('./lib/schema/failsafe'); | ||
| module.exports.JSON_SCHEMA = require('./lib/schema/json'); | ||
| module.exports.CORE_SCHEMA = require('./lib/schema/core'); | ||
| module.exports.DEFAULT_SCHEMA = require('./lib/schema/default'); | ||
| module.exports.load = loader.load; | ||
| module.exports.loadAll = loader.loadAll; | ||
| module.exports.dump = dumper.dump; | ||
| module.exports.YAMLException = require('./lib/exception'); | ||
| // Re-export all types in case user wants to create custom schema | ||
| module.exports.types = { | ||
| binary: require('./lib/type/binary'), | ||
| float: require('./lib/type/float'), | ||
| map: require('./lib/type/map'), | ||
| null: require('./lib/type/null'), | ||
| pairs: require('./lib/type/pairs'), | ||
| set: require('./lib/type/set'), | ||
| binary: require('./lib/type/binary'), | ||
| float: require('./lib/type/float'), | ||
| map: require('./lib/type/map'), | ||
| null: require('./lib/type/null'), | ||
| pairs: require('./lib/type/pairs'), | ||
| set: require('./lib/type/set'), | ||
| timestamp: require('./lib/type/timestamp'), | ||
| bool: require('./lib/type/bool'), | ||
| int: require('./lib/type/int'), | ||
| merge: require('./lib/type/merge'), | ||
| omap: require('./lib/type/omap'), | ||
| seq: require('./lib/type/seq'), | ||
| str: require('./lib/type/str') | ||
| }; | ||
| bool: require('./lib/type/bool'), | ||
| int: require('./lib/type/int'), | ||
| merge: require('./lib/type/merge'), | ||
| omap: require('./lib/type/omap'), | ||
| seq: require('./lib/type/seq'), | ||
| str: require('./lib/type/str') | ||
| } | ||
| // Removed functions from JS-YAML 3.0.x | ||
| module.exports.safeLoad = renamed('safeLoad', 'load'); | ||
| module.exports.safeLoadAll = renamed('safeLoadAll', 'loadAll'); | ||
| module.exports.safeDump = renamed('safeDump', 'dump'); | ||
| module.exports.safeLoad = renamed('safeLoad', 'load') | ||
| module.exports.safeLoadAll = renamed('safeLoadAll', 'loadAll') | ||
| module.exports.safeDump = renamed('safeDump', 'dump') |
+28
-37
@@ -1,59 +0,50 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| function isNothing(subject) { | ||
| return (typeof subject === 'undefined') || (subject === null); | ||
| function isNothing (subject) { | ||
| return (typeof subject === 'undefined') || (subject === null) | ||
| } | ||
| function isObject(subject) { | ||
| return (typeof subject === 'object') && (subject !== null); | ||
| function isObject (subject) { | ||
| return (typeof subject === 'object') && (subject !== null) | ||
| } | ||
| function toArray (sequence) { | ||
| if (Array.isArray(sequence)) return sequence | ||
| else if (isNothing(sequence)) return [] | ||
| function toArray(sequence) { | ||
| if (Array.isArray(sequence)) return sequence; | ||
| else if (isNothing(sequence)) return []; | ||
| return [ sequence ]; | ||
| return [sequence] | ||
| } | ||
| function extend(target, source) { | ||
| var index, length, key, sourceKeys; | ||
| function extend (target, source) { | ||
| if (source) { | ||
| sourceKeys = Object.keys(source); | ||
| const sourceKeys = Object.keys(source) | ||
| for (index = 0, length = sourceKeys.length; index < length; index += 1) { | ||
| key = sourceKeys[index]; | ||
| target[key] = source[key]; | ||
| for (let index = 0, length = sourceKeys.length; index < length; index += 1) { | ||
| const key = sourceKeys[index] | ||
| target[key] = source[key] | ||
| } | ||
| } | ||
| return target; | ||
| return target | ||
| } | ||
| function repeat (string, count) { | ||
| let result = '' | ||
| function repeat(string, count) { | ||
| var result = '', cycle; | ||
| for (cycle = 0; cycle < count; cycle += 1) { | ||
| result += string; | ||
| for (let cycle = 0; cycle < count; cycle += 1) { | ||
| result += string | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
| function isNegativeZero(number) { | ||
| return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); | ||
| function isNegativeZero (number) { | ||
| return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number) | ||
| } | ||
| module.exports.isNothing = isNothing; | ||
| module.exports.isObject = isObject; | ||
| module.exports.toArray = toArray; | ||
| module.exports.repeat = repeat; | ||
| module.exports.isNegativeZero = isNegativeZero; | ||
| module.exports.extend = extend; | ||
| module.exports.isNothing = isNothing | ||
| module.exports.isObject = isObject | ||
| module.exports.toArray = toArray | ||
| module.exports.repeat = repeat | ||
| module.exports.isNegativeZero = isNegativeZero | ||
| module.exports.extend = extend |
+440
-468
@@ -1,189 +0,182 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| /*eslint-disable no-use-before-define*/ | ||
| const common = require('./common') | ||
| const YAMLException = require('./exception') | ||
| const DEFAULT_SCHEMA = require('./schema/default') | ||
| var common = require('./common'); | ||
| var YAMLException = require('./exception'); | ||
| var DEFAULT_SCHEMA = require('./schema/default'); | ||
| const _toString = Object.prototype.toString | ||
| const _hasOwnProperty = Object.prototype.hasOwnProperty | ||
| var _toString = Object.prototype.toString; | ||
| var _hasOwnProperty = Object.prototype.hasOwnProperty; | ||
| const CHAR_BOM = 0xFEFF | ||
| const CHAR_TAB = 0x09 /* Tab */ | ||
| const CHAR_LINE_FEED = 0x0A /* LF */ | ||
| const CHAR_CARRIAGE_RETURN = 0x0D /* CR */ | ||
| const CHAR_SPACE = 0x20 /* Space */ | ||
| const CHAR_EXCLAMATION = 0x21 /* ! */ | ||
| const CHAR_DOUBLE_QUOTE = 0x22 /* " */ | ||
| const CHAR_SHARP = 0x23 /* # */ | ||
| const CHAR_PERCENT = 0x25 /* % */ | ||
| const CHAR_AMPERSAND = 0x26 /* & */ | ||
| const CHAR_SINGLE_QUOTE = 0x27 /* ' */ | ||
| const CHAR_ASTERISK = 0x2A /* * */ | ||
| const CHAR_COMMA = 0x2C /* , */ | ||
| const CHAR_MINUS = 0x2D /* - */ | ||
| const CHAR_COLON = 0x3A /* : */ | ||
| const CHAR_EQUALS = 0x3D /* = */ | ||
| const CHAR_GREATER_THAN = 0x3E /* > */ | ||
| const CHAR_QUESTION = 0x3F /* ? */ | ||
| const CHAR_COMMERCIAL_AT = 0x40 /* @ */ | ||
| const CHAR_LEFT_SQUARE_BRACKET = 0x5B /* [ */ | ||
| const CHAR_RIGHT_SQUARE_BRACKET = 0x5D /* ] */ | ||
| const CHAR_GRAVE_ACCENT = 0x60 /* ` */ | ||
| const CHAR_LEFT_CURLY_BRACKET = 0x7B /* { */ | ||
| const CHAR_VERTICAL_LINE = 0x7C /* | */ | ||
| const CHAR_RIGHT_CURLY_BRACKET = 0x7D /* } */ | ||
| var CHAR_BOM = 0xFEFF; | ||
| var CHAR_TAB = 0x09; /* Tab */ | ||
| var CHAR_LINE_FEED = 0x0A; /* LF */ | ||
| var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ | ||
| var CHAR_SPACE = 0x20; /* Space */ | ||
| var CHAR_EXCLAMATION = 0x21; /* ! */ | ||
| var CHAR_DOUBLE_QUOTE = 0x22; /* " */ | ||
| var CHAR_SHARP = 0x23; /* # */ | ||
| var CHAR_PERCENT = 0x25; /* % */ | ||
| var CHAR_AMPERSAND = 0x26; /* & */ | ||
| var CHAR_SINGLE_QUOTE = 0x27; /* ' */ | ||
| var CHAR_ASTERISK = 0x2A; /* * */ | ||
| var CHAR_COMMA = 0x2C; /* , */ | ||
| var CHAR_MINUS = 0x2D; /* - */ | ||
| var CHAR_COLON = 0x3A; /* : */ | ||
| var CHAR_EQUALS = 0x3D; /* = */ | ||
| var CHAR_GREATER_THAN = 0x3E; /* > */ | ||
| var CHAR_QUESTION = 0x3F; /* ? */ | ||
| var CHAR_COMMERCIAL_AT = 0x40; /* @ */ | ||
| var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ | ||
| var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ | ||
| var CHAR_GRAVE_ACCENT = 0x60; /* ` */ | ||
| var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ | ||
| var CHAR_VERTICAL_LINE = 0x7C; /* | */ | ||
| var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ | ||
| const ESCAPE_SEQUENCES = {} | ||
| var ESCAPE_SEQUENCES = {}; | ||
| ESCAPE_SEQUENCES[0x00] = '\\0' | ||
| ESCAPE_SEQUENCES[0x07] = '\\a' | ||
| ESCAPE_SEQUENCES[0x08] = '\\b' | ||
| ESCAPE_SEQUENCES[0x09] = '\\t' | ||
| ESCAPE_SEQUENCES[0x0A] = '\\n' | ||
| ESCAPE_SEQUENCES[0x0B] = '\\v' | ||
| ESCAPE_SEQUENCES[0x0C] = '\\f' | ||
| ESCAPE_SEQUENCES[0x0D] = '\\r' | ||
| ESCAPE_SEQUENCES[0x1B] = '\\e' | ||
| ESCAPE_SEQUENCES[0x22] = '\\"' | ||
| ESCAPE_SEQUENCES[0x5C] = '\\\\' | ||
| ESCAPE_SEQUENCES[0x85] = '\\N' | ||
| ESCAPE_SEQUENCES[0xA0] = '\\_' | ||
| ESCAPE_SEQUENCES[0x2028] = '\\L' | ||
| ESCAPE_SEQUENCES[0x2029] = '\\P' | ||
| ESCAPE_SEQUENCES[0x00] = '\\0'; | ||
| ESCAPE_SEQUENCES[0x07] = '\\a'; | ||
| ESCAPE_SEQUENCES[0x08] = '\\b'; | ||
| ESCAPE_SEQUENCES[0x09] = '\\t'; | ||
| ESCAPE_SEQUENCES[0x0A] = '\\n'; | ||
| ESCAPE_SEQUENCES[0x0B] = '\\v'; | ||
| ESCAPE_SEQUENCES[0x0C] = '\\f'; | ||
| ESCAPE_SEQUENCES[0x0D] = '\\r'; | ||
| ESCAPE_SEQUENCES[0x1B] = '\\e'; | ||
| ESCAPE_SEQUENCES[0x22] = '\\"'; | ||
| ESCAPE_SEQUENCES[0x5C] = '\\\\'; | ||
| ESCAPE_SEQUENCES[0x85] = '\\N'; | ||
| ESCAPE_SEQUENCES[0xA0] = '\\_'; | ||
| ESCAPE_SEQUENCES[0x2028] = '\\L'; | ||
| ESCAPE_SEQUENCES[0x2029] = '\\P'; | ||
| var DEPRECATED_BOOLEANS_SYNTAX = [ | ||
| const DEPRECATED_BOOLEANS_SYNTAX = [ | ||
| 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', | ||
| 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' | ||
| ]; | ||
| ] | ||
| var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; | ||
| const DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/ | ||
| function compileStyleMap(schema, map) { | ||
| var result, keys, index, length, tag, style, type; | ||
| function compileStyleMap (schema, map) { | ||
| if (map === null) return {} | ||
| if (map === null) return {}; | ||
| const result = {} | ||
| const keys = Object.keys(map) | ||
| result = {}; | ||
| keys = Object.keys(map); | ||
| for (let index = 0, length = keys.length; index < length; index += 1) { | ||
| let tag = keys[index] | ||
| let style = String(map[tag]) | ||
| for (index = 0, length = keys.length; index < length; index += 1) { | ||
| tag = keys[index]; | ||
| style = String(map[tag]); | ||
| if (tag.slice(0, 2) === '!!') { | ||
| tag = 'tag:yaml.org,2002:' + tag.slice(2); | ||
| tag = 'tag:yaml.org,2002:' + tag.slice(2) | ||
| } | ||
| type = schema.compiledTypeMap['fallback'][tag]; | ||
| const type = schema.compiledTypeMap['fallback'][tag] | ||
| if (type && _hasOwnProperty.call(type.styleAliases, style)) { | ||
| style = type.styleAliases[style]; | ||
| style = type.styleAliases[style] | ||
| } | ||
| result[tag] = style; | ||
| result[tag] = style | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
| function encodeHex(character) { | ||
| var string, handle, length; | ||
| function encodeHex (character) { | ||
| let handle | ||
| let length | ||
| string = character.toString(16).toUpperCase(); | ||
| const string = character.toString(16).toUpperCase() | ||
| if (character <= 0xFF) { | ||
| handle = 'x'; | ||
| length = 2; | ||
| handle = 'x' | ||
| length = 2 | ||
| } else if (character <= 0xFFFF) { | ||
| handle = 'u'; | ||
| length = 4; | ||
| handle = 'u' | ||
| length = 4 | ||
| } else if (character <= 0xFFFFFFFF) { | ||
| handle = 'U'; | ||
| length = 8; | ||
| handle = 'U' | ||
| length = 8 | ||
| } else { | ||
| throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); | ||
| throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF') | ||
| } | ||
| return '\\' + handle + common.repeat('0', length - string.length) + string; | ||
| return '\\' + handle + common.repeat('0', length - string.length) + string | ||
| } | ||
| const QUOTING_TYPE_SINGLE = 1 | ||
| const QUOTING_TYPE_DOUBLE = 2 | ||
| var QUOTING_TYPE_SINGLE = 1, | ||
| QUOTING_TYPE_DOUBLE = 2; | ||
| function State (options) { | ||
| this.schema = options['schema'] || DEFAULT_SCHEMA | ||
| this.indent = Math.max(1, (options['indent'] || 2)) | ||
| this.noArrayIndent = options['noArrayIndent'] || false | ||
| this.skipInvalid = options['skipInvalid'] || false | ||
| this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']) | ||
| this.styleMap = compileStyleMap(this.schema, options['styles'] || null) | ||
| this.sortKeys = options['sortKeys'] || false | ||
| this.lineWidth = options['lineWidth'] || 80 | ||
| this.noRefs = options['noRefs'] || false | ||
| this.noCompatMode = options['noCompatMode'] || false | ||
| this.condenseFlow = options['condenseFlow'] || false | ||
| this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE | ||
| this.forceQuotes = options['forceQuotes'] || false | ||
| this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null | ||
| function State(options) { | ||
| this.schema = options['schema'] || DEFAULT_SCHEMA; | ||
| this.indent = Math.max(1, (options['indent'] || 2)); | ||
| this.noArrayIndent = options['noArrayIndent'] || false; | ||
| this.skipInvalid = options['skipInvalid'] || false; | ||
| this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); | ||
| this.styleMap = compileStyleMap(this.schema, options['styles'] || null); | ||
| this.sortKeys = options['sortKeys'] || false; | ||
| this.lineWidth = options['lineWidth'] || 80; | ||
| this.noRefs = options['noRefs'] || false; | ||
| this.noCompatMode = options['noCompatMode'] || false; | ||
| this.condenseFlow = options['condenseFlow'] || false; | ||
| this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; | ||
| this.forceQuotes = options['forceQuotes'] || false; | ||
| this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; | ||
| this.implicitTypes = this.schema.compiledImplicit | ||
| this.explicitTypes = this.schema.compiledExplicit | ||
| this.implicitTypes = this.schema.compiledImplicit; | ||
| this.explicitTypes = this.schema.compiledExplicit; | ||
| this.tag = null | ||
| this.result = '' | ||
| this.tag = null; | ||
| this.result = ''; | ||
| this.duplicates = []; | ||
| this.usedDuplicates = null; | ||
| this.duplicates = [] | ||
| this.usedDuplicates = null | ||
| } | ||
| // Indents every line in a string. Empty lines (\n only) are not indented. | ||
| function indentString(string, spaces) { | ||
| var ind = common.repeat(' ', spaces), | ||
| position = 0, | ||
| next = -1, | ||
| result = '', | ||
| line, | ||
| length = string.length; | ||
| function indentString (string, spaces) { | ||
| const ind = common.repeat(' ', spaces) | ||
| let position = 0 | ||
| let result = '' | ||
| const length = string.length | ||
| while (position < length) { | ||
| next = string.indexOf('\n', position); | ||
| let line | ||
| const next = string.indexOf('\n', position) | ||
| if (next === -1) { | ||
| line = string.slice(position); | ||
| position = length; | ||
| line = string.slice(position) | ||
| position = length | ||
| } else { | ||
| line = string.slice(position, next + 1); | ||
| position = next + 1; | ||
| line = string.slice(position, next + 1) | ||
| position = next + 1 | ||
| } | ||
| if (line.length && line !== '\n') result += ind; | ||
| if (line.length && line !== '\n') result += ind | ||
| result += line; | ||
| result += line | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
| function generateNextLine(state, level) { | ||
| return '\n' + common.repeat(' ', state.indent * level); | ||
| function generateNextLine (state, level) { | ||
| return '\n' + common.repeat(' ', state.indent * level) | ||
| } | ||
| function testImplicitResolving(state, str) { | ||
| var index, length, type; | ||
| function testImplicitResolving (state, str) { | ||
| for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) { | ||
| const type = state.implicitTypes[index] | ||
| for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { | ||
| type = state.implicitTypes[index]; | ||
| if (type.resolve(str)) { | ||
| return true; | ||
| return true | ||
| } | ||
| } | ||
| return false; | ||
| return false | ||
| } | ||
| // [33] s-white ::= s-space | s-tab | ||
| function isWhitespace(c) { | ||
| return c === CHAR_SPACE || c === CHAR_TAB; | ||
| function isWhitespace (c) { | ||
| return c === CHAR_SPACE || c === CHAR_TAB | ||
| } | ||
@@ -195,7 +188,7 @@ | ||
| // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. | ||
| function isPrintable(c) { | ||
| return (0x00020 <= c && c <= 0x00007E) | ||
| || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) | ||
| || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) | ||
| || (0x10000 <= c && c <= 0x10FFFF); | ||
| function isPrintable (c) { | ||
| return (c >= 0x00020 && c <= 0x00007E) || | ||
| ((c >= 0x000A1 && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) || | ||
| ((c >= 0x0E000 && c <= 0x00FFFD) && c !== CHAR_BOM) || | ||
| (c >= 0x10000 && c <= 0x10FFFF) | ||
| } | ||
@@ -208,8 +201,8 @@ | ||
| // ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark | ||
| function isNsCharOrWhitespace(c) { | ||
| return isPrintable(c) | ||
| && c !== CHAR_BOM | ||
| function isNsCharOrWhitespace (c) { | ||
| return isPrintable(c) && | ||
| c !== CHAR_BOM && | ||
| // - b-char | ||
| && c !== CHAR_CARRIAGE_RETURN | ||
| && c !== CHAR_LINE_FEED; | ||
| c !== CHAR_CARRIAGE_RETURN && | ||
| c !== CHAR_LINE_FEED | ||
| } | ||
@@ -226,87 +219,92 @@ | ||
| // | ( “:” /* Followed by an ns-plain-safe(c) */ ) | ||
| function isPlainSafe(c, prev, inblock) { | ||
| var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); | ||
| var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); | ||
| function isPlainSafe (c, prev, inblock) { | ||
| const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c) | ||
| const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c) | ||
| return ( | ||
| // ns-plain-safe | ||
| inblock ? // c = flow-in | ||
| cIsNsCharOrWhitespace | ||
| : cIsNsCharOrWhitespace | ||
| // - c-flow-indicator | ||
| && c !== CHAR_COMMA | ||
| && c !== CHAR_LEFT_SQUARE_BRACKET | ||
| && c !== CHAR_RIGHT_SQUARE_BRACKET | ||
| && c !== CHAR_LEFT_CURLY_BRACKET | ||
| && c !== CHAR_RIGHT_CURLY_BRACKET | ||
| ) | ||
| ( | ||
| // ns-plain-safe | ||
| inblock // c = flow-in | ||
| ? cIsNsCharOrWhitespace | ||
| : cIsNsCharOrWhitespace && | ||
| // - c-flow-indicator | ||
| c !== CHAR_COMMA && | ||
| c !== CHAR_LEFT_SQUARE_BRACKET && | ||
| c !== CHAR_RIGHT_SQUARE_BRACKET && | ||
| c !== CHAR_LEFT_CURLY_BRACKET && | ||
| c !== CHAR_RIGHT_CURLY_BRACKET | ||
| ) && | ||
| // ns-plain-char | ||
| && c !== CHAR_SHARP // false on '#' | ||
| && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' | ||
| || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' | ||
| || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' | ||
| c !== CHAR_SHARP && // false on '#' | ||
| !(prev === CHAR_COLON && !cIsNsChar) | ||
| ) || // false on ': ' | ||
| (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) || // change to true on '[^ ]#' | ||
| (prev === CHAR_COLON && cIsNsChar) // change to true on ':[^ ]' | ||
| } | ||
| // Simplified test for values allowed as the first character in plain style. | ||
| function isPlainSafeFirst(c) { | ||
| function isPlainSafeFirst (c) { | ||
| // Uses a subset of ns-char - c-indicator | ||
| // where ns-char = nb-char - s-white. | ||
| // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part | ||
| return isPrintable(c) && c !== CHAR_BOM | ||
| && !isWhitespace(c) // - s-white | ||
| return isPrintable(c) && | ||
| c !== CHAR_BOM && | ||
| !isWhitespace(c) && // - s-white | ||
| // - (c-indicator ::= | ||
| // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” | ||
| && c !== CHAR_MINUS | ||
| && c !== CHAR_QUESTION | ||
| && c !== CHAR_COLON | ||
| && c !== CHAR_COMMA | ||
| && c !== CHAR_LEFT_SQUARE_BRACKET | ||
| && c !== CHAR_RIGHT_SQUARE_BRACKET | ||
| && c !== CHAR_LEFT_CURLY_BRACKET | ||
| && c !== CHAR_RIGHT_CURLY_BRACKET | ||
| c !== CHAR_MINUS && | ||
| c !== CHAR_QUESTION && | ||
| c !== CHAR_COLON && | ||
| c !== CHAR_COMMA && | ||
| c !== CHAR_LEFT_SQUARE_BRACKET && | ||
| c !== CHAR_RIGHT_SQUARE_BRACKET && | ||
| c !== CHAR_LEFT_CURLY_BRACKET && | ||
| c !== CHAR_RIGHT_CURLY_BRACKET && | ||
| // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” | ||
| && c !== CHAR_SHARP | ||
| && c !== CHAR_AMPERSAND | ||
| && c !== CHAR_ASTERISK | ||
| && c !== CHAR_EXCLAMATION | ||
| && c !== CHAR_VERTICAL_LINE | ||
| && c !== CHAR_EQUALS | ||
| && c !== CHAR_GREATER_THAN | ||
| && c !== CHAR_SINGLE_QUOTE | ||
| && c !== CHAR_DOUBLE_QUOTE | ||
| c !== CHAR_SHARP && | ||
| c !== CHAR_AMPERSAND && | ||
| c !== CHAR_ASTERISK && | ||
| c !== CHAR_EXCLAMATION && | ||
| c !== CHAR_VERTICAL_LINE && | ||
| c !== CHAR_EQUALS && | ||
| c !== CHAR_GREATER_THAN && | ||
| c !== CHAR_SINGLE_QUOTE && | ||
| c !== CHAR_DOUBLE_QUOTE && | ||
| // | “%” | “@” | “`”) | ||
| && c !== CHAR_PERCENT | ||
| && c !== CHAR_COMMERCIAL_AT | ||
| && c !== CHAR_GRAVE_ACCENT; | ||
| c !== CHAR_PERCENT && | ||
| c !== CHAR_COMMERCIAL_AT && | ||
| c !== CHAR_GRAVE_ACCENT | ||
| } | ||
| // Simplified test for values allowed as the last character in plain style. | ||
| function isPlainSafeLast(c) { | ||
| function isPlainSafeLast (c) { | ||
| // just not whitespace or colon, it will be checked to be plain character later | ||
| return !isWhitespace(c) && c !== CHAR_COLON; | ||
| return !isWhitespace(c) && c !== CHAR_COLON | ||
| } | ||
| // Same as 'string'.codePointAt(pos), but works in older browsers. | ||
| function codePointAt(string, pos) { | ||
| var first = string.charCodeAt(pos), second; | ||
| function codePointAt (string, pos) { | ||
| const first = string.charCodeAt(pos) | ||
| let second | ||
| if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { | ||
| second = string.charCodeAt(pos + 1); | ||
| second = string.charCodeAt(pos + 1) | ||
| if (second >= 0xDC00 && second <= 0xDFFF) { | ||
| // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae | ||
| return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; | ||
| return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000 | ||
| } | ||
| } | ||
| return first; | ||
| return first | ||
| } | ||
| // Determines whether block indentation indicator is required. | ||
| function needIndentIndicator(string) { | ||
| var leadingSpaceRe = /^\n* /; | ||
| return leadingSpaceRe.test(string); | ||
| function needIndentIndicator (string) { | ||
| const leadingSpaceRe = /^\n* / | ||
| return leadingSpaceRe.test(string) | ||
| } | ||
| var STYLE_PLAIN = 1, | ||
| STYLE_SINGLE = 2, | ||
| STYLE_LITERAL = 3, | ||
| STYLE_FOLDED = 4, | ||
| STYLE_DOUBLE = 5; | ||
| const STYLE_PLAIN = 1 | ||
| const STYLE_SINGLE = 2 | ||
| const STYLE_LITERAL = 3 | ||
| const STYLE_FOLDED = 4 | ||
| const STYLE_DOUBLE = 5 | ||
@@ -320,15 +318,14 @@ // Determines which scalar styles are possible and returns the preferred style. | ||
| // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). | ||
| function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, | ||
| function chooseScalarStyle (string, singleLineOnly, indentPerLevel, lineWidth, | ||
| testAmbiguousType, quotingType, forceQuotes, inblock) { | ||
| let i | ||
| let char = 0 | ||
| let prevChar = null | ||
| let hasLineBreak = false | ||
| let hasFoldableLine = false // only checked if shouldTrackWidth | ||
| const shouldTrackWidth = lineWidth !== -1 | ||
| let previousLineBreak = -1 // count the first line correctly | ||
| let plain = isPlainSafeFirst(codePointAt(string, 0)) && | ||
| isPlainSafeLast(codePointAt(string, string.length - 1)) | ||
| var i; | ||
| var char = 0; | ||
| var prevChar = null; | ||
| var hasLineBreak = false; | ||
| var hasFoldableLine = false; // only checked if shouldTrackWidth | ||
| var shouldTrackWidth = lineWidth !== -1; | ||
| var previousLineBreak = -1; // count the first line correctly | ||
| var plain = isPlainSafeFirst(codePointAt(string, 0)) | ||
| && isPlainSafeLast(codePointAt(string, string.length - 1)); | ||
| if (singleLineOnly || forceQuotes) { | ||
@@ -338,8 +335,8 @@ // Case: no block styles. | ||
| for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { | ||
| char = codePointAt(string, i); | ||
| char = codePointAt(string, i) | ||
| if (!isPrintable(char)) { | ||
| return STYLE_DOUBLE; | ||
| return STYLE_DOUBLE | ||
| } | ||
| plain = plain && isPlainSafe(char, prevChar, inblock); | ||
| prevChar = char; | ||
| plain = plain && isPlainSafe(char, prevChar, inblock) | ||
| prevChar = char | ||
| } | ||
@@ -349,5 +346,5 @@ } else { | ||
| for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { | ||
| char = codePointAt(string, i); | ||
| char = codePointAt(string, i) | ||
| if (char === CHAR_LINE_FEED) { | ||
| hasLineBreak = true; | ||
| hasLineBreak = true | ||
| // Check if any line can be folded. | ||
@@ -358,10 +355,10 @@ if (shouldTrackWidth) { | ||
| (i - previousLineBreak - 1 > lineWidth && | ||
| string[previousLineBreak + 1] !== ' '); | ||
| previousLineBreak = i; | ||
| string[previousLineBreak + 1] !== ' ') | ||
| previousLineBreak = i | ||
| } | ||
| } else if (!isPrintable(char)) { | ||
| return STYLE_DOUBLE; | ||
| return STYLE_DOUBLE | ||
| } | ||
| plain = plain && isPlainSafe(char, prevChar, inblock); | ||
| prevChar = char; | ||
| plain = plain && isPlainSafe(char, prevChar, inblock) | ||
| prevChar = char | ||
| } | ||
@@ -371,3 +368,3 @@ // in case the end is missing a \n | ||
| (i - previousLineBreak - 1 > lineWidth && | ||
| string[previousLineBreak + 1] !== ' ')); | ||
| string[previousLineBreak + 1] !== ' ')) | ||
| } | ||
@@ -381,9 +378,9 @@ // Although every style can represent \n without escaping, prefer block styles | ||
| if (plain && !forceQuotes && !testAmbiguousType(string)) { | ||
| return STYLE_PLAIN; | ||
| return STYLE_PLAIN | ||
| } | ||
| return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; | ||
| return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE | ||
| } | ||
| // Edge case: block indentation indicator can only have one digit. | ||
| if (indentPerLevel > 9 && needIndentIndicator(string)) { | ||
| return STYLE_DOUBLE; | ||
| return STYLE_DOUBLE | ||
| } | ||
@@ -393,5 +390,5 @@ // At this point we know block styles are valid. | ||
| if (!forceQuotes) { | ||
| return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; | ||
| return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL | ||
| } | ||
| return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; | ||
| return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE | ||
| } | ||
@@ -405,14 +402,14 @@ | ||
| // Importantly, this keeps the "+" chomp indicator from gaining an extra line. | ||
| function writeScalar(state, string, level, iskey, inblock) { | ||
| function writeScalar (state, string, level, iskey, inblock) { | ||
| state.dump = (function () { | ||
| if (string.length === 0) { | ||
| return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; | ||
| return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''" | ||
| } | ||
| if (!state.noCompatMode) { | ||
| if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { | ||
| return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); | ||
| return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'") | ||
| } | ||
| } | ||
| var indent = state.indent * Math.max(1, level); // no 0-indent scalars | ||
| const indent = state.indent * Math.max(1, level) // no 0-indent scalars | ||
| // As indentation gets deeper, let the width decrease monotonically | ||
@@ -425,11 +422,12 @@ // to the lower bound min(state.lineWidth, 40). | ||
| // or an indent threshold which causes the width to suddenly increase. | ||
| var lineWidth = state.lineWidth === -1 | ||
| ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); | ||
| const lineWidth = (state.lineWidth === -1) | ||
| ? -1 | ||
| : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent) | ||
| // Without knowing if keys are implicit/explicit, assume implicit for safety. | ||
| var singleLineOnly = iskey | ||
| const singleLineOnly = iskey || | ||
| // No block styles in flow mode. | ||
| || (state.flowLevel > -1 && level >= state.flowLevel); | ||
| function testAmbiguity(string) { | ||
| return testImplicitResolving(state, string); | ||
| (state.flowLevel > -1 && level >= state.flowLevel) | ||
| function testAmbiguity (string) { | ||
| return testImplicitResolving(state, string) | ||
| } | ||
@@ -439,36 +437,35 @@ | ||
| testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { | ||
| case STYLE_PLAIN: | ||
| return string; | ||
| return string | ||
| case STYLE_SINGLE: | ||
| return "'" + string.replace(/'/g, "''") + "'"; | ||
| return "'" + string.replace(/'/g, "''") + "'" | ||
| case STYLE_LITERAL: | ||
| return '|' + blockHeader(string, state.indent) | ||
| + dropEndingNewline(indentString(string, indent)); | ||
| return '|' + blockHeader(string, state.indent) + | ||
| dropEndingNewline(indentString(string, indent)) | ||
| case STYLE_FOLDED: | ||
| return '>' + blockHeader(string, state.indent) | ||
| + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); | ||
| return '>' + blockHeader(string, state.indent) + | ||
| dropEndingNewline(indentString(foldString(string, lineWidth), indent)) | ||
| case STYLE_DOUBLE: | ||
| return '"' + escapeString(string, lineWidth) + '"'; | ||
| return '"' + escapeString(string, lineWidth) + '"' | ||
| default: | ||
| throw new YAMLException('impossible error: invalid scalar style'); | ||
| throw new YAMLException('impossible error: invalid scalar style') | ||
| } | ||
| }()); | ||
| }()) | ||
| } | ||
| // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. | ||
| function blockHeader(string, indentPerLevel) { | ||
| var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; | ||
| function blockHeader (string, indentPerLevel) { | ||
| const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '' | ||
| // note the special case: the string '\n' counts as a "trailing" empty line. | ||
| var clip = string[string.length - 1] === '\n'; | ||
| var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); | ||
| var chomp = keep ? '+' : (clip ? '' : '-'); | ||
| const clip = string[string.length - 1] === '\n' | ||
| const keep = clip && (string[string.length - 2] === '\n' || string === '\n') | ||
| const chomp = keep ? '+' : (clip ? '' : '-') | ||
| return indentIndicator + chomp + '\n'; | ||
| return indentIndicator + chomp + '\n' | ||
| } | ||
| // (See the note for writeScalar.) | ||
| function dropEndingNewline(string) { | ||
| return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; | ||
| function dropEndingNewline (string) { | ||
| return string[string.length - 1] === '\n' ? string.slice(0, -1) : string | ||
| } | ||
@@ -478,3 +475,3 @@ | ||
| // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. | ||
| function foldString(string, width) { | ||
| function foldString (string, width) { | ||
| // In folded style, $k$ consecutive newlines output as $k+1$ newlines— | ||
@@ -484,28 +481,29 @@ // unless they're before or after a more-indented line, or at the very | ||
| // Therefore, parse each chunk as newline(s) followed by a content line. | ||
| var lineRe = /(\n+)([^\n]*)/g; | ||
| const lineRe = /(\n+)([^\n]*)/g | ||
| // first line (possibly an empty line) | ||
| var result = (function () { | ||
| var nextLF = string.indexOf('\n'); | ||
| nextLF = nextLF !== -1 ? nextLF : string.length; | ||
| lineRe.lastIndex = nextLF; | ||
| return foldLine(string.slice(0, nextLF), width); | ||
| }()); | ||
| let result = (function () { | ||
| let nextLF = string.indexOf('\n') | ||
| nextLF = nextLF !== -1 ? nextLF : string.length | ||
| lineRe.lastIndex = nextLF | ||
| return foldLine(string.slice(0, nextLF), width) | ||
| }()) | ||
| // If we haven't reached the first content line yet, don't add an extra \n. | ||
| var prevMoreIndented = string[0] === '\n' || string[0] === ' '; | ||
| var moreIndented; | ||
| let prevMoreIndented = string[0] === '\n' || string[0] === ' ' | ||
| let moreIndented | ||
| // rest of the lines | ||
| var match; | ||
| let match | ||
| while ((match = lineRe.exec(string))) { | ||
| var prefix = match[1], line = match[2]; | ||
| moreIndented = (line[0] === ' '); | ||
| result += prefix | ||
| + (!prevMoreIndented && !moreIndented && line !== '' | ||
| ? '\n' : '') | ||
| + foldLine(line, width); | ||
| prevMoreIndented = moreIndented; | ||
| const prefix = match[1] | ||
| const line = match[2] | ||
| moreIndented = (line[0] === ' ') | ||
| result += prefix + | ||
| ((!prevMoreIndented && !moreIndented && line !== '') ? '\n' : '') + | ||
| foldLine(line, width) | ||
| prevMoreIndented = moreIndented | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
@@ -517,11 +515,14 @@ | ||
| // NB. More-indented lines *cannot* be folded, as that would add an extra \n. | ||
| function foldLine(line, width) { | ||
| if (line === '' || line[0] === ' ') return line; | ||
| function foldLine (line, width) { | ||
| if (line === '' || line[0] === ' ') return line | ||
| // Since a more-indented line adds a \n, breaks can't be followed by a space. | ||
| var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. | ||
| var match; | ||
| const breakRe = / [^ ]/g // note: the match index will always be <= length-2. | ||
| let match | ||
| // start is an inclusive index. end, curr, and next are exclusive. | ||
| var start = 0, end, curr = 0, next = 0; | ||
| var result = ''; | ||
| let start = 0 | ||
| let end | ||
| let curr = 0 | ||
| let next = 0 | ||
| let result = '' | ||
@@ -533,11 +534,11 @@ // Invariants: 0 <= start <= length-1. | ||
| while ((match = breakRe.exec(line))) { | ||
| next = match.index; | ||
| next = match.index | ||
| // maintain invariant: curr - start <= width | ||
| if (next - start > width) { | ||
| end = (curr > start) ? curr : next; // derive end <= length-2 | ||
| result += '\n' + line.slice(start, end); | ||
| end = (curr > start) ? curr : next // derive end <= length-2 | ||
| result += '\n' + line.slice(start, end) | ||
| // skip the space that was output as \n | ||
| start = end + 1; // derive start <= length-1 | ||
| start = end + 1 // derive start <= length-1 | ||
| } | ||
| curr = next; | ||
| curr = next | ||
| } | ||
@@ -547,46 +548,42 @@ | ||
| // It is either the whole string or a part starting from non-whitespace. | ||
| result += '\n'; | ||
| result += '\n' | ||
| // Insert a break if the remainder is too long and there is a break available. | ||
| if (line.length - start > width && curr > start) { | ||
| result += line.slice(start, curr) + '\n' + line.slice(curr + 1); | ||
| result += line.slice(start, curr) + '\n' + line.slice(curr + 1) | ||
| } else { | ||
| result += line.slice(start); | ||
| result += line.slice(start) | ||
| } | ||
| return result.slice(1); // drop extra \n joiner | ||
| return result.slice(1) // drop extra \n joiner | ||
| } | ||
| // Escapes a double-quoted string. | ||
| function escapeString(string) { | ||
| var result = ''; | ||
| var char = 0; | ||
| var escapeSeq; | ||
| function escapeString (string) { | ||
| let result = '' | ||
| let char = 0 | ||
| for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { | ||
| char = codePointAt(string, i); | ||
| escapeSeq = ESCAPE_SEQUENCES[char]; | ||
| for (let i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { | ||
| char = codePointAt(string, i) | ||
| const escapeSeq = ESCAPE_SEQUENCES[char] | ||
| if (!escapeSeq && isPrintable(char)) { | ||
| result += string[i]; | ||
| if (char >= 0x10000) result += string[i + 1]; | ||
| result += string[i] | ||
| if (char >= 0x10000) result += string[i + 1] | ||
| } else { | ||
| result += escapeSeq || encodeHex(char); | ||
| result += escapeSeq || encodeHex(char) | ||
| } | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
| function writeFlowSequence(state, level, object) { | ||
| var _result = '', | ||
| _tag = state.tag, | ||
| index, | ||
| length, | ||
| value; | ||
| function writeFlowSequence (state, level, object) { | ||
| let _result = '' | ||
| const _tag = state.tag | ||
| for (index = 0, length = object.length; index < length; index += 1) { | ||
| value = object[index]; | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| let value = object[index] | ||
| if (state.replacer) { | ||
| value = state.replacer.call(object, String(index), value); | ||
| value = state.replacer.call(object, String(index), value) | ||
| } | ||
@@ -598,24 +595,20 @@ | ||
| writeNode(state, level, null, false, false))) { | ||
| if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); | ||
| _result += state.dump; | ||
| if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : '') | ||
| _result += state.dump | ||
| } | ||
| } | ||
| state.tag = _tag; | ||
| state.dump = '[' + _result + ']'; | ||
| state.tag = _tag | ||
| state.dump = '[' + _result + ']' | ||
| } | ||
| function writeBlockSequence(state, level, object, compact) { | ||
| var _result = '', | ||
| _tag = state.tag, | ||
| index, | ||
| length, | ||
| value; | ||
| function writeBlockSequence (state, level, object, compact) { | ||
| let _result = '' | ||
| const _tag = state.tag | ||
| for (index = 0, length = object.length; index < length; index += 1) { | ||
| value = object[index]; | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| let value = object[index] | ||
| if (state.replacer) { | ||
| value = state.replacer.call(object, String(index), value); | ||
| value = state.replacer.call(object, String(index), value) | ||
| } | ||
@@ -627,77 +620,64 @@ | ||
| writeNode(state, level + 1, null, true, true, false, true))) { | ||
| if (!compact || _result !== '') { | ||
| _result += generateNextLine(state, level); | ||
| _result += generateNextLine(state, level) | ||
| } | ||
| if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { | ||
| _result += '-'; | ||
| _result += '-' | ||
| } else { | ||
| _result += '- '; | ||
| _result += '- ' | ||
| } | ||
| _result += state.dump; | ||
| _result += state.dump | ||
| } | ||
| } | ||
| state.tag = _tag; | ||
| state.dump = _result || '[]'; // Empty sequence if no valid values. | ||
| state.tag = _tag | ||
| state.dump = _result || '[]' // Empty sequence if no valid values. | ||
| } | ||
| function writeFlowMapping(state, level, object) { | ||
| var _result = '', | ||
| _tag = state.tag, | ||
| objectKeyList = Object.keys(object), | ||
| index, | ||
| length, | ||
| objectKey, | ||
| objectValue, | ||
| pairBuffer; | ||
| function writeFlowMapping (state, level, object) { | ||
| let _result = '' | ||
| const _tag = state.tag | ||
| const objectKeyList = Object.keys(object) | ||
| for (index = 0, length = objectKeyList.length; index < length; index += 1) { | ||
| for (let index = 0, length = objectKeyList.length; index < length; index += 1) { | ||
| let pairBuffer = '' | ||
| if (_result !== '') pairBuffer += ', ' | ||
| pairBuffer = ''; | ||
| if (_result !== '') pairBuffer += ', '; | ||
| if (state.condenseFlow) pairBuffer += '"' | ||
| if (state.condenseFlow) pairBuffer += '"'; | ||
| const objectKey = objectKeyList[index] | ||
| let objectValue = object[objectKey] | ||
| objectKey = objectKeyList[index]; | ||
| objectValue = object[objectKey]; | ||
| if (state.replacer) { | ||
| objectValue = state.replacer.call(object, objectKey, objectValue); | ||
| objectValue = state.replacer.call(object, objectKey, objectValue) | ||
| } | ||
| if (!writeNode(state, level, objectKey, false, false)) { | ||
| continue; // Skip this pair because of invalid key; | ||
| continue // Skip this pair because of invalid key; | ||
| } | ||
| if (state.dump.length > 1024) pairBuffer += '? '; | ||
| if (state.dump.length > 1024) pairBuffer += '? ' | ||
| pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); | ||
| pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ') | ||
| if (!writeNode(state, level, objectValue, false, false)) { | ||
| continue; // Skip this pair because of invalid value. | ||
| continue // Skip this pair because of invalid value. | ||
| } | ||
| pairBuffer += state.dump; | ||
| pairBuffer += state.dump | ||
| // Both key and value are valid. | ||
| _result += pairBuffer; | ||
| _result += pairBuffer | ||
| } | ||
| state.tag = _tag; | ||
| state.dump = '{' + _result + '}'; | ||
| state.tag = _tag | ||
| state.dump = '{' + _result + '}' | ||
| } | ||
| function writeBlockMapping(state, level, object, compact) { | ||
| var _result = '', | ||
| _tag = state.tag, | ||
| objectKeyList = Object.keys(object), | ||
| index, | ||
| length, | ||
| objectKey, | ||
| objectValue, | ||
| explicitPair, | ||
| pairBuffer; | ||
| function writeBlockMapping (state, level, object, compact) { | ||
| let _result = '' | ||
| const _tag = state.tag | ||
| const objectKeyList = Object.keys(object) | ||
@@ -707,107 +687,105 @@ // Allow sorting keys so that the output file is deterministic | ||
| // Default sorting | ||
| objectKeyList.sort(); | ||
| objectKeyList.sort() | ||
| } else if (typeof state.sortKeys === 'function') { | ||
| // Custom sort function | ||
| objectKeyList.sort(state.sortKeys); | ||
| objectKeyList.sort(state.sortKeys) | ||
| } else if (state.sortKeys) { | ||
| // Something is wrong | ||
| throw new YAMLException('sortKeys must be a boolean or a function'); | ||
| throw new YAMLException('sortKeys must be a boolean or a function') | ||
| } | ||
| for (index = 0, length = objectKeyList.length; index < length; index += 1) { | ||
| pairBuffer = ''; | ||
| for (let index = 0, length = objectKeyList.length; index < length; index += 1) { | ||
| let pairBuffer = '' | ||
| if (!compact || _result !== '') { | ||
| pairBuffer += generateNextLine(state, level); | ||
| pairBuffer += generateNextLine(state, level) | ||
| } | ||
| objectKey = objectKeyList[index]; | ||
| objectValue = object[objectKey]; | ||
| const objectKey = objectKeyList[index] | ||
| let objectValue = object[objectKey] | ||
| if (state.replacer) { | ||
| objectValue = state.replacer.call(object, objectKey, objectValue); | ||
| objectValue = state.replacer.call(object, objectKey, objectValue) | ||
| } | ||
| if (!writeNode(state, level + 1, objectKey, true, true, true)) { | ||
| continue; // Skip this pair because of invalid key. | ||
| continue // Skip this pair because of invalid key. | ||
| } | ||
| explicitPair = (state.tag !== null && state.tag !== '?') || | ||
| (state.dump && state.dump.length > 1024); | ||
| const explicitPair = (state.tag !== null && state.tag !== '?') || | ||
| (state.dump && state.dump.length > 1024) | ||
| if (explicitPair) { | ||
| if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { | ||
| pairBuffer += '?'; | ||
| pairBuffer += '?' | ||
| } else { | ||
| pairBuffer += '? '; | ||
| pairBuffer += '? ' | ||
| } | ||
| } | ||
| pairBuffer += state.dump; | ||
| pairBuffer += state.dump | ||
| if (explicitPair) { | ||
| pairBuffer += generateNextLine(state, level); | ||
| pairBuffer += generateNextLine(state, level) | ||
| } | ||
| if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { | ||
| continue; // Skip this pair because of invalid value. | ||
| continue // Skip this pair because of invalid value. | ||
| } | ||
| if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { | ||
| pairBuffer += ':'; | ||
| pairBuffer += ':' | ||
| } else { | ||
| pairBuffer += ': '; | ||
| pairBuffer += ': ' | ||
| } | ||
| pairBuffer += state.dump; | ||
| pairBuffer += state.dump | ||
| // Both key and value are valid. | ||
| _result += pairBuffer; | ||
| _result += pairBuffer | ||
| } | ||
| state.tag = _tag; | ||
| state.dump = _result || '{}'; // Empty mapping if no valid pairs. | ||
| state.tag = _tag | ||
| state.dump = _result || '{}' // Empty mapping if no valid pairs. | ||
| } | ||
| function detectType(state, object, explicit) { | ||
| var _result, typeList, index, length, type, style; | ||
| function detectType (state, object, explicit) { | ||
| const typeList = explicit ? state.explicitTypes : state.implicitTypes | ||
| typeList = explicit ? state.explicitTypes : state.implicitTypes; | ||
| for (let index = 0, length = typeList.length; index < length; index += 1) { | ||
| const type = typeList[index] | ||
| for (index = 0, length = typeList.length; index < length; index += 1) { | ||
| type = typeList[index]; | ||
| if ((type.instanceOf || type.predicate) && | ||
| if ((type.instanceOf || type.predicate) && | ||
| (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && | ||
| (!type.predicate || type.predicate(object))) { | ||
| (!type.predicate || type.predicate(object))) { | ||
| if (explicit) { | ||
| if (type.multi && type.representName) { | ||
| state.tag = type.representName(object); | ||
| state.tag = type.representName(object) | ||
| } else { | ||
| state.tag = type.tag; | ||
| state.tag = type.tag | ||
| } | ||
| } else { | ||
| state.tag = '?'; | ||
| state.tag = '?' | ||
| } | ||
| if (type.represent) { | ||
| style = state.styleMap[type.tag] || type.defaultStyle; | ||
| const style = state.styleMap[type.tag] || type.defaultStyle | ||
| let _result | ||
| if (_toString.call(type.represent) === '[object Function]') { | ||
| _result = type.represent(object, style); | ||
| _result = type.represent(object, style) | ||
| } else if (_hasOwnProperty.call(type.represent, style)) { | ||
| _result = type.represent[style](object, style); | ||
| _result = type.represent[style](object, style) | ||
| } else { | ||
| throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); | ||
| throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style') | ||
| } | ||
| state.dump = _result; | ||
| state.dump = _result | ||
| } | ||
| return true; | ||
| return true | ||
| } | ||
| } | ||
| return false; | ||
| return false | ||
| } | ||
@@ -818,47 +796,46 @@ | ||
| // | ||
| function writeNode(state, level, object, block, compact, iskey, isblockseq) { | ||
| state.tag = null; | ||
| state.dump = object; | ||
| function writeNode (state, level, object, block, compact, iskey, isblockseq) { | ||
| state.tag = null | ||
| state.dump = object | ||
| if (!detectType(state, object, false)) { | ||
| detectType(state, object, true); | ||
| detectType(state, object, true) | ||
| } | ||
| var type = _toString.call(state.dump); | ||
| var inblock = block; | ||
| var tagStr; | ||
| const type = _toString.call(state.dump) | ||
| const inblock = block | ||
| if (block) { | ||
| block = (state.flowLevel < 0 || state.flowLevel > level); | ||
| block = (state.flowLevel < 0 || state.flowLevel > level) | ||
| } | ||
| var objectOrArray = type === '[object Object]' || type === '[object Array]', | ||
| duplicateIndex, | ||
| duplicate; | ||
| const objectOrArray = type === '[object Object]' || type === '[object Array]' | ||
| let duplicateIndex | ||
| let duplicate | ||
| if (objectOrArray) { | ||
| duplicateIndex = state.duplicates.indexOf(object); | ||
| duplicate = duplicateIndex !== -1; | ||
| duplicateIndex = state.duplicates.indexOf(object) | ||
| duplicate = duplicateIndex !== -1 | ||
| } | ||
| if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { | ||
| compact = false; | ||
| compact = false | ||
| } | ||
| if (duplicate && state.usedDuplicates[duplicateIndex]) { | ||
| state.dump = '*ref_' + duplicateIndex; | ||
| state.dump = '*ref_' + duplicateIndex | ||
| } else { | ||
| if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { | ||
| state.usedDuplicates[duplicateIndex] = true; | ||
| state.usedDuplicates[duplicateIndex] = true | ||
| } | ||
| if (type === '[object Object]') { | ||
| if (block && (Object.keys(state.dump).length !== 0)) { | ||
| writeBlockMapping(state, level, state.dump, compact); | ||
| writeBlockMapping(state, level, state.dump, compact) | ||
| if (duplicate) { | ||
| state.dump = '&ref_' + duplicateIndex + state.dump; | ||
| state.dump = '&ref_' + duplicateIndex + state.dump | ||
| } | ||
| } else { | ||
| writeFlowMapping(state, level, state.dump); | ||
| writeFlowMapping(state, level, state.dump) | ||
| if (duplicate) { | ||
| state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; | ||
| state.dump = '&ref_' + duplicateIndex + ' ' + state.dump | ||
| } | ||
@@ -869,13 +846,13 @@ } | ||
| if (state.noArrayIndent && !isblockseq && level > 0) { | ||
| writeBlockSequence(state, level - 1, state.dump, compact); | ||
| writeBlockSequence(state, level - 1, state.dump, compact) | ||
| } else { | ||
| writeBlockSequence(state, level, state.dump, compact); | ||
| writeBlockSequence(state, level, state.dump, compact) | ||
| } | ||
| if (duplicate) { | ||
| state.dump = '&ref_' + duplicateIndex + state.dump; | ||
| state.dump = '&ref_' + duplicateIndex + state.dump | ||
| } | ||
| } else { | ||
| writeFlowSequence(state, level, state.dump); | ||
| writeFlowSequence(state, level, state.dump) | ||
| if (duplicate) { | ||
| state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; | ||
| state.dump = '&ref_' + duplicateIndex + ' ' + state.dump | ||
| } | ||
@@ -885,9 +862,9 @@ } | ||
| if (state.tag !== '?') { | ||
| writeScalar(state, state.dump, level, iskey, inblock); | ||
| writeScalar(state, state.dump, level, iskey, inblock) | ||
| } | ||
| } else if (type === '[object Undefined]') { | ||
| return false; | ||
| return false | ||
| } else { | ||
| if (state.skipInvalid) return false; | ||
| throw new YAMLException('unacceptable kind of an object to dump ' + type); | ||
| if (state.skipInvalid) return false | ||
| throw new YAMLException('unacceptable kind of an object to dump ' + type) | ||
| } | ||
@@ -909,58 +886,53 @@ | ||
| // | ||
| tagStr = encodeURI( | ||
| let tagStr = encodeURI( | ||
| state.tag[0] === '!' ? state.tag.slice(1) : state.tag | ||
| ).replace(/!/g, '%21'); | ||
| ).replace(/!/g, '%21') | ||
| if (state.tag[0] === '!') { | ||
| tagStr = '!' + tagStr; | ||
| tagStr = '!' + tagStr | ||
| } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { | ||
| tagStr = '!!' + tagStr.slice(18); | ||
| tagStr = '!!' + tagStr.slice(18) | ||
| } else { | ||
| tagStr = '!<' + tagStr + '>'; | ||
| tagStr = '!<' + tagStr + '>' | ||
| } | ||
| state.dump = tagStr + ' ' + state.dump; | ||
| state.dump = tagStr + ' ' + state.dump | ||
| } | ||
| } | ||
| return true; | ||
| return true | ||
| } | ||
| function getDuplicateReferences(object, state) { | ||
| var objects = [], | ||
| duplicatesIndexes = [], | ||
| index, | ||
| length; | ||
| function getDuplicateReferences (object, state) { | ||
| const objects = [] | ||
| const duplicatesIndexes = [] | ||
| inspectNode(object, objects, duplicatesIndexes); | ||
| inspectNode(object, objects, duplicatesIndexes) | ||
| for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { | ||
| state.duplicates.push(objects[duplicatesIndexes[index]]); | ||
| const length = duplicatesIndexes.length | ||
| for (let index = 0; index < length; index += 1) { | ||
| state.duplicates.push(objects[duplicatesIndexes[index]]) | ||
| } | ||
| state.usedDuplicates = new Array(length); | ||
| state.usedDuplicates = new Array(length) | ||
| } | ||
| function inspectNode(object, objects, duplicatesIndexes) { | ||
| var objectKeyList, | ||
| index, | ||
| length; | ||
| function inspectNode (object, objects, duplicatesIndexes) { | ||
| if (object !== null && typeof object === 'object') { | ||
| index = objects.indexOf(object); | ||
| const index = objects.indexOf(object) | ||
| if (index !== -1) { | ||
| if (duplicatesIndexes.indexOf(index) === -1) { | ||
| duplicatesIndexes.push(index); | ||
| duplicatesIndexes.push(index) | ||
| } | ||
| } else { | ||
| objects.push(object); | ||
| objects.push(object) | ||
| if (Array.isArray(object)) { | ||
| for (index = 0, length = object.length; index < length; index += 1) { | ||
| inspectNode(object[index], objects, duplicatesIndexes); | ||
| for (let i = 0, length = object.length; i < length; i += 1) { | ||
| inspectNode(object[i], objects, duplicatesIndexes) | ||
| } | ||
| } else { | ||
| objectKeyList = Object.keys(object); | ||
| const objectKeyList = Object.keys(object) | ||
| for (index = 0, length = objectKeyList.length; index < length; index += 1) { | ||
| inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); | ||
| for (let i = 0, length = objectKeyList.length; i < length; i += 1) { | ||
| inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes) | ||
| } | ||
@@ -972,20 +944,20 @@ } | ||
| function dump(input, options) { | ||
| options = options || {}; | ||
| function dump (input, options) { | ||
| options = options || {} | ||
| var state = new State(options); | ||
| const state = new State(options) | ||
| if (!state.noRefs) getDuplicateReferences(input, state); | ||
| if (!state.noRefs) getDuplicateReferences(input, state) | ||
| var value = input; | ||
| let value = input | ||
| if (state.replacer) { | ||
| value = state.replacer.call({ '': value }, '', value); | ||
| value = state.replacer.call({ '': value }, '', value) | ||
| } | ||
| if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; | ||
| if (writeNode(state, 0, value, true, true)) return state.dump + '\n' | ||
| return ''; | ||
| return '' | ||
| } | ||
| module.exports.dump = dump; | ||
| module.exports.dump = dump |
+23
-27
| // YAML error class. http://stackoverflow.com/questions/8458984 | ||
| // | ||
| 'use strict'; | ||
| 'use strict' | ||
| function formatError (exception, compact) { | ||
| let where = '' | ||
| const message = exception.reason || '(unknown reason)' | ||
| function formatError(exception, compact) { | ||
| var where = '', message = exception.reason || '(unknown reason)'; | ||
| if (!exception.mark) return message | ||
| if (!exception.mark) return message; | ||
| if (exception.mark.name) { | ||
| where += 'in "' + exception.mark.name + '" '; | ||
| where += 'in "' + exception.mark.name + '" ' | ||
| } | ||
| where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; | ||
| where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')' | ||
| if (!compact && exception.mark.snippet) { | ||
| where += '\n\n' + exception.mark.snippet; | ||
| where += '\n\n' + exception.mark.snippet | ||
| } | ||
| return message + ' ' + where; | ||
| return message + ' ' + where | ||
| } | ||
| function YAMLException(reason, mark) { | ||
| function YAMLException (reason, mark) { | ||
| // Super constructor | ||
| Error.call(this); | ||
| Error.call(this) | ||
| this.name = 'YAMLException'; | ||
| this.reason = reason; | ||
| this.mark = mark; | ||
| this.message = formatError(this, false); | ||
| this.name = 'YAMLException' | ||
| this.reason = reason | ||
| this.mark = mark | ||
| this.message = formatError(this, false) | ||
@@ -37,20 +36,17 @@ // Include stack trace in error object | ||
| // Chrome and NodeJS | ||
| Error.captureStackTrace(this, this.constructor); | ||
| Error.captureStackTrace(this, this.constructor) | ||
| } else { | ||
| // FF, IE 10+ and Safari 6+. Fallback for others | ||
| this.stack = (new Error()).stack || ''; | ||
| this.stack = (new Error()).stack || '' | ||
| } | ||
| } | ||
| // Inherit from Error | ||
| YAMLException.prototype = Object.create(Error.prototype); | ||
| YAMLException.prototype.constructor = YAMLException; | ||
| YAMLException.prototype = Object.create(Error.prototype) | ||
| YAMLException.prototype.constructor = YAMLException | ||
| YAMLException.prototype.toString = function toString (compact) { | ||
| return this.name + ': ' + formatError(this, compact) | ||
| } | ||
| YAMLException.prototype.toString = function toString(compact) { | ||
| return this.name + ': ' + formatError(this, compact); | ||
| }; | ||
| module.exports = YAMLException; | ||
| module.exports = YAMLException |
+917
-856
@@ -1,50 +0,47 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| /*eslint-disable max-len,no-use-before-define*/ | ||
| const common = require('./common') | ||
| const YAMLException = require('./exception') | ||
| const makeSnippet = require('./snippet') | ||
| const DEFAULT_SCHEMA = require('./schema/default') | ||
| var common = require('./common'); | ||
| var YAMLException = require('./exception'); | ||
| var makeSnippet = require('./snippet'); | ||
| var DEFAULT_SCHEMA = require('./schema/default'); | ||
| const _hasOwnProperty = Object.prototype.hasOwnProperty | ||
| const CONTEXT_FLOW_IN = 1 | ||
| const CONTEXT_FLOW_OUT = 2 | ||
| const CONTEXT_BLOCK_IN = 3 | ||
| const CONTEXT_BLOCK_OUT = 4 | ||
| var _hasOwnProperty = Object.prototype.hasOwnProperty; | ||
| const CHOMPING_CLIP = 1 | ||
| const CHOMPING_STRIP = 2 | ||
| const CHOMPING_KEEP = 3 | ||
| // eslint-disable-next-line no-control-regex | ||
| const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/ | ||
| const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/ | ||
| // eslint-disable-next-line no-useless-escape | ||
| const PATTERN_FLOW_INDICATORS = /[,\[\]{}]/ | ||
| // eslint-disable-next-line no-useless-escape | ||
| const PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/ | ||
| // eslint-disable-next-line no-useless-escape | ||
| const PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i | ||
| var CONTEXT_FLOW_IN = 1; | ||
| var CONTEXT_FLOW_OUT = 2; | ||
| var CONTEXT_BLOCK_IN = 3; | ||
| var CONTEXT_BLOCK_OUT = 4; | ||
| function _class (obj) { return Object.prototype.toString.call(obj) } | ||
| var CHOMPING_CLIP = 1; | ||
| var CHOMPING_STRIP = 2; | ||
| var CHOMPING_KEEP = 3; | ||
| var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; | ||
| var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; | ||
| var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; | ||
| var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; | ||
| var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; | ||
| function _class(obj) { return Object.prototype.toString.call(obj); } | ||
| function is_EOL(c) { | ||
| return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); | ||
| function isEol (c) { | ||
| return (c === 0x0A/* LF */) || (c === 0x0D/* CR */) | ||
| } | ||
| function is_WHITE_SPACE(c) { | ||
| return (c === 0x09/* Tab */) || (c === 0x20/* Space */); | ||
| function isWhiteSpace (c) { | ||
| return (c === 0x09/* Tab */) || (c === 0x20/* Space */) | ||
| } | ||
| function is_WS_OR_EOL(c) { | ||
| function isWsOrEol (c) { | ||
| return (c === 0x09/* Tab */) || | ||
| (c === 0x20/* Space */) || | ||
| (c === 0x0A/* LF */) || | ||
| (c === 0x0D/* CR */); | ||
| (c === 0x0D/* CR */) | ||
| } | ||
| function is_FLOW_INDICATOR(c) { | ||
| function isFlowIndicator (c) { | ||
| return c === 0x2C/* , */ || | ||
@@ -54,62 +51,61 @@ c === 0x5B/* [ */ || | ||
| c === 0x7B/* { */ || | ||
| c === 0x7D/* } */; | ||
| c === 0x7D/* } */ | ||
| } | ||
| function fromHexCode(c) { | ||
| var lc; | ||
| if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { | ||
| return c - 0x30; | ||
| function fromHexCode (c) { | ||
| if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) { | ||
| return c - 0x30 | ||
| } | ||
| /*eslint-disable no-bitwise*/ | ||
| lc = c | 0x20; | ||
| const lc = c | 0x20 | ||
| if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { | ||
| return lc - 0x61 + 10; | ||
| if ((lc >= 0x61/* a */) && (lc <= 0x66/* f */)) { | ||
| return lc - 0x61 + 10 | ||
| } | ||
| return -1; | ||
| return -1 | ||
| } | ||
| function escapedHexLen(c) { | ||
| if (c === 0x78/* x */) { return 2; } | ||
| if (c === 0x75/* u */) { return 4; } | ||
| if (c === 0x55/* U */) { return 8; } | ||
| return 0; | ||
| function escapedHexLen (c) { | ||
| if (c === 0x78/* x */) { return 2 } | ||
| if (c === 0x75/* u */) { return 4 } | ||
| if (c === 0x55/* U */) { return 8 } | ||
| return 0 | ||
| } | ||
| function fromDecimalCode(c) { | ||
| if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { | ||
| return c - 0x30; | ||
| function fromDecimalCode (c) { | ||
| if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) { | ||
| return c - 0x30 | ||
| } | ||
| return -1; | ||
| return -1 | ||
| } | ||
| function simpleEscapeSequence(c) { | ||
| /* eslint-disable indent */ | ||
| return (c === 0x30/* 0 */) ? '\x00' : | ||
| (c === 0x61/* a */) ? '\x07' : | ||
| (c === 0x62/* b */) ? '\x08' : | ||
| (c === 0x74/* t */) ? '\x09' : | ||
| (c === 0x09/* Tab */) ? '\x09' : | ||
| (c === 0x6E/* n */) ? '\x0A' : | ||
| (c === 0x76/* v */) ? '\x0B' : | ||
| (c === 0x66/* f */) ? '\x0C' : | ||
| (c === 0x72/* r */) ? '\x0D' : | ||
| (c === 0x65/* e */) ? '\x1B' : | ||
| (c === 0x20/* Space */) ? ' ' : | ||
| (c === 0x22/* " */) ? '\x22' : | ||
| (c === 0x2F/* / */) ? '/' : | ||
| (c === 0x5C/* \ */) ? '\x5C' : | ||
| (c === 0x4E/* N */) ? '\x85' : | ||
| (c === 0x5F/* _ */) ? '\xA0' : | ||
| (c === 0x4C/* L */) ? '\u2028' : | ||
| (c === 0x50/* P */) ? '\u2029' : ''; | ||
| function simpleEscapeSequence (c) { | ||
| switch (c) { | ||
| case 0x30/* 0 */: return '\x00' | ||
| case 0x61/* a */: return '\x07' | ||
| case 0x62/* b */: return '\x08' | ||
| case 0x74/* t */: return '\x09' | ||
| case 0x09/* Tab */: return '\x09' | ||
| case 0x6E/* n */: return '\x0A' | ||
| case 0x76/* v */: return '\x0B' | ||
| case 0x66/* f */: return '\x0C' | ||
| case 0x72/* r */: return '\x0D' | ||
| case 0x65/* e */: return '\x1B' | ||
| case 0x20/* Space */: return ' ' | ||
| case 0x22/* " */: return '\x22' | ||
| case 0x2F/* / */: return '/' | ||
| case 0x5C/* \ */: return '\x5C' | ||
| case 0x4E/* N */: return '\x85' | ||
| case 0x5F/* _ */: return '\xA0' | ||
| case 0x4C/* L */: return '\u2028' | ||
| case 0x50/* P */: return '\u2029' | ||
| default: return '' | ||
| } | ||
| } | ||
| function charFromCodepoint(c) { | ||
| function charFromCodepoint (c) { | ||
| if (c <= 0xFFFF) { | ||
| return String.fromCharCode(c); | ||
| return String.fromCharCode(c) | ||
| } | ||
@@ -121,3 +117,3 @@ // Encode UTF-16 surrogate pair | ||
| ((c - 0x010000) & 0x03FF) + 0xDC00 | ||
| ); | ||
| ) | ||
| } | ||
@@ -127,3 +123,3 @@ | ||
| // see https://github.com/nodeca/js-yaml/issues/164 for more details | ||
| function setProperty(object, key, value) { | ||
| function setProperty (object, key, value) { | ||
| // used for this specific key only because Object.defineProperty is slow | ||
@@ -136,43 +132,46 @@ if (key === '__proto__') { | ||
| value: value | ||
| }); | ||
| }) | ||
| } else { | ||
| object[key] = value; | ||
| object[key] = value | ||
| } | ||
| } | ||
| var simpleEscapeCheck = new Array(256); // integer, for fast access | ||
| var simpleEscapeMap = new Array(256); | ||
| for (var i = 0; i < 256; i++) { | ||
| simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; | ||
| simpleEscapeMap[i] = simpleEscapeSequence(i); | ||
| const simpleEscapeCheck = new Array(256) // integer, for fast access | ||
| const simpleEscapeMap = new Array(256) | ||
| for (let i = 0; i < 256; i++) { | ||
| simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0 | ||
| simpleEscapeMap[i] = simpleEscapeSequence(i) | ||
| } | ||
| function State (input, options) { | ||
| this.input = input | ||
| function State(input, options) { | ||
| this.input = input; | ||
| this.filename = options['filename'] || null; | ||
| this.schema = options['schema'] || DEFAULT_SCHEMA; | ||
| this.onWarning = options['onWarning'] || null; | ||
| this.filename = options['filename'] || null | ||
| this.schema = options['schema'] || DEFAULT_SCHEMA | ||
| this.onWarning = options['onWarning'] || null | ||
| // (Hidden) Remove? makes the loader to expect YAML 1.1 documents | ||
| // if such documents have no explicit %YAML directive | ||
| this.legacy = options['legacy'] || false; | ||
| this.legacy = options['legacy'] || false | ||
| this.json = options['json'] || false; | ||
| this.listener = options['listener'] || null; | ||
| this.json = options['json'] || false | ||
| this.listener = options['listener'] || null | ||
| this.maxDepth = typeof options['maxDepth'] === 'number' ? options['maxDepth'] : 100 | ||
| this.maxMergeSeqLength = typeof options['maxMergeSeqLength'] === 'number' ? options['maxMergeSeqLength'] : 20 | ||
| this.implicitTypes = this.schema.compiledImplicit; | ||
| this.typeMap = this.schema.compiledTypeMap; | ||
| this.implicitTypes = this.schema.compiledImplicit | ||
| this.typeMap = this.schema.compiledTypeMap | ||
| this.length = input.length; | ||
| this.position = 0; | ||
| this.line = 0; | ||
| this.lineStart = 0; | ||
| this.lineIndent = 0; | ||
| this.length = input.length | ||
| this.position = 0 | ||
| this.line = 0 | ||
| this.lineStart = 0 | ||
| this.lineIndent = 0 | ||
| this.depth = 0 | ||
| // position of first leading tab in the current line, | ||
| // used to make sure there are no tabs in the indentation | ||
| this.firstTabInLine = -1; | ||
| this.firstTabInLine = -1 | ||
| this.documents = []; | ||
| this.documents = [] | ||
| this.anchorMapTransactions = [] | ||
@@ -187,138 +186,206 @@ /* | ||
| this.kind; | ||
| this.result;*/ | ||
| this.result; */ | ||
| } | ||
| function generateError(state, message) { | ||
| var mark = { | ||
| name: state.filename, | ||
| buffer: state.input.slice(0, -1), // omit trailing \0 | ||
| function generateError (state, message) { | ||
| const mark = { | ||
| name: state.filename, | ||
| buffer: state.input.slice(0, -1), // omit trailing \0 | ||
| position: state.position, | ||
| line: state.line, | ||
| column: state.position - state.lineStart | ||
| }; | ||
| line: state.line, | ||
| column: state.position - state.lineStart | ||
| } | ||
| mark.snippet = makeSnippet(mark); | ||
| mark.snippet = makeSnippet(mark) | ||
| return new YAMLException(message, mark); | ||
| return new YAMLException(message, mark) | ||
| } | ||
| function throwError(state, message) { | ||
| throw generateError(state, message); | ||
| function throwError (state, message) { | ||
| throw generateError(state, message) | ||
| } | ||
| function throwWarning(state, message) { | ||
| function throwWarning (state, message) { | ||
| if (state.onWarning) { | ||
| state.onWarning.call(null, generateError(state, message)); | ||
| state.onWarning.call(null, generateError(state, message)) | ||
| } | ||
| } | ||
| function storeAnchor (state, name, value) { | ||
| const transactions = state.anchorMapTransactions | ||
| var directiveHandlers = { | ||
| if (transactions.length !== 0) { | ||
| const transaction = transactions[transactions.length - 1] | ||
| YAML: function handleYamlDirective(state, name, args) { | ||
| if (!_hasOwnProperty.call(transaction, name)) { | ||
| transaction[name] = { | ||
| existed: _hasOwnProperty.call(state.anchorMap, name), | ||
| value: state.anchorMap[name] | ||
| } | ||
| } | ||
| } | ||
| var match, major, minor; | ||
| state.anchorMap[name] = value | ||
| } | ||
| function beginAnchorTransaction (state) { | ||
| state.anchorMapTransactions.push(Object.create(null)) | ||
| } | ||
| function commitAnchorTransaction (state) { | ||
| const transaction = state.anchorMapTransactions.pop() | ||
| const transactions = state.anchorMapTransactions | ||
| if (transactions.length === 0) return | ||
| const parent = transactions[transactions.length - 1] | ||
| const names = Object.keys(transaction) | ||
| for (let index = 0, length = names.length; index < length; index += 1) { | ||
| const name = names[index] | ||
| if (!_hasOwnProperty.call(parent, name)) { | ||
| parent[name] = transaction[name] | ||
| } | ||
| } | ||
| } | ||
| function rollbackAnchorTransaction (state) { | ||
| const transaction = state.anchorMapTransactions.pop() | ||
| const names = Object.keys(transaction) | ||
| for (let index = names.length - 1; index >= 0; index -= 1) { | ||
| const entry = transaction[names[index]] | ||
| if (entry.existed) { | ||
| state.anchorMap[names[index]] = entry.value | ||
| } else { | ||
| delete state.anchorMap[names[index]] | ||
| } | ||
| } | ||
| } | ||
| function snapshotState (state) { | ||
| return { | ||
| position: state.position, | ||
| line: state.line, | ||
| lineStart: state.lineStart, | ||
| lineIndent: state.lineIndent, | ||
| firstTabInLine: state.firstTabInLine, | ||
| tag: state.tag, | ||
| anchor: state.anchor, | ||
| kind: state.kind, | ||
| result: state.result | ||
| } | ||
| } | ||
| function restoreState (state, snapshot) { | ||
| state.position = snapshot.position | ||
| state.line = snapshot.line | ||
| state.lineStart = snapshot.lineStart | ||
| state.lineIndent = snapshot.lineIndent | ||
| state.firstTabInLine = snapshot.firstTabInLine | ||
| state.tag = snapshot.tag | ||
| state.anchor = snapshot.anchor | ||
| state.kind = snapshot.kind | ||
| state.result = snapshot.result | ||
| } | ||
| const directiveHandlers = { | ||
| YAML: function handleYamlDirective (state, name, args) { | ||
| if (state.version !== null) { | ||
| throwError(state, 'duplication of %YAML directive'); | ||
| throwError(state, 'duplication of %YAML directive') | ||
| } | ||
| if (args.length !== 1) { | ||
| throwError(state, 'YAML directive accepts exactly one argument'); | ||
| throwError(state, 'YAML directive accepts exactly one argument') | ||
| } | ||
| match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); | ||
| const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]) | ||
| if (match === null) { | ||
| throwError(state, 'ill-formed argument of the YAML directive'); | ||
| throwError(state, 'ill-formed argument of the YAML directive') | ||
| } | ||
| major = parseInt(match[1], 10); | ||
| minor = parseInt(match[2], 10); | ||
| const major = parseInt(match[1], 10) | ||
| const minor = parseInt(match[2], 10) | ||
| if (major !== 1) { | ||
| throwError(state, 'unacceptable YAML version of the document'); | ||
| throwError(state, 'unacceptable YAML version of the document') | ||
| } | ||
| state.version = args[0]; | ||
| state.checkLineBreaks = (minor < 2); | ||
| state.version = args[0] | ||
| state.checkLineBreaks = (minor < 2) | ||
| if (minor !== 1 && minor !== 2) { | ||
| throwWarning(state, 'unsupported YAML version of the document'); | ||
| throwWarning(state, 'unsupported YAML version of the document') | ||
| } | ||
| }, | ||
| TAG: function handleTagDirective(state, name, args) { | ||
| TAG: function handleTagDirective (state, name, args) { | ||
| let prefix | ||
| var handle, prefix; | ||
| if (args.length !== 2) { | ||
| throwError(state, 'TAG directive accepts exactly two arguments'); | ||
| throwError(state, 'TAG directive accepts exactly two arguments') | ||
| } | ||
| handle = args[0]; | ||
| prefix = args[1]; | ||
| const handle = args[0] | ||
| prefix = args[1] | ||
| if (!PATTERN_TAG_HANDLE.test(handle)) { | ||
| throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); | ||
| throwError(state, 'ill-formed tag handle (first argument) of the TAG directive') | ||
| } | ||
| if (_hasOwnProperty.call(state.tagMap, handle)) { | ||
| throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); | ||
| throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle') | ||
| } | ||
| if (!PATTERN_TAG_URI.test(prefix)) { | ||
| throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); | ||
| throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive') | ||
| } | ||
| try { | ||
| prefix = decodeURIComponent(prefix); | ||
| prefix = decodeURIComponent(prefix) | ||
| } catch (err) { | ||
| throwError(state, 'tag prefix is malformed: ' + prefix); | ||
| throwError(state, 'tag prefix is malformed: ' + prefix) | ||
| } | ||
| state.tagMap[handle] = prefix; | ||
| state.tagMap[handle] = prefix | ||
| } | ||
| }; | ||
| } | ||
| function captureSegment(state, start, end, checkJson) { | ||
| var _position, _length, _character, _result; | ||
| function captureSegment (state, start, end, checkJson) { | ||
| if (start < end) { | ||
| _result = state.input.slice(start, end); | ||
| const _result = state.input.slice(start, end) | ||
| if (checkJson) { | ||
| for (_position = 0, _length = _result.length; _position < _length; _position += 1) { | ||
| _character = _result.charCodeAt(_position); | ||
| for (let _position = 0, _length = _result.length; _position < _length; _position += 1) { | ||
| const _character = _result.charCodeAt(_position) | ||
| if (!(_character === 0x09 || | ||
| (0x20 <= _character && _character <= 0x10FFFF))) { | ||
| throwError(state, 'expected valid JSON character'); | ||
| (_character >= 0x20 && _character <= 0x10FFFF))) { | ||
| throwError(state, 'expected valid JSON character') | ||
| } | ||
| } | ||
| } else if (PATTERN_NON_PRINTABLE.test(_result)) { | ||
| throwError(state, 'the stream contains non-printable characters'); | ||
| throwError(state, 'the stream contains non-printable characters') | ||
| } | ||
| state.result += _result; | ||
| state.result += _result | ||
| } | ||
| } | ||
| function mergeMappings(state, destination, source, overridableKeys) { | ||
| var sourceKeys, key, index, quantity; | ||
| function mergeMappings (state, destination, source, overridableKeys) { | ||
| if (!common.isObject(source)) { | ||
| throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); | ||
| throwError(state, 'cannot merge mappings; the provided source object is unacceptable') | ||
| } | ||
| sourceKeys = Object.keys(source); | ||
| const sourceKeys = Object.keys(source) | ||
| for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { | ||
| key = sourceKeys[index]; | ||
| for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { | ||
| const key = sourceKeys[index] | ||
| if (!_hasOwnProperty.call(destination, key)) { | ||
| setProperty(destination, key, source[key]); | ||
| overridableKeys[key] = true; | ||
| setProperty(destination, key, source[key]) | ||
| overridableKeys[key] = true | ||
| } | ||
@@ -328,7 +395,4 @@ } | ||
| function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, | ||
| function storeMappingPair (state, _result, overridableKeys, keyTag, keyNode, valueNode, | ||
| startLine, startLineStart, startPos) { | ||
| var index, quantity; | ||
| // The output is a plain object here, so keys can only be strings. | ||
@@ -338,11 +402,11 @@ // We need to convert keyNode to a string, but doing so can hang the process | ||
| if (Array.isArray(keyNode)) { | ||
| keyNode = Array.prototype.slice.call(keyNode); | ||
| keyNode = Array.prototype.slice.call(keyNode) | ||
| for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { | ||
| for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) { | ||
| if (Array.isArray(keyNode[index])) { | ||
| throwError(state, 'nested arrays are not supported inside keys'); | ||
| throwError(state, 'nested arrays are not supported inside keys') | ||
| } | ||
| if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { | ||
| keyNode[index] = '[object Object]'; | ||
| keyNode[index] = '[object Object]' | ||
| } | ||
@@ -356,10 +420,9 @@ } | ||
| if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { | ||
| keyNode = '[object Object]'; | ||
| keyNode = '[object Object]' | ||
| } | ||
| keyNode = String(keyNode) | ||
| keyNode = String(keyNode); | ||
| if (_result === null) { | ||
| _result = {}; | ||
| _result = {} | ||
| } | ||
@@ -369,7 +432,16 @@ | ||
| if (Array.isArray(valueNode)) { | ||
| for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { | ||
| mergeMappings(state, _result, valueNode[index], overridableKeys); | ||
| if (valueNode.length > state.maxMergeSeqLength) { | ||
| throwError(state, 'merge sequence length exceeded maxMergeSeqLength (' + state.maxMergeSeqLength + ')') | ||
| } | ||
| const seen = new Set() | ||
| for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) { | ||
| const src = valueNode[index] | ||
| // Existing keys are not overridden on merge, so dedupe sources to | ||
| // avoid redundant work on repeated aliases. | ||
| if (seen.has(src)) continue | ||
| seen.add(src) | ||
| mergeMappings(state, _result, src, overridableKeys) | ||
| } | ||
| } else { | ||
| mergeMappings(state, _result, valueNode, overridableKeys); | ||
| mergeMappings(state, _result, valueNode, overridableKeys) | ||
| } | ||
@@ -380,46 +452,44 @@ } else { | ||
| _hasOwnProperty.call(_result, keyNode)) { | ||
| state.line = startLine || state.line; | ||
| state.lineStart = startLineStart || state.lineStart; | ||
| state.position = startPos || state.position; | ||
| throwError(state, 'duplicated mapping key'); | ||
| state.line = startLine || state.line | ||
| state.lineStart = startLineStart || state.lineStart | ||
| state.position = startPos || state.position | ||
| throwError(state, 'duplicated mapping key') | ||
| } | ||
| setProperty(_result, keyNode, valueNode); | ||
| delete overridableKeys[keyNode]; | ||
| setProperty(_result, keyNode, valueNode) | ||
| delete overridableKeys[keyNode] | ||
| } | ||
| return _result; | ||
| return _result | ||
| } | ||
| function readLineBreak(state) { | ||
| var ch; | ||
| function readLineBreak (state) { | ||
| const ch = state.input.charCodeAt(state.position) | ||
| ch = state.input.charCodeAt(state.position); | ||
| if (ch === 0x0A/* LF */) { | ||
| state.position++; | ||
| state.position++ | ||
| } else if (ch === 0x0D/* CR */) { | ||
| state.position++; | ||
| state.position++ | ||
| if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { | ||
| state.position++; | ||
| state.position++ | ||
| } | ||
| } else { | ||
| throwError(state, 'a line break is expected'); | ||
| throwError(state, 'a line break is expected') | ||
| } | ||
| state.line += 1; | ||
| state.lineStart = state.position; | ||
| state.firstTabInLine = -1; | ||
| state.line += 1 | ||
| state.lineStart = state.position | ||
| state.firstTabInLine = -1 | ||
| } | ||
| function skipSeparationSpace(state, allowComments, checkIndent) { | ||
| var lineBreaks = 0, | ||
| ch = state.input.charCodeAt(state.position); | ||
| function skipSeparationSpace (state, allowComments, checkIndent) { | ||
| let lineBreaks = 0 | ||
| let ch = state.input.charCodeAt(state.position) | ||
| while (ch !== 0) { | ||
| while (is_WHITE_SPACE(ch)) { | ||
| while (isWhiteSpace(ch)) { | ||
| if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { | ||
| state.firstTabInLine = state.position; | ||
| state.firstTabInLine = state.position | ||
| } | ||
| ch = state.input.charCodeAt(++state.position); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
@@ -429,19 +499,19 @@ | ||
| do { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0) | ||
| } | ||
| if (is_EOL(ch)) { | ||
| readLineBreak(state); | ||
| if (isEol(ch)) { | ||
| readLineBreak(state) | ||
| ch = state.input.charCodeAt(state.position); | ||
| lineBreaks++; | ||
| state.lineIndent = 0; | ||
| ch = state.input.charCodeAt(state.position) | ||
| lineBreaks++ | ||
| state.lineIndent = 0 | ||
| while (ch === 0x20/* Space */) { | ||
| state.lineIndent++; | ||
| ch = state.input.charCodeAt(++state.position); | ||
| state.lineIndent++ | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| } else { | ||
| break; | ||
| break | ||
| } | ||
@@ -451,14 +521,12 @@ } | ||
| if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { | ||
| throwWarning(state, 'deficient indentation'); | ||
| throwWarning(state, 'deficient indentation') | ||
| } | ||
| return lineBreaks; | ||
| return lineBreaks | ||
| } | ||
| function testDocumentSeparator(state) { | ||
| var _position = state.position, | ||
| ch; | ||
| function testDocumentSeparator (state) { | ||
| let _position = state.position | ||
| let ch = state.input.charCodeAt(_position) | ||
| ch = state.input.charCodeAt(_position); | ||
| // Condition state.position === state.lineStart is tested | ||
@@ -469,105 +537,97 @@ // in parent on each call, for efficiency. No needs to test here again. | ||
| ch === state.input.charCodeAt(_position + 2)) { | ||
| _position += 3 | ||
| _position += 3; | ||
| ch = state.input.charCodeAt(_position) | ||
| ch = state.input.charCodeAt(_position); | ||
| if (ch === 0 || is_WS_OR_EOL(ch)) { | ||
| return true; | ||
| if (ch === 0 || isWsOrEol(ch)) { | ||
| return true | ||
| } | ||
| } | ||
| return false; | ||
| return false | ||
| } | ||
| function writeFoldedLines(state, count) { | ||
| function writeFoldedLines (state, count) { | ||
| if (count === 1) { | ||
| state.result += ' '; | ||
| state.result += ' ' | ||
| } else if (count > 1) { | ||
| state.result += common.repeat('\n', count - 1); | ||
| state.result += common.repeat('\n', count - 1) | ||
| } | ||
| } | ||
| function readPlainScalar (state, nodeIndent, withinFlowCollection) { | ||
| let captureStart | ||
| let captureEnd | ||
| let hasPendingContent | ||
| let _line | ||
| let _lineStart | ||
| let _lineIndent | ||
| const _kind = state.kind | ||
| const _result = state.result | ||
| function readPlainScalar(state, nodeIndent, withinFlowCollection) { | ||
| var preceding, | ||
| following, | ||
| captureStart, | ||
| captureEnd, | ||
| hasPendingContent, | ||
| _line, | ||
| _lineStart, | ||
| _lineIndent, | ||
| _kind = state.kind, | ||
| _result = state.result, | ||
| ch; | ||
| let ch = state.input.charCodeAt(state.position) | ||
| ch = state.input.charCodeAt(state.position); | ||
| if (is_WS_OR_EOL(ch) || | ||
| is_FLOW_INDICATOR(ch) || | ||
| ch === 0x23/* # */ || | ||
| ch === 0x26/* & */ || | ||
| ch === 0x2A/* * */ || | ||
| ch === 0x21/* ! */ || | ||
| ch === 0x7C/* | */ || | ||
| ch === 0x3E/* > */ || | ||
| ch === 0x27/* ' */ || | ||
| ch === 0x22/* " */ || | ||
| ch === 0x25/* % */ || | ||
| ch === 0x40/* @ */ || | ||
| if (isWsOrEol(ch) || | ||
| isFlowIndicator(ch) || | ||
| ch === 0x23/* # */ || | ||
| ch === 0x26/* & */ || | ||
| ch === 0x2A/* * */ || | ||
| ch === 0x21/* ! */ || | ||
| ch === 0x7C/* | */ || | ||
| ch === 0x3E/* > */ || | ||
| ch === 0x27/* ' */ || | ||
| ch === 0x22/* " */ || | ||
| ch === 0x25/* % */ || | ||
| ch === 0x40/* @ */ || | ||
| ch === 0x60/* ` */) { | ||
| return false; | ||
| return false | ||
| } | ||
| if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { | ||
| following = state.input.charCodeAt(state.position + 1); | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| if (is_WS_OR_EOL(following) || | ||
| withinFlowCollection && is_FLOW_INDICATOR(following)) { | ||
| return false; | ||
| if (isWsOrEol(following) || | ||
| (withinFlowCollection && isFlowIndicator(following))) { | ||
| return false | ||
| } | ||
| } | ||
| state.kind = 'scalar'; | ||
| state.result = ''; | ||
| captureStart = captureEnd = state.position; | ||
| hasPendingContent = false; | ||
| state.kind = 'scalar' | ||
| state.result = '' | ||
| captureStart = captureEnd = state.position | ||
| hasPendingContent = false | ||
| while (ch !== 0) { | ||
| if (ch === 0x3A/* : */) { | ||
| following = state.input.charCodeAt(state.position + 1); | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| if (is_WS_OR_EOL(following) || | ||
| withinFlowCollection && is_FLOW_INDICATOR(following)) { | ||
| break; | ||
| if (isWsOrEol(following) || | ||
| (withinFlowCollection && isFlowIndicator(following))) { | ||
| break | ||
| } | ||
| } else if (ch === 0x23/* # */) { | ||
| preceding = state.input.charCodeAt(state.position - 1); | ||
| const preceding = state.input.charCodeAt(state.position - 1) | ||
| if (is_WS_OR_EOL(preceding)) { | ||
| break; | ||
| if (isWsOrEol(preceding)) { | ||
| break | ||
| } | ||
| } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || | ||
| withinFlowCollection && is_FLOW_INDICATOR(ch)) { | ||
| break; | ||
| (withinFlowCollection && isFlowIndicator(ch))) { | ||
| break | ||
| } else if (isEol(ch)) { | ||
| _line = state.line | ||
| _lineStart = state.lineStart | ||
| _lineIndent = state.lineIndent | ||
| skipSeparationSpace(state, false, -1) | ||
| } else if (is_EOL(ch)) { | ||
| _line = state.line; | ||
| _lineStart = state.lineStart; | ||
| _lineIndent = state.lineIndent; | ||
| skipSeparationSpace(state, false, -1); | ||
| if (state.lineIndent >= nodeIndent) { | ||
| hasPendingContent = true; | ||
| ch = state.input.charCodeAt(state.position); | ||
| continue; | ||
| hasPendingContent = true | ||
| ch = state.input.charCodeAt(state.position) | ||
| continue | ||
| } else { | ||
| state.position = captureEnd; | ||
| state.line = _line; | ||
| state.lineStart = _lineStart; | ||
| state.lineIndent = _lineIndent; | ||
| break; | ||
| state.position = captureEnd | ||
| state.line = _line | ||
| state.lineStart = _lineStart | ||
| state.lineIndent = _lineIndent | ||
| break | ||
| } | ||
@@ -577,319 +637,304 @@ } | ||
| if (hasPendingContent) { | ||
| captureSegment(state, captureStart, captureEnd, false); | ||
| writeFoldedLines(state, state.line - _line); | ||
| captureStart = captureEnd = state.position; | ||
| hasPendingContent = false; | ||
| captureSegment(state, captureStart, captureEnd, false) | ||
| writeFoldedLines(state, state.line - _line) | ||
| captureStart = captureEnd = state.position | ||
| hasPendingContent = false | ||
| } | ||
| if (!is_WHITE_SPACE(ch)) { | ||
| captureEnd = state.position + 1; | ||
| if (!isWhiteSpace(ch)) { | ||
| captureEnd = state.position + 1 | ||
| } | ||
| ch = state.input.charCodeAt(++state.position); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| captureSegment(state, captureStart, captureEnd, false); | ||
| captureSegment(state, captureStart, captureEnd, false) | ||
| if (state.result) { | ||
| return true; | ||
| return true | ||
| } | ||
| state.kind = _kind; | ||
| state.result = _result; | ||
| return false; | ||
| state.kind = _kind | ||
| state.result = _result | ||
| return false | ||
| } | ||
| function readSingleQuotedScalar(state, nodeIndent) { | ||
| var ch, | ||
| captureStart, captureEnd; | ||
| function readSingleQuotedScalar (state, nodeIndent) { | ||
| let captureStart | ||
| let captureEnd | ||
| ch = state.input.charCodeAt(state.position); | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch !== 0x27/* ' */) { | ||
| return false; | ||
| return false | ||
| } | ||
| state.kind = 'scalar'; | ||
| state.result = ''; | ||
| state.position++; | ||
| captureStart = captureEnd = state.position; | ||
| state.kind = 'scalar' | ||
| state.result = '' | ||
| state.position++ | ||
| captureStart = captureEnd = state.position | ||
| while ((ch = state.input.charCodeAt(state.position)) !== 0) { | ||
| if (ch === 0x27/* ' */) { | ||
| captureSegment(state, captureStart, state.position, true); | ||
| ch = state.input.charCodeAt(++state.position); | ||
| captureSegment(state, captureStart, state.position, true) | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (ch === 0x27/* ' */) { | ||
| captureStart = state.position; | ||
| state.position++; | ||
| captureEnd = state.position; | ||
| captureStart = state.position | ||
| state.position++ | ||
| captureEnd = state.position | ||
| } else { | ||
| return true; | ||
| return true | ||
| } | ||
| } else if (is_EOL(ch)) { | ||
| captureSegment(state, captureStart, captureEnd, true); | ||
| writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); | ||
| captureStart = captureEnd = state.position; | ||
| } else if (isEol(ch)) { | ||
| captureSegment(state, captureStart, captureEnd, true) | ||
| writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)) | ||
| captureStart = captureEnd = state.position | ||
| } else if (state.position === state.lineStart && testDocumentSeparator(state)) { | ||
| throwError(state, 'unexpected end of the document within a single quoted scalar'); | ||
| throwError(state, 'unexpected end of the document within a single quoted scalar') | ||
| } else { | ||
| state.position++; | ||
| captureEnd = state.position; | ||
| state.position++ | ||
| if (!isWhiteSpace(ch)) { | ||
| captureEnd = state.position | ||
| } | ||
| } | ||
| } | ||
| throwError(state, 'unexpected end of the stream within a single quoted scalar'); | ||
| throwError(state, 'unexpected end of the stream within a single quoted scalar') | ||
| } | ||
| function readDoubleQuotedScalar(state, nodeIndent) { | ||
| var captureStart, | ||
| captureEnd, | ||
| hexLength, | ||
| hexResult, | ||
| tmp, | ||
| ch; | ||
| function readDoubleQuotedScalar (state, nodeIndent) { | ||
| let captureStart | ||
| let captureEnd | ||
| let tmp | ||
| ch = state.input.charCodeAt(state.position); | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch !== 0x22/* " */) { | ||
| return false; | ||
| return false | ||
| } | ||
| state.kind = 'scalar'; | ||
| state.result = ''; | ||
| state.position++; | ||
| captureStart = captureEnd = state.position; | ||
| state.kind = 'scalar' | ||
| state.result = '' | ||
| state.position++ | ||
| captureStart = captureEnd = state.position | ||
| while ((ch = state.input.charCodeAt(state.position)) !== 0) { | ||
| if (ch === 0x22/* " */) { | ||
| captureSegment(state, captureStart, state.position, true); | ||
| state.position++; | ||
| return true; | ||
| captureSegment(state, captureStart, state.position, true) | ||
| state.position++ | ||
| return true | ||
| } else if (ch === 0x5C/* \ */) { | ||
| captureSegment(state, captureStart, state.position, true); | ||
| ch = state.input.charCodeAt(++state.position); | ||
| captureSegment(state, captureStart, state.position, true) | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (is_EOL(ch)) { | ||
| skipSeparationSpace(state, false, nodeIndent); | ||
| if (isEol(ch)) { | ||
| skipSeparationSpace(state, false, nodeIndent) | ||
| // TODO: rework to inline fn with no type cast? | ||
| } else if (ch < 256 && simpleEscapeCheck[ch]) { | ||
| state.result += simpleEscapeMap[ch]; | ||
| state.position++; | ||
| state.result += simpleEscapeMap[ch] | ||
| state.position++ | ||
| } else if ((tmp = escapedHexLen(ch)) > 0) { | ||
| hexLength = tmp; | ||
| hexResult = 0; | ||
| let hexLength = tmp | ||
| let hexResult = 0 | ||
| for (; hexLength > 0; hexLength--) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if ((tmp = fromHexCode(ch)) >= 0) { | ||
| hexResult = (hexResult << 4) + tmp; | ||
| hexResult = (hexResult << 4) + tmp | ||
| } else { | ||
| throwError(state, 'expected hexadecimal character'); | ||
| throwError(state, 'expected hexadecimal character') | ||
| } | ||
| } | ||
| state.result += charFromCodepoint(hexResult); | ||
| state.result += charFromCodepoint(hexResult) | ||
| state.position++; | ||
| state.position++ | ||
| } else { | ||
| throwError(state, 'unknown escape sequence'); | ||
| throwError(state, 'unknown escape sequence') | ||
| } | ||
| captureStart = captureEnd = state.position; | ||
| } else if (is_EOL(ch)) { | ||
| captureSegment(state, captureStart, captureEnd, true); | ||
| writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); | ||
| captureStart = captureEnd = state.position; | ||
| captureStart = captureEnd = state.position | ||
| } else if (isEol(ch)) { | ||
| captureSegment(state, captureStart, captureEnd, true) | ||
| writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)) | ||
| captureStart = captureEnd = state.position | ||
| } else if (state.position === state.lineStart && testDocumentSeparator(state)) { | ||
| throwError(state, 'unexpected end of the document within a double quoted scalar'); | ||
| throwError(state, 'unexpected end of the document within a double quoted scalar') | ||
| } else { | ||
| state.position++; | ||
| captureEnd = state.position; | ||
| state.position++ | ||
| if (!isWhiteSpace(ch)) { | ||
| captureEnd = state.position | ||
| } | ||
| } | ||
| } | ||
| throwError(state, 'unexpected end of the stream within a double quoted scalar'); | ||
| throwError(state, 'unexpected end of the stream within a double quoted scalar') | ||
| } | ||
| function readFlowCollection(state, nodeIndent) { | ||
| var readNext = true, | ||
| _line, | ||
| _lineStart, | ||
| _pos, | ||
| _tag = state.tag, | ||
| _result, | ||
| _anchor = state.anchor, | ||
| following, | ||
| terminator, | ||
| isPair, | ||
| isExplicitPair, | ||
| isMapping, | ||
| overridableKeys = Object.create(null), | ||
| keyNode, | ||
| keyTag, | ||
| valueNode, | ||
| ch; | ||
| function readFlowCollection (state, nodeIndent) { | ||
| let readNext = true | ||
| let _line | ||
| let _lineStart | ||
| let _pos | ||
| const _tag = state.tag | ||
| let _result | ||
| const _anchor = state.anchor | ||
| let terminator | ||
| let isPair | ||
| let isExplicitPair | ||
| let isMapping | ||
| const overridableKeys = Object.create(null) | ||
| let keyNode | ||
| let keyTag | ||
| let valueNode | ||
| ch = state.input.charCodeAt(state.position); | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch === 0x5B/* [ */) { | ||
| terminator = 0x5D;/* ] */ | ||
| isMapping = false; | ||
| _result = []; | ||
| terminator = 0x5D/* ] */ | ||
| isMapping = false | ||
| _result = [] | ||
| } else if (ch === 0x7B/* { */) { | ||
| terminator = 0x7D;/* } */ | ||
| isMapping = true; | ||
| _result = {}; | ||
| terminator = 0x7D/* } */ | ||
| isMapping = true | ||
| _result = {} | ||
| } else { | ||
| return false; | ||
| return false | ||
| } | ||
| if (state.anchor !== null) { | ||
| state.anchorMap[state.anchor] = _result; | ||
| storeAnchor(state, state.anchor, _result) | ||
| } | ||
| ch = state.input.charCodeAt(++state.position); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| while (ch !== 0) { | ||
| skipSeparationSpace(state, true, nodeIndent); | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| ch = state.input.charCodeAt(state.position); | ||
| ch = state.input.charCodeAt(state.position) | ||
| if (ch === terminator) { | ||
| state.position++; | ||
| state.tag = _tag; | ||
| state.anchor = _anchor; | ||
| state.kind = isMapping ? 'mapping' : 'sequence'; | ||
| state.result = _result; | ||
| return true; | ||
| state.position++ | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| state.kind = isMapping ? 'mapping' : 'sequence' | ||
| state.result = _result | ||
| return true | ||
| } else if (!readNext) { | ||
| throwError(state, 'missed comma between flow collection entries'); | ||
| throwError(state, 'missed comma between flow collection entries') | ||
| } else if (ch === 0x2C/* , */) { | ||
| // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 | ||
| throwError(state, "expected the node content, but found ','"); | ||
| throwError(state, "expected the node content, but found ','") | ||
| } | ||
| keyTag = keyNode = valueNode = null; | ||
| isPair = isExplicitPair = false; | ||
| keyTag = keyNode = valueNode = null | ||
| isPair = isExplicitPair = false | ||
| if (ch === 0x3F/* ? */) { | ||
| following = state.input.charCodeAt(state.position + 1); | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| if (is_WS_OR_EOL(following)) { | ||
| isPair = isExplicitPair = true; | ||
| state.position++; | ||
| skipSeparationSpace(state, true, nodeIndent); | ||
| if (isWsOrEol(following)) { | ||
| isPair = isExplicitPair = true | ||
| state.position++ | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| } | ||
| } | ||
| _line = state.line; // Save the current line. | ||
| _lineStart = state.lineStart; | ||
| _pos = state.position; | ||
| composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); | ||
| keyTag = state.tag; | ||
| keyNode = state.result; | ||
| skipSeparationSpace(state, true, nodeIndent); | ||
| _line = state.line // Save the current line. | ||
| _lineStart = state.lineStart | ||
| _pos = state.position | ||
| composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true) | ||
| keyTag = state.tag | ||
| keyNode = state.result | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| ch = state.input.charCodeAt(state.position); | ||
| ch = state.input.charCodeAt(state.position) | ||
| if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { | ||
| isPair = true; | ||
| ch = state.input.charCodeAt(++state.position); | ||
| skipSeparationSpace(state, true, nodeIndent); | ||
| composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); | ||
| valueNode = state.result; | ||
| isPair = true | ||
| ch = state.input.charCodeAt(++state.position) | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true) | ||
| valueNode = state.result | ||
| } | ||
| if (isMapping) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos) | ||
| } else if (isPair) { | ||
| _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); | ||
| _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)) | ||
| } else { | ||
| _result.push(keyNode); | ||
| _result.push(keyNode) | ||
| } | ||
| skipSeparationSpace(state, true, nodeIndent); | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| ch = state.input.charCodeAt(state.position); | ||
| ch = state.input.charCodeAt(state.position) | ||
| if (ch === 0x2C/* , */) { | ||
| readNext = true; | ||
| ch = state.input.charCodeAt(++state.position); | ||
| readNext = true | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } else { | ||
| readNext = false; | ||
| readNext = false | ||
| } | ||
| } | ||
| throwError(state, 'unexpected end of the stream within a flow collection'); | ||
| throwError(state, 'unexpected end of the stream within a flow collection') | ||
| } | ||
| function readBlockScalar(state, nodeIndent) { | ||
| var captureStart, | ||
| folding, | ||
| chomping = CHOMPING_CLIP, | ||
| didReadContent = false, | ||
| detectedIndent = false, | ||
| textIndent = nodeIndent, | ||
| emptyLines = 0, | ||
| atMoreIndented = false, | ||
| tmp, | ||
| ch; | ||
| function readBlockScalar (state, nodeIndent) { | ||
| let folding | ||
| let chomping = CHOMPING_CLIP | ||
| let didReadContent = false | ||
| let detectedIndent = false | ||
| let textIndent = nodeIndent | ||
| let emptyLines = 0 | ||
| let atMoreIndented = false | ||
| let tmp | ||
| ch = state.input.charCodeAt(state.position); | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch === 0x7C/* | */) { | ||
| folding = false; | ||
| folding = false | ||
| } else if (ch === 0x3E/* > */) { | ||
| folding = true; | ||
| folding = true | ||
| } else { | ||
| return false; | ||
| return false | ||
| } | ||
| state.kind = 'scalar'; | ||
| state.result = ''; | ||
| state.kind = 'scalar' | ||
| state.result = '' | ||
| while (ch !== 0) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { | ||
| if (CHOMPING_CLIP === chomping) { | ||
| chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; | ||
| chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP | ||
| } else { | ||
| throwError(state, 'repeat of a chomping mode identifier'); | ||
| throwError(state, 'repeat of a chomping mode identifier') | ||
| } | ||
| } else if ((tmp = fromDecimalCode(ch)) >= 0) { | ||
| if (tmp === 0) { | ||
| throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); | ||
| throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one') | ||
| } else if (!detectedIndent) { | ||
| textIndent = nodeIndent + tmp - 1; | ||
| detectedIndent = true; | ||
| textIndent = nodeIndent + tmp - 1 | ||
| detectedIndent = true | ||
| } else { | ||
| throwError(state, 'repeat of an indentation width identifier'); | ||
| throwError(state, 'repeat of an indentation width identifier') | ||
| } | ||
| } else { | ||
| break; | ||
| break | ||
| } | ||
| } | ||
| if (is_WHITE_SPACE(ch)) { | ||
| do { ch = state.input.charCodeAt(++state.position); } | ||
| while (is_WHITE_SPACE(ch)); | ||
| if (isWhiteSpace(ch)) { | ||
| do { ch = state.input.charCodeAt(++state.position) } | ||
| while (isWhiteSpace(ch)) | ||
| if (ch === 0x23/* # */) { | ||
| do { ch = state.input.charCodeAt(++state.position); } | ||
| while (!is_EOL(ch) && (ch !== 0)); | ||
| do { ch = state.input.charCodeAt(++state.position) } | ||
| while (!isEol(ch) && (ch !== 0)) | ||
| } | ||
@@ -899,31 +944,35 @@ } | ||
| while (ch !== 0) { | ||
| readLineBreak(state); | ||
| state.lineIndent = 0; | ||
| readLineBreak(state) | ||
| state.lineIndent = 0 | ||
| ch = state.input.charCodeAt(state.position); | ||
| ch = state.input.charCodeAt(state.position) | ||
| // eslint-disable-next-line no-unmodified-loop-condition | ||
| while ((!detectedIndent || state.lineIndent < textIndent) && | ||
| (ch === 0x20/* Space */)) { | ||
| state.lineIndent++; | ||
| ch = state.input.charCodeAt(++state.position); | ||
| state.lineIndent++ | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (!detectedIndent && state.lineIndent > textIndent) { | ||
| textIndent = state.lineIndent; | ||
| textIndent = state.lineIndent | ||
| } | ||
| if (is_EOL(ch)) { | ||
| emptyLines++; | ||
| continue; | ||
| if (isEol(ch)) { | ||
| emptyLines++ | ||
| continue | ||
| } | ||
| if (!detectedIndent && textIndent === 0) { | ||
| throwError(state, 'missing indentation for block scalar') | ||
| } | ||
| // End of the scalar. | ||
| if (state.lineIndent < textIndent) { | ||
| // Perform the chomping. | ||
| if (chomping === CHOMPING_KEEP) { | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) | ||
| } else if (chomping === CHOMPING_CLIP) { | ||
| if (didReadContent) { // i.e. only if the scalar is not empty. | ||
| state.result += '\n'; | ||
| state.result += '\n' | ||
| } | ||
@@ -933,3 +982,3 @@ } | ||
| // Break this `while` cycle and go to the funciton's epilogue. | ||
| break; | ||
| break | ||
| } | ||
@@ -939,13 +988,12 @@ | ||
| if (folding) { | ||
| // Lines starting with white space characters (more-indented lines) are not folded. | ||
| if (is_WHITE_SPACE(ch)) { | ||
| atMoreIndented = true; | ||
| if (isWhiteSpace(ch)) { | ||
| atMoreIndented = true | ||
| // except for the first content line (cf. Example 8.1) | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) | ||
| // End of more-indented block. | ||
| } else if (atMoreIndented) { | ||
| atMoreIndented = false; | ||
| state.result += common.repeat('\n', emptyLines + 1); | ||
| atMoreIndented = false | ||
| state.result += common.repeat('\n', emptyLines + 1) | ||
@@ -955,3 +1003,3 @@ // Just one line break - perceive as the same line. | ||
| if (didReadContent) { // i.e. only if we have already read some scalar content. | ||
| state.result += ' '; | ||
| state.result += ' ' | ||
| } | ||
@@ -961,3 +1009,3 @@ | ||
| } else { | ||
| state.result += common.repeat('\n', emptyLines); | ||
| state.result += common.repeat('\n', emptyLines) | ||
| } | ||
@@ -968,77 +1016,74 @@ | ||
| // Keep all line breaks except the header line break. | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) | ||
| } | ||
| didReadContent = true; | ||
| detectedIndent = true; | ||
| emptyLines = 0; | ||
| captureStart = state.position; | ||
| didReadContent = true | ||
| detectedIndent = true | ||
| emptyLines = 0 | ||
| const captureStart = state.position | ||
| while (!is_EOL(ch) && (ch !== 0)) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| while (!isEol(ch) && (ch !== 0)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| captureSegment(state, captureStart, state.position, false); | ||
| captureSegment(state, captureStart, state.position, false) | ||
| } | ||
| return true; | ||
| return true | ||
| } | ||
| function readBlockSequence(state, nodeIndent) { | ||
| var _line, | ||
| _tag = state.tag, | ||
| _anchor = state.anchor, | ||
| _result = [], | ||
| following, | ||
| detected = false, | ||
| ch; | ||
| function readBlockSequence (state, nodeIndent) { | ||
| const _tag = state.tag | ||
| const _anchor = state.anchor | ||
| const _result = [] | ||
| let detected = false | ||
| // there is a leading tab before this token, so it can't be a block sequence/mapping; | ||
| // it can still be flow sequence/mapping or a scalar | ||
| if (state.firstTabInLine !== -1) return false; | ||
| if (state.firstTabInLine !== -1) return false | ||
| if (state.anchor !== null) { | ||
| state.anchorMap[state.anchor] = _result; | ||
| storeAnchor(state, state.anchor, _result) | ||
| } | ||
| ch = state.input.charCodeAt(state.position); | ||
| let ch = state.input.charCodeAt(state.position) | ||
| while (ch !== 0) { | ||
| if (state.firstTabInLine !== -1) { | ||
| state.position = state.firstTabInLine; | ||
| throwError(state, 'tab characters must not be used in indentation'); | ||
| state.position = state.firstTabInLine | ||
| throwError(state, 'tab characters must not be used in indentation') | ||
| } | ||
| if (ch !== 0x2D/* - */) { | ||
| break; | ||
| break | ||
| } | ||
| following = state.input.charCodeAt(state.position + 1); | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| if (!is_WS_OR_EOL(following)) { | ||
| break; | ||
| if (!isWsOrEol(following)) { | ||
| break | ||
| } | ||
| detected = true; | ||
| state.position++; | ||
| detected = true | ||
| state.position++ | ||
| if (skipSeparationSpace(state, true, -1)) { | ||
| if (state.lineIndent <= nodeIndent) { | ||
| _result.push(null); | ||
| ch = state.input.charCodeAt(state.position); | ||
| continue; | ||
| _result.push(null) | ||
| ch = state.input.charCodeAt(state.position) | ||
| continue | ||
| } | ||
| } | ||
| _line = state.line; | ||
| composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); | ||
| _result.push(state.result); | ||
| skipSeparationSpace(state, true, -1); | ||
| const _line = state.line | ||
| composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true) | ||
| _result.push(state.result) | ||
| skipSeparationSpace(state, true, -1) | ||
| ch = state.input.charCodeAt(state.position); | ||
| ch = state.input.charCodeAt(state.position) | ||
| if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { | ||
| throwError(state, 'bad indentation of a sequence entry'); | ||
| throwError(state, 'bad indentation of a sequence entry') | ||
| } else if (state.lineIndent < nodeIndent) { | ||
| break; | ||
| break | ||
| } | ||
@@ -1048,47 +1093,44 @@ } | ||
| if (detected) { | ||
| state.tag = _tag; | ||
| state.anchor = _anchor; | ||
| state.kind = 'sequence'; | ||
| state.result = _result; | ||
| return true; | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| state.kind = 'sequence' | ||
| state.result = _result | ||
| return true | ||
| } | ||
| return false; | ||
| return false | ||
| } | ||
| function readBlockMapping(state, nodeIndent, flowIndent) { | ||
| var following, | ||
| allowCompact, | ||
| _line, | ||
| _keyLine, | ||
| _keyLineStart, | ||
| _keyPos, | ||
| _tag = state.tag, | ||
| _anchor = state.anchor, | ||
| _result = {}, | ||
| overridableKeys = Object.create(null), | ||
| keyTag = null, | ||
| keyNode = null, | ||
| valueNode = null, | ||
| atExplicitKey = false, | ||
| detected = false, | ||
| ch; | ||
| function readBlockMapping (state, nodeIndent, flowIndent) { | ||
| let allowCompact | ||
| let _keyLine | ||
| let _keyLineStart | ||
| let _keyPos | ||
| const _tag = state.tag | ||
| const _anchor = state.anchor | ||
| const _result = {} | ||
| const overridableKeys = Object.create(null) | ||
| let keyTag = null | ||
| let keyNode = null | ||
| let valueNode = null | ||
| let atExplicitKey = false | ||
| let detected = false | ||
| // there is a leading tab before this token, so it can't be a block sequence/mapping; | ||
| // it can still be flow sequence/mapping or a scalar | ||
| if (state.firstTabInLine !== -1) return false; | ||
| if (state.firstTabInLine !== -1) return false | ||
| if (state.anchor !== null) { | ||
| state.anchorMap[state.anchor] = _result; | ||
| storeAnchor(state, state.anchor, _result) | ||
| } | ||
| ch = state.input.charCodeAt(state.position); | ||
| let ch = state.input.charCodeAt(state.position) | ||
| while (ch !== 0) { | ||
| if (!atExplicitKey && state.firstTabInLine !== -1) { | ||
| state.position = state.firstTabInLine; | ||
| throwError(state, 'tab characters must not be used in indentation'); | ||
| state.position = state.firstTabInLine | ||
| throwError(state, 'tab characters must not be used in indentation') | ||
| } | ||
| following = state.input.charCodeAt(state.position + 1); | ||
| _line = state.line; // Save the current line. | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| const _line = state.line // Save the current line. | ||
@@ -1099,25 +1141,22 @@ // | ||
| // | ||
| if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { | ||
| if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && isWsOrEol(following)) { | ||
| if (ch === 0x3F/* ? */) { | ||
| if (atExplicitKey) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); | ||
| keyTag = keyNode = valueNode = null; | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) | ||
| keyTag = keyNode = valueNode = null | ||
| } | ||
| detected = true; | ||
| atExplicitKey = true; | ||
| allowCompact = true; | ||
| detected = true | ||
| atExplicitKey = true | ||
| allowCompact = true | ||
| } else if (atExplicitKey) { | ||
| // i.e. 0x3A/* : */ === character after the explicit key. | ||
| atExplicitKey = false; | ||
| allowCompact = true; | ||
| atExplicitKey = false | ||
| allowCompact = true | ||
| } else { | ||
| throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); | ||
| throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line') | ||
| } | ||
| state.position += 1; | ||
| ch = following; | ||
| state.position += 1 | ||
| ch = following | ||
@@ -1128,5 +1167,5 @@ // | ||
| } else { | ||
| _keyLine = state.line; | ||
| _keyLineStart = state.lineStart; | ||
| _keyPos = state.position; | ||
| _keyLine = state.line | ||
| _keyLineStart = state.lineStart | ||
| _keyPos = state.position | ||
@@ -1136,46 +1175,42 @@ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { | ||
| // Reading is done. Go to the epilogue. | ||
| break; | ||
| break | ||
| } | ||
| if (state.line === _line) { | ||
| ch = state.input.charCodeAt(state.position); | ||
| ch = state.input.charCodeAt(state.position) | ||
| while (is_WHITE_SPACE(ch)) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| while (isWhiteSpace(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (ch === 0x3A/* : */) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (!is_WS_OR_EOL(ch)) { | ||
| throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); | ||
| if (!isWsOrEol(ch)) { | ||
| throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping') | ||
| } | ||
| if (atExplicitKey) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); | ||
| keyTag = keyNode = valueNode = null; | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) | ||
| keyTag = keyNode = valueNode = null | ||
| } | ||
| detected = true; | ||
| atExplicitKey = false; | ||
| allowCompact = false; | ||
| keyTag = state.tag; | ||
| keyNode = state.result; | ||
| detected = true | ||
| atExplicitKey = false | ||
| allowCompact = false | ||
| keyTag = state.tag | ||
| keyNode = state.result | ||
| } else if (detected) { | ||
| throwError(state, 'can not read an implicit mapping pair; a colon is missed'); | ||
| throwError(state, 'can not read an implicit mapping pair; a colon is missed') | ||
| } else { | ||
| state.tag = _tag; | ||
| state.anchor = _anchor; | ||
| return true; // Keep the result of `composeNode`. | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| return true // Keep the result of `composeNode`. | ||
| } | ||
| } else if (detected) { | ||
| throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); | ||
| throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key') | ||
| } else { | ||
| state.tag = _tag; | ||
| state.anchor = _anchor; | ||
| return true; // Keep the result of `composeNode`. | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| return true // Keep the result of `composeNode`. | ||
| } | ||
@@ -1189,5 +1224,5 @@ } | ||
| if (atExplicitKey) { | ||
| _keyLine = state.line; | ||
| _keyLineStart = state.lineStart; | ||
| _keyPos = state.position; | ||
| _keyLine = state.line | ||
| _keyLineStart = state.lineStart | ||
| _keyPos = state.position | ||
| } | ||
@@ -1197,5 +1232,5 @@ | ||
| if (atExplicitKey) { | ||
| keyNode = state.result; | ||
| keyNode = state.result | ||
| } else { | ||
| valueNode = state.result; | ||
| valueNode = state.result | ||
| } | ||
@@ -1205,14 +1240,14 @@ } | ||
| if (!atExplicitKey) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); | ||
| keyTag = keyNode = valueNode = null; | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos) | ||
| keyTag = keyNode = valueNode = null | ||
| } | ||
| skipSeparationSpace(state, true, -1); | ||
| ch = state.input.charCodeAt(state.position); | ||
| skipSeparationSpace(state, true, -1) | ||
| ch = state.input.charCodeAt(state.position) | ||
| } | ||
| if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { | ||
| throwError(state, 'bad indentation of a mapping entry'); | ||
| throwError(state, 'bad indentation of a mapping entry') | ||
| } else if (state.lineIndent < nodeIndent) { | ||
| break; | ||
| break | ||
| } | ||
@@ -1227,3 +1262,3 @@ } | ||
| if (atExplicitKey) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) | ||
| } | ||
@@ -1233,79 +1268,74 @@ | ||
| if (detected) { | ||
| state.tag = _tag; | ||
| state.anchor = _anchor; | ||
| state.kind = 'mapping'; | ||
| state.result = _result; | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| state.kind = 'mapping' | ||
| state.result = _result | ||
| } | ||
| return detected; | ||
| return detected | ||
| } | ||
| function readTagProperty(state) { | ||
| var _position, | ||
| isVerbatim = false, | ||
| isNamed = false, | ||
| tagHandle, | ||
| tagName, | ||
| ch; | ||
| function readTagProperty (state) { | ||
| let isVerbatim = false | ||
| let isNamed = false | ||
| let tagHandle | ||
| let tagName | ||
| ch = state.input.charCodeAt(state.position); | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch !== 0x21/* ! */) return false; | ||
| if (ch !== 0x21/* ! */) return false | ||
| if (state.tag !== null) { | ||
| throwError(state, 'duplication of a tag property'); | ||
| throwError(state, 'duplication of a tag property') | ||
| } | ||
| ch = state.input.charCodeAt(++state.position); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (ch === 0x3C/* < */) { | ||
| isVerbatim = true; | ||
| ch = state.input.charCodeAt(++state.position); | ||
| isVerbatim = true | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } else if (ch === 0x21/* ! */) { | ||
| isNamed = true; | ||
| tagHandle = '!!'; | ||
| ch = state.input.charCodeAt(++state.position); | ||
| isNamed = true | ||
| tagHandle = '!!' | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } else { | ||
| tagHandle = '!'; | ||
| tagHandle = '!' | ||
| } | ||
| _position = state.position; | ||
| let _position = state.position | ||
| if (isVerbatim) { | ||
| do { ch = state.input.charCodeAt(++state.position); } | ||
| while (ch !== 0 && ch !== 0x3E/* > */); | ||
| do { ch = state.input.charCodeAt(++state.position) } | ||
| while (ch !== 0 && ch !== 0x3E/* > */) | ||
| if (state.position < state.length) { | ||
| tagName = state.input.slice(_position, state.position); | ||
| ch = state.input.charCodeAt(++state.position); | ||
| tagName = state.input.slice(_position, state.position) | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } else { | ||
| throwError(state, 'unexpected end of the stream within a verbatim tag'); | ||
| throwError(state, 'unexpected end of the stream within a verbatim tag') | ||
| } | ||
| } else { | ||
| while (ch !== 0 && !is_WS_OR_EOL(ch)) { | ||
| while (ch !== 0 && !isWsOrEol(ch)) { | ||
| if (ch === 0x21/* ! */) { | ||
| if (!isNamed) { | ||
| tagHandle = state.input.slice(_position - 1, state.position + 1); | ||
| tagHandle = state.input.slice(_position - 1, state.position + 1) | ||
| if (!PATTERN_TAG_HANDLE.test(tagHandle)) { | ||
| throwError(state, 'named tag handle cannot contain such characters'); | ||
| throwError(state, 'named tag handle cannot contain such characters') | ||
| } | ||
| isNamed = true; | ||
| _position = state.position + 1; | ||
| isNamed = true | ||
| _position = state.position + 1 | ||
| } else { | ||
| throwError(state, 'tag suffix cannot contain exclamation marks'); | ||
| throwError(state, 'tag suffix cannot contain exclamation marks') | ||
| } | ||
| } | ||
| ch = state.input.charCodeAt(++state.position); | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| tagName = state.input.slice(_position, state.position); | ||
| tagName = state.input.slice(_position, state.position) | ||
| if (PATTERN_FLOW_INDICATORS.test(tagName)) { | ||
| throwError(state, 'tag suffix cannot contain flow indicator characters'); | ||
| throwError(state, 'tag suffix cannot contain flow indicator characters') | ||
| } | ||
@@ -1315,124 +1345,140 @@ } | ||
| if (tagName && !PATTERN_TAG_URI.test(tagName)) { | ||
| throwError(state, 'tag name cannot contain such characters: ' + tagName); | ||
| throwError(state, 'tag name cannot contain such characters: ' + tagName) | ||
| } | ||
| try { | ||
| tagName = decodeURIComponent(tagName); | ||
| tagName = decodeURIComponent(tagName) | ||
| } catch (err) { | ||
| throwError(state, 'tag name is malformed: ' + tagName); | ||
| throwError(state, 'tag name is malformed: ' + tagName) | ||
| } | ||
| if (isVerbatim) { | ||
| state.tag = tagName; | ||
| state.tag = tagName | ||
| } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { | ||
| state.tag = state.tagMap[tagHandle] + tagName; | ||
| state.tag = state.tagMap[tagHandle] + tagName | ||
| } else if (tagHandle === '!') { | ||
| state.tag = '!' + tagName; | ||
| state.tag = '!' + tagName | ||
| } else if (tagHandle === '!!') { | ||
| state.tag = 'tag:yaml.org,2002:' + tagName; | ||
| state.tag = 'tag:yaml.org,2002:' + tagName | ||
| } else { | ||
| throwError(state, 'undeclared tag handle "' + tagHandle + '"'); | ||
| throwError(state, 'undeclared tag handle "' + tagHandle + '"') | ||
| } | ||
| return true; | ||
| return true | ||
| } | ||
| function readAnchorProperty(state) { | ||
| var _position, | ||
| ch; | ||
| function readAnchorProperty (state) { | ||
| let ch = state.input.charCodeAt(state.position) | ||
| ch = state.input.charCodeAt(state.position); | ||
| if (ch !== 0x26/* & */) return false | ||
| if (ch !== 0x26/* & */) return false; | ||
| if (state.anchor !== null) { | ||
| throwError(state, 'duplication of an anchor property'); | ||
| throwError(state, 'duplication of an anchor property') | ||
| } | ||
| ch = state.input.charCodeAt(++state.position); | ||
| _position = state.position; | ||
| ch = state.input.charCodeAt(++state.position) | ||
| const _position = state.position | ||
| while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (state.position === _position) { | ||
| throwError(state, 'name of an anchor node must contain at least one character'); | ||
| throwError(state, 'name of an anchor node must contain at least one character') | ||
| } | ||
| state.anchor = state.input.slice(_position, state.position); | ||
| return true; | ||
| state.anchor = state.input.slice(_position, state.position) | ||
| return true | ||
| } | ||
| function readAlias(state) { | ||
| var _position, alias, | ||
| ch; | ||
| function readAlias (state) { | ||
| let ch = state.input.charCodeAt(state.position) | ||
| ch = state.input.charCodeAt(state.position); | ||
| if (ch !== 0x2A/* * */) return false | ||
| if (ch !== 0x2A/* * */) return false; | ||
| ch = state.input.charCodeAt(++state.position) | ||
| const _position = state.position | ||
| ch = state.input.charCodeAt(++state.position); | ||
| _position = state.position; | ||
| while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (state.position === _position) { | ||
| throwError(state, 'name of an alias node must contain at least one character'); | ||
| throwError(state, 'name of an alias node must contain at least one character') | ||
| } | ||
| alias = state.input.slice(_position, state.position); | ||
| const alias = state.input.slice(_position, state.position) | ||
| if (!_hasOwnProperty.call(state.anchorMap, alias)) { | ||
| throwError(state, 'unidentified alias "' + alias + '"'); | ||
| throwError(state, 'unidentified alias "' + alias + '"') | ||
| } | ||
| state.result = state.anchorMap[alias]; | ||
| skipSeparationSpace(state, true, -1); | ||
| return true; | ||
| state.result = state.anchorMap[alias] | ||
| skipSeparationSpace(state, true, -1) | ||
| return true | ||
| } | ||
| function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { | ||
| var allowBlockStyles, | ||
| allowBlockScalars, | ||
| allowBlockCollections, | ||
| indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent | ||
| atNewLine = false, | ||
| hasContent = false, | ||
| typeIndex, | ||
| typeQuantity, | ||
| typeList, | ||
| type, | ||
| flowIndent, | ||
| blockIndent; | ||
| function tryReadBlockMappingFromProperty (state, propertyStart, nodeIndent, flowIndent) { | ||
| const fallbackState = snapshotState(state) | ||
| beginAnchorTransaction(state) | ||
| restoreState(state, propertyStart) | ||
| // Re-read the leading properties as part of the first implicit key, not as | ||
| // properties of the current node. | ||
| state.tag = null | ||
| state.anchor = null | ||
| state.kind = null | ||
| state.result = null | ||
| if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === 'mapping') { | ||
| commitAnchorTransaction(state) | ||
| return true | ||
| } | ||
| rollbackAnchorTransaction(state) | ||
| restoreState(state, fallbackState) | ||
| return false | ||
| } | ||
| function composeNode (state, parentIndent, nodeContext, allowToSeek, allowCompact) { | ||
| let allowBlockScalars | ||
| let allowBlockCollections | ||
| let indentStatus = 1 // 1: this>parent, 0: this=parent, -1: this<parent | ||
| let atNewLine = false | ||
| let hasContent = false | ||
| let propertyStart = null | ||
| let type | ||
| let flowIndent | ||
| let blockIndent | ||
| if (state.depth >= state.maxDepth) { | ||
| throwError(state, 'nesting exceeded maxDepth (' + state.maxDepth + ')') | ||
| } | ||
| state.depth += 1 | ||
| if (state.listener !== null) { | ||
| state.listener('open', state); | ||
| state.listener('open', state) | ||
| } | ||
| state.tag = null; | ||
| state.anchor = null; | ||
| state.kind = null; | ||
| state.result = null; | ||
| state.tag = null | ||
| state.anchor = null | ||
| state.kind = null | ||
| state.result = null | ||
| allowBlockStyles = allowBlockScalars = allowBlockCollections = | ||
| const allowBlockStyles = allowBlockScalars = allowBlockCollections = | ||
| CONTEXT_BLOCK_OUT === nodeContext || | ||
| CONTEXT_BLOCK_IN === nodeContext; | ||
| CONTEXT_BLOCK_IN === nodeContext | ||
| if (allowToSeek) { | ||
| if (skipSeparationSpace(state, true, -1)) { | ||
| atNewLine = true; | ||
| atNewLine = true | ||
| if (state.lineIndent > parentIndent) { | ||
| indentStatus = 1; | ||
| indentStatus = 1 | ||
| } else if (state.lineIndent === parentIndent) { | ||
| indentStatus = 0; | ||
| indentStatus = 0 | ||
| } else if (state.lineIndent < parentIndent) { | ||
| indentStatus = -1; | ||
| indentStatus = -1 | ||
| } | ||
@@ -1443,16 +1489,35 @@ } | ||
| if (indentStatus === 1) { | ||
| while (readTagProperty(state) || readAnchorProperty(state)) { | ||
| while (true) { | ||
| const ch = state.input.charCodeAt(state.position) | ||
| const propertyState = snapshotState(state) | ||
| // A duplicate property token after a line break can be the first key of | ||
| // a nested block mapping, e.g. `!!map\n !!str key: value`. | ||
| if (atNewLine && | ||
| ((ch === 0x21/* ! */ && state.tag !== null) || | ||
| (ch === 0x26/* & */ && state.anchor !== null))) { | ||
| break | ||
| } | ||
| if (!readTagProperty(state) && !readAnchorProperty(state)) { | ||
| break | ||
| } | ||
| if (propertyStart === null) { | ||
| propertyStart = propertyState | ||
| } | ||
| if (skipSeparationSpace(state, true, -1)) { | ||
| atNewLine = true; | ||
| allowBlockCollections = allowBlockStyles; | ||
| atNewLine = true | ||
| allowBlockCollections = allowBlockStyles | ||
| if (state.lineIndent > parentIndent) { | ||
| indentStatus = 1; | ||
| indentStatus = 1 | ||
| } else if (state.lineIndent === parentIndent) { | ||
| indentStatus = 0; | ||
| indentStatus = 0 | ||
| } else if (state.lineIndent < parentIndent) { | ||
| indentStatus = -1; | ||
| indentStatus = -1 | ||
| } | ||
| } else { | ||
| allowBlockCollections = false; | ||
| allowBlockCollections = false | ||
| } | ||
@@ -1463,3 +1528,3 @@ } | ||
| if (allowBlockCollections) { | ||
| allowBlockCollections = atNewLine || allowCompact; | ||
| allowBlockCollections = atNewLine || allowCompact | ||
| } | ||
@@ -1469,33 +1534,41 @@ | ||
| if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { | ||
| flowIndent = parentIndent; | ||
| flowIndent = parentIndent | ||
| } else { | ||
| flowIndent = parentIndent + 1; | ||
| flowIndent = parentIndent + 1 | ||
| } | ||
| blockIndent = state.position - state.lineStart; | ||
| blockIndent = state.position - state.lineStart | ||
| if (indentStatus === 1) { | ||
| if (allowBlockCollections && | ||
| (readBlockSequence(state, blockIndent) || | ||
| readBlockMapping(state, blockIndent, flowIndent)) || | ||
| if ((allowBlockCollections && | ||
| (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent))) || | ||
| readFlowCollection(state, flowIndent)) { | ||
| hasContent = true; | ||
| hasContent = true | ||
| } else { | ||
| if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || | ||
| const ch = state.input.charCodeAt(state.position) | ||
| if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && | ||
| ch !== 0x7C/* | */ && ch !== 0x3E/* > */ && | ||
| tryReadBlockMappingFromProperty( | ||
| state, | ||
| propertyStart, | ||
| propertyStart.position - propertyStart.lineStart, | ||
| flowIndent | ||
| )) { | ||
| hasContent = true | ||
| } else if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || | ||
| readSingleQuotedScalar(state, flowIndent) || | ||
| readDoubleQuotedScalar(state, flowIndent)) { | ||
| hasContent = true; | ||
| hasContent = true | ||
| } else if (readAlias(state)) { | ||
| hasContent = true; | ||
| hasContent = true | ||
| if (state.tag !== null || state.anchor !== null) { | ||
| throwError(state, 'alias node should not have any properties'); | ||
| throwError(state, 'alias node should not have any properties') | ||
| } | ||
| } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { | ||
| hasContent = true; | ||
| hasContent = true | ||
| if (state.tag === null) { | ||
| state.tag = '?'; | ||
| state.tag = '?' | ||
| } | ||
@@ -1505,3 +1578,3 @@ } | ||
| if (state.anchor !== null) { | ||
| state.anchorMap[state.anchor] = state.result; | ||
| storeAnchor(state, state.anchor, state.result) | ||
| } | ||
@@ -1512,3 +1585,3 @@ } | ||
| // http://www.yaml.org/spec/1.2/spec.html#id2799784 | ||
| hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); | ||
| hasContent = allowBlockCollections && readBlockSequence(state, blockIndent) | ||
| } | ||
@@ -1519,5 +1592,4 @@ } | ||
| if (state.anchor !== null) { | ||
| state.anchorMap[state.anchor] = state.result; | ||
| storeAnchor(state, state.anchor, state.result) | ||
| } | ||
| } else if (state.tag === '?') { | ||
@@ -1531,15 +1603,15 @@ // Implicit resolving is not allowed for non-scalar types, and '?' | ||
| if (state.result !== null && state.kind !== 'scalar') { | ||
| throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"'); | ||
| throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"') | ||
| } | ||
| for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { | ||
| type = state.implicitTypes[typeIndex]; | ||
| for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { | ||
| type = state.implicitTypes[typeIndex] | ||
| if (type.resolve(state.result)) { // `state.result` updated in resolver if matched | ||
| state.result = type.construct(state.result); | ||
| state.tag = type.tag; | ||
| state.result = type.construct(state.result) | ||
| state.tag = type.tag | ||
| if (state.anchor !== null) { | ||
| state.anchorMap[state.anchor] = state.result; | ||
| storeAnchor(state, state.anchor, state.result) | ||
| } | ||
| break; | ||
| break | ||
| } | ||
@@ -1549,12 +1621,12 @@ } | ||
| if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { | ||
| type = state.typeMap[state.kind || 'fallback'][state.tag]; | ||
| type = state.typeMap[state.kind || 'fallback'][state.tag] | ||
| } else { | ||
| // looking for multi type | ||
| type = null; | ||
| typeList = state.typeMap.multi[state.kind || 'fallback']; | ||
| type = null | ||
| const typeList = state.typeMap.multi[state.kind || 'fallback'] | ||
| for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { | ||
| for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { | ||
| if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { | ||
| type = typeList[typeIndex]; | ||
| break; | ||
| type = typeList[typeIndex] | ||
| break | ||
| } | ||
@@ -1565,15 +1637,15 @@ } | ||
| if (!type) { | ||
| throwError(state, 'unknown tag !<' + state.tag + '>'); | ||
| throwError(state, 'unknown tag !<' + state.tag + '>') | ||
| } | ||
| if (state.result !== null && type.kind !== state.kind) { | ||
| throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); | ||
| throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"') | ||
| } | ||
| if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched | ||
| throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); | ||
| throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag') | ||
| } else { | ||
| state.result = type.construct(state.result, state.tag); | ||
| state.result = type.construct(state.result, state.tag) | ||
| if (state.anchor !== null) { | ||
| state.anchorMap[state.anchor] = state.result; | ||
| storeAnchor(state, state.anchor, state.result) | ||
| } | ||
@@ -1584,125 +1656,118 @@ } | ||
| if (state.listener !== null) { | ||
| state.listener('close', state); | ||
| state.listener('close', state) | ||
| } | ||
| return state.tag !== null || state.anchor !== null || hasContent; | ||
| state.depth -= 1 | ||
| return state.tag !== null || state.anchor !== null || hasContent | ||
| } | ||
| function readDocument(state) { | ||
| var documentStart = state.position, | ||
| _position, | ||
| directiveName, | ||
| directiveArgs, | ||
| hasDirectives = false, | ||
| ch; | ||
| function readDocument (state) { | ||
| const documentStart = state.position | ||
| let hasDirectives = false | ||
| let ch | ||
| state.version = null; | ||
| state.checkLineBreaks = state.legacy; | ||
| state.tagMap = Object.create(null); | ||
| state.anchorMap = Object.create(null); | ||
| state.version = null | ||
| state.checkLineBreaks = state.legacy | ||
| state.tagMap = Object.create(null) | ||
| state.anchorMap = Object.create(null) | ||
| while ((ch = state.input.charCodeAt(state.position)) !== 0) { | ||
| skipSeparationSpace(state, true, -1); | ||
| skipSeparationSpace(state, true, -1) | ||
| ch = state.input.charCodeAt(state.position); | ||
| ch = state.input.charCodeAt(state.position) | ||
| if (state.lineIndent > 0 || ch !== 0x25/* % */) { | ||
| break; | ||
| break | ||
| } | ||
| hasDirectives = true; | ||
| ch = state.input.charCodeAt(++state.position); | ||
| _position = state.position; | ||
| hasDirectives = true | ||
| ch = state.input.charCodeAt(++state.position) | ||
| let _position = state.position | ||
| while (ch !== 0 && !is_WS_OR_EOL(ch)) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| while (ch !== 0 && !isWsOrEol(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| directiveName = state.input.slice(_position, state.position); | ||
| directiveArgs = []; | ||
| const directiveName = state.input.slice(_position, state.position) | ||
| const directiveArgs = [] | ||
| if (directiveName.length < 1) { | ||
| throwError(state, 'directive name must not be less than one character in length'); | ||
| throwError(state, 'directive name must not be less than one character in length') | ||
| } | ||
| while (ch !== 0) { | ||
| while (is_WHITE_SPACE(ch)) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| while (isWhiteSpace(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (ch === 0x23/* # */) { | ||
| do { ch = state.input.charCodeAt(++state.position); } | ||
| while (ch !== 0 && !is_EOL(ch)); | ||
| break; | ||
| do { ch = state.input.charCodeAt(++state.position) } | ||
| while (ch !== 0 && !isEol(ch)) | ||
| break | ||
| } | ||
| if (is_EOL(ch)) break; | ||
| if (isEol(ch)) break | ||
| _position = state.position; | ||
| _position = state.position | ||
| while (ch !== 0 && !is_WS_OR_EOL(ch)) { | ||
| ch = state.input.charCodeAt(++state.position); | ||
| while (ch !== 0 && !isWsOrEol(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| directiveArgs.push(state.input.slice(_position, state.position)); | ||
| directiveArgs.push(state.input.slice(_position, state.position)) | ||
| } | ||
| if (ch !== 0) readLineBreak(state); | ||
| if (ch !== 0) readLineBreak(state) | ||
| if (_hasOwnProperty.call(directiveHandlers, directiveName)) { | ||
| directiveHandlers[directiveName](state, directiveName, directiveArgs); | ||
| directiveHandlers[directiveName](state, directiveName, directiveArgs) | ||
| } else { | ||
| throwWarning(state, 'unknown document directive "' + directiveName + '"'); | ||
| throwWarning(state, 'unknown document directive "' + directiveName + '"') | ||
| } | ||
| } | ||
| skipSeparationSpace(state, true, -1); | ||
| skipSeparationSpace(state, true, -1) | ||
| if (state.lineIndent === 0 && | ||
| state.input.charCodeAt(state.position) === 0x2D/* - */ && | ||
| state.input.charCodeAt(state.position) === 0x2D/* - */ && | ||
| state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && | ||
| state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { | ||
| state.position += 3; | ||
| skipSeparationSpace(state, true, -1); | ||
| state.position += 3 | ||
| skipSeparationSpace(state, true, -1) | ||
| } else if (hasDirectives) { | ||
| throwError(state, 'directives end mark is expected'); | ||
| throwError(state, 'directives end mark is expected') | ||
| } | ||
| composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); | ||
| skipSeparationSpace(state, true, -1); | ||
| composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true) | ||
| skipSeparationSpace(state, true, -1) | ||
| if (state.checkLineBreaks && | ||
| PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { | ||
| throwWarning(state, 'non-ASCII line breaks are interpreted as content'); | ||
| throwWarning(state, 'non-ASCII line breaks are interpreted as content') | ||
| } | ||
| state.documents.push(state.result); | ||
| state.documents.push(state.result) | ||
| if (state.position === state.lineStart && testDocumentSeparator(state)) { | ||
| if (state.input.charCodeAt(state.position) === 0x2E/* . */) { | ||
| state.position += 3; | ||
| skipSeparationSpace(state, true, -1); | ||
| state.position += 3 | ||
| skipSeparationSpace(state, true, -1) | ||
| } | ||
| return; | ||
| return | ||
| } | ||
| if (state.position < (state.length - 1)) { | ||
| throwError(state, 'end of the stream or a document separator is expected'); | ||
| } else { | ||
| return; | ||
| throwError(state, 'end of the stream or a document separator is expected') | ||
| } | ||
| } | ||
| function loadDocuments (input, options) { | ||
| input = String(input) | ||
| options = options || {} | ||
| function loadDocuments(input, options) { | ||
| input = String(input); | ||
| options = options || {}; | ||
| if (input.length !== 0) { | ||
| // Add tailing `\n` if not exists | ||
| if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && | ||
| input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { | ||
| input += '\n'; | ||
| input += '\n' | ||
| } | ||
@@ -1712,63 +1777,59 @@ | ||
| if (input.charCodeAt(0) === 0xFEFF) { | ||
| input = input.slice(1); | ||
| input = input.slice(1) | ||
| } | ||
| } | ||
| var state = new State(input, options); | ||
| const state = new State(input, options) | ||
| var nullpos = input.indexOf('\0'); | ||
| const nullpos = input.indexOf('\0') | ||
| if (nullpos !== -1) { | ||
| state.position = nullpos; | ||
| throwError(state, 'null byte is not allowed in input'); | ||
| state.position = nullpos | ||
| throwError(state, 'null byte is not allowed in input') | ||
| } | ||
| // Use 0 as string terminator. That significantly simplifies bounds check. | ||
| state.input += '\0'; | ||
| state.input += '\0' | ||
| while (state.input.charCodeAt(state.position) === 0x20/* Space */) { | ||
| state.lineIndent += 1; | ||
| state.position += 1; | ||
| state.lineIndent += 1 | ||
| state.position += 1 | ||
| } | ||
| while (state.position < (state.length - 1)) { | ||
| readDocument(state); | ||
| readDocument(state) | ||
| } | ||
| return state.documents; | ||
| return state.documents | ||
| } | ||
| function loadAll(input, iterator, options) { | ||
| function loadAll (input, iterator, options) { | ||
| if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { | ||
| options = iterator; | ||
| iterator = null; | ||
| options = iterator | ||
| iterator = null | ||
| } | ||
| var documents = loadDocuments(input, options); | ||
| const documents = loadDocuments(input, options) | ||
| if (typeof iterator !== 'function') { | ||
| return documents; | ||
| return documents | ||
| } | ||
| for (var index = 0, length = documents.length; index < length; index += 1) { | ||
| iterator(documents[index]); | ||
| for (let index = 0, length = documents.length; index < length; index += 1) { | ||
| iterator(documents[index]) | ||
| } | ||
| } | ||
| function load (input, options) { | ||
| const documents = loadDocuments(input, options) | ||
| function load(input, options) { | ||
| var documents = loadDocuments(input, options); | ||
| if (documents.length === 0) { | ||
| /*eslint-disable no-undefined*/ | ||
| return undefined; | ||
| return undefined | ||
| } else if (documents.length === 1) { | ||
| return documents[0]; | ||
| return documents[0] | ||
| } | ||
| throw new YAMLException('expected a single document in the stream, but found more'); | ||
| throw new YAMLException('expected a single document in the stream, but found more') | ||
| } | ||
| module.exports.loadAll = loadAll; | ||
| module.exports.load = load; | ||
| module.exports.loadAll = loadAll | ||
| module.exports.load = load |
+56
-68
@@ -1,14 +0,11 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| /*eslint-disable max-len*/ | ||
| const YAMLException = require('./exception') | ||
| const Type = require('./type') | ||
| var YAMLException = require('./exception'); | ||
| var Type = require('./type'); | ||
| function compileList (schema, name) { | ||
| const result = [] | ||
| function compileList(schema, name) { | ||
| var result = []; | ||
| schema[name].forEach(function (currentType) { | ||
| var newIndex = result.length; | ||
| let newIndex = result.length | ||
@@ -19,69 +16,61 @@ result.forEach(function (previousType, previousIndex) { | ||
| previousType.multi === currentType.multi) { | ||
| newIndex = previousIndex; | ||
| newIndex = previousIndex | ||
| } | ||
| }); | ||
| }) | ||
| result[newIndex] = currentType; | ||
| }); | ||
| result[newIndex] = currentType | ||
| }) | ||
| return result; | ||
| return result | ||
| } | ||
| function compileMap(/* lists... */) { | ||
| var result = { | ||
| scalar: {}, | ||
| sequence: {}, | ||
| mapping: {}, | ||
| fallback: {}, | ||
| multi: { | ||
| scalar: [], | ||
| sequence: [], | ||
| mapping: [], | ||
| fallback: [] | ||
| } | ||
| }, index, length; | ||
| function collectType(type) { | ||
| function compileMap (/* lists... */) { | ||
| const result = { | ||
| scalar: {}, | ||
| sequence: {}, | ||
| mapping: {}, | ||
| fallback: {}, | ||
| multi: { | ||
| scalar: [], | ||
| sequence: [], | ||
| mapping: [], | ||
| fallback: [] | ||
| } | ||
| } | ||
| function collectType (type) { | ||
| if (type.multi) { | ||
| result.multi[type.kind].push(type); | ||
| result.multi['fallback'].push(type); | ||
| result.multi[type.kind].push(type) | ||
| result.multi['fallback'].push(type) | ||
| } else { | ||
| result[type.kind][type.tag] = result['fallback'][type.tag] = type; | ||
| result[type.kind][type.tag] = result['fallback'][type.tag] = type | ||
| } | ||
| } | ||
| for (index = 0, length = arguments.length; index < length; index += 1) { | ||
| arguments[index].forEach(collectType); | ||
| for (let index = 0, length = arguments.length; index < length; index += 1) { | ||
| arguments[index].forEach(collectType) | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
| function Schema(definition) { | ||
| return this.extend(definition); | ||
| function Schema (definition) { | ||
| return this.extend(definition) | ||
| } | ||
| Schema.prototype.extend = function extend (definition) { | ||
| let implicit = [] | ||
| let explicit = [] | ||
| Schema.prototype.extend = function extend(definition) { | ||
| var implicit = []; | ||
| var explicit = []; | ||
| if (definition instanceof Type) { | ||
| // Schema.extend(type) | ||
| explicit.push(definition); | ||
| explicit.push(definition) | ||
| } else if (Array.isArray(definition)) { | ||
| // Schema.extend([ type1, type2, ... ]) | ||
| explicit = explicit.concat(definition); | ||
| explicit = explicit.concat(definition) | ||
| } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { | ||
| // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) | ||
| if (definition.implicit) implicit = implicit.concat(definition.implicit); | ||
| if (definition.explicit) explicit = explicit.concat(definition.explicit); | ||
| if (definition.implicit) implicit = implicit.concat(definition.implicit) | ||
| if (definition.explicit) explicit = explicit.concat(definition.explicit) | ||
| } else { | ||
| throw new YAMLException('Schema.extend argument should be a Type, [ Type ], ' + | ||
| 'or a schema definition ({ implicit: [...], explicit: [...] })'); | ||
| 'or a schema definition ({ implicit: [...], explicit: [...] })') | ||
| } | ||
@@ -91,33 +80,32 @@ | ||
| if (!(type instanceof Type)) { | ||
| throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); | ||
| throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.') | ||
| } | ||
| if (type.loadKind && type.loadKind !== 'scalar') { | ||
| throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); | ||
| throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.') | ||
| } | ||
| if (type.multi) { | ||
| throw new YAMLException('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); | ||
| throw new YAMLException('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.') | ||
| } | ||
| }); | ||
| }) | ||
| explicit.forEach(function (type) { | ||
| if (!(type instanceof Type)) { | ||
| throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); | ||
| throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.') | ||
| } | ||
| }); | ||
| }) | ||
| var result = Object.create(Schema.prototype); | ||
| const result = Object.create(Schema.prototype) | ||
| result.implicit = (this.implicit || []).concat(implicit); | ||
| result.explicit = (this.explicit || []).concat(explicit); | ||
| result.implicit = (this.implicit || []).concat(implicit) | ||
| result.explicit = (this.explicit || []).concat(explicit) | ||
| result.compiledImplicit = compileList(result, 'implicit'); | ||
| result.compiledExplicit = compileList(result, 'explicit'); | ||
| result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); | ||
| result.compiledImplicit = compileList(result, 'implicit') | ||
| result.compiledExplicit = compileList(result, 'explicit') | ||
| result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit) | ||
| return result; | ||
| }; | ||
| return result | ||
| } | ||
| module.exports = Schema; | ||
| module.exports = Schema |
@@ -7,6 +7,4 @@ // Standard YAML's Core schema. | ||
| 'use strict' | ||
| 'use strict'; | ||
| module.exports = require('./json'); | ||
| module.exports = require('./json') |
@@ -7,6 +7,4 @@ // JS-YAML's default schema for `safeLoad` function. | ||
| 'use strict' | ||
| 'use strict'; | ||
| module.exports = require('./core').extend({ | ||
@@ -23,2 +21,2 @@ implicit: [ | ||
| ] | ||
| }); | ||
| }) |
| // Standard YAML's Failsafe schema. | ||
| // http://www.yaml.org/spec/1.2/spec.html#id2802346 | ||
| 'use strict' | ||
| 'use strict'; | ||
| const Schema = require('../schema') | ||
| var Schema = require('../schema'); | ||
| module.exports = new Schema({ | ||
@@ -17,2 +14,2 @@ explicit: [ | ||
| ] | ||
| }); | ||
| }) |
@@ -8,6 +8,4 @@ // Standard YAML's JSON schema. | ||
| 'use strict' | ||
| 'use strict'; | ||
| module.exports = require('./failsafe').extend({ | ||
@@ -20,2 +18,2 @@ implicit: [ | ||
| ] | ||
| }); | ||
| }) |
+47
-52
@@ -1,21 +0,19 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| const common = require('./common') | ||
| var common = require('./common'); | ||
| // get snippet for a single line, respecting maxLength | ||
| function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { | ||
| var head = ''; | ||
| var tail = ''; | ||
| var maxHalfLength = Math.floor(maxLineLength / 2) - 1; | ||
| function getLine (buffer, lineStart, lineEnd, position, maxLineLength) { | ||
| let head = '' | ||
| let tail = '' | ||
| const maxHalfLength = Math.floor(maxLineLength / 2) - 1 | ||
| if (position - lineStart > maxHalfLength) { | ||
| head = ' ... '; | ||
| lineStart = position - maxHalfLength + head.length; | ||
| head = ' ... ' | ||
| lineStart = position - maxHalfLength + head.length | ||
| } | ||
| if (lineEnd - position > maxHalfLength) { | ||
| tail = ' ...'; | ||
| lineEnd = position + maxHalfLength - tail.length; | ||
| tail = ' ...' | ||
| lineEnd = position + maxHalfLength - tail.length | ||
| } | ||
@@ -26,45 +24,43 @@ | ||
| pos: position - lineStart + head.length // relative position | ||
| }; | ||
| } | ||
| } | ||
| function padStart(string, max) { | ||
| return common.repeat(' ', max - string.length) + string; | ||
| function padStart (string, max) { | ||
| return common.repeat(' ', max - string.length) + string | ||
| } | ||
| function makeSnippet (mark, options) { | ||
| options = Object.create(options || null) | ||
| function makeSnippet(mark, options) { | ||
| options = Object.create(options || null); | ||
| if (!mark.buffer) return null | ||
| if (!mark.buffer) return null; | ||
| if (!options.maxLength) options.maxLength = 79 | ||
| if (typeof options.indent !== 'number') options.indent = 1 | ||
| if (typeof options.linesBefore !== 'number') options.linesBefore = 3 | ||
| if (typeof options.linesAfter !== 'number') options.linesAfter = 2 | ||
| if (!options.maxLength) options.maxLength = 79; | ||
| if (typeof options.indent !== 'number') options.indent = 1; | ||
| if (typeof options.linesBefore !== 'number') options.linesBefore = 3; | ||
| if (typeof options.linesAfter !== 'number') options.linesAfter = 2; | ||
| const re = /\r?\n|\r|\0/g | ||
| const lineStarts = [0] | ||
| const lineEnds = [] | ||
| let match | ||
| let foundLineNo = -1 | ||
| var re = /\r?\n|\r|\0/g; | ||
| var lineStarts = [ 0 ]; | ||
| var lineEnds = []; | ||
| var match; | ||
| var foundLineNo = -1; | ||
| while ((match = re.exec(mark.buffer))) { | ||
| lineEnds.push(match.index); | ||
| lineStarts.push(match.index + match[0].length); | ||
| lineEnds.push(match.index) | ||
| lineStarts.push(match.index + match[0].length) | ||
| if (mark.position <= match.index && foundLineNo < 0) { | ||
| foundLineNo = lineStarts.length - 2; | ||
| foundLineNo = lineStarts.length - 2 | ||
| } | ||
| } | ||
| if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; | ||
| if (foundLineNo < 0) foundLineNo = lineStarts.length - 1 | ||
| var result = '', i, line; | ||
| var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; | ||
| var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); | ||
| let result = '' | ||
| const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length | ||
| const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3) | ||
| for (i = 1; i <= options.linesBefore; i++) { | ||
| if (foundLineNo - i < 0) break; | ||
| line = getLine( | ||
| for (let i = 1; i <= options.linesBefore; i++) { | ||
| if (foundLineNo - i < 0) break | ||
| const line = getLine( | ||
| mark.buffer, | ||
@@ -75,15 +71,15 @@ lineStarts[foundLineNo - i], | ||
| maxLineLength | ||
| ); | ||
| ) | ||
| result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + | ||
| ' | ' + line.str + '\n' + result; | ||
| ' | ' + line.str + '\n' + result | ||
| } | ||
| line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); | ||
| const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength) | ||
| result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + | ||
| ' | ' + line.str + '\n'; | ||
| result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; | ||
| ' | ' + line.str + '\n' | ||
| result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n' | ||
| for (i = 1; i <= options.linesAfter; i++) { | ||
| if (foundLineNo + i >= lineEnds.length) break; | ||
| line = getLine( | ||
| for (let i = 1; i <= options.linesAfter; i++) { | ||
| if (foundLineNo + i >= lineEnds.length) break | ||
| const line = getLine( | ||
| mark.buffer, | ||
@@ -94,11 +90,10 @@ lineStarts[foundLineNo + i], | ||
| maxLineLength | ||
| ); | ||
| ) | ||
| result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + | ||
| ' | ' + line.str + '\n'; | ||
| ' | ' + line.str + '\n' | ||
| } | ||
| return result.replace(/\n$/, ''); | ||
| return result.replace(/\n$/, '') | ||
| } | ||
| module.exports = makeSnippet; | ||
| module.exports = makeSnippet |
+30
-30
@@ -1,6 +0,6 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var YAMLException = require('./exception'); | ||
| const YAMLException = require('./exception') | ||
| var TYPE_CONSTRUCTOR_OPTIONS = [ | ||
| const TYPE_CONSTRUCTOR_OPTIONS = [ | ||
| 'kind', | ||
@@ -16,12 +16,12 @@ 'multi', | ||
| 'styleAliases' | ||
| ]; | ||
| ] | ||
| var YAML_NODE_KINDS = [ | ||
| const YAML_NODE_KINDS = [ | ||
| 'scalar', | ||
| 'sequence', | ||
| 'mapping' | ||
| ]; | ||
| ] | ||
| function compileStyleAliases(map) { | ||
| var result = {}; | ||
| function compileStyleAliases (map) { | ||
| const result = {} | ||
@@ -31,38 +31,38 @@ if (map !== null) { | ||
| map[style].forEach(function (alias) { | ||
| result[String(alias)] = style; | ||
| }); | ||
| }); | ||
| result[String(alias)] = style | ||
| }) | ||
| }) | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
| function Type(tag, options) { | ||
| options = options || {}; | ||
| function Type (tag, options) { | ||
| options = options || {} | ||
| Object.keys(options).forEach(function (name) { | ||
| if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { | ||
| throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); | ||
| throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.') | ||
| } | ||
| }); | ||
| }) | ||
| // TODO: Add tag format check. | ||
| this.options = options; // keep original options in case user wants to extend this type later | ||
| this.tag = tag; | ||
| this.kind = options['kind'] || null; | ||
| this.resolve = options['resolve'] || function () { return true; }; | ||
| this.construct = options['construct'] || function (data) { return data; }; | ||
| this.instanceOf = options['instanceOf'] || null; | ||
| this.predicate = options['predicate'] || null; | ||
| this.represent = options['represent'] || null; | ||
| this.representName = options['representName'] || null; | ||
| this.defaultStyle = options['defaultStyle'] || null; | ||
| this.multi = options['multi'] || false; | ||
| this.styleAliases = compileStyleAliases(options['styleAliases'] || null); | ||
| this.options = options // keep original options in case user wants to extend this type later | ||
| this.tag = tag | ||
| this.kind = options['kind'] || null | ||
| this.resolve = options['resolve'] || function () { return true } | ||
| this.construct = options['construct'] || function (data) { return data } | ||
| this.instanceOf = options['instanceOf'] || null | ||
| this.predicate = options['predicate'] || null | ||
| this.represent = options['represent'] || null | ||
| this.representName = options['representName'] || null | ||
| this.defaultStyle = options['defaultStyle'] || null | ||
| this.multi = options['multi'] || false | ||
| this.styleAliases = compileStyleAliases(options['styleAliases'] || null) | ||
| if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { | ||
| throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); | ||
| throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.') | ||
| } | ||
| } | ||
| module.exports = Type; | ||
| module.exports = Type |
+61
-64
@@ -1,53 +0,49 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| /*eslint-disable no-bitwise*/ | ||
| const Type = require('../type') | ||
| var Type = require('../type'); | ||
| // [ 64, 65, 66 ] -> [ padding, CR, LF ] | ||
| var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; | ||
| const BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r' | ||
| function resolveYamlBinary (data) { | ||
| if (data === null) return false | ||
| function resolveYamlBinary(data) { | ||
| if (data === null) return false; | ||
| let bitlen = 0 | ||
| const max = data.length | ||
| const map = BASE64_MAP | ||
| var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; | ||
| // Convert one by one. | ||
| for (idx = 0; idx < max; idx++) { | ||
| code = map.indexOf(data.charAt(idx)); | ||
| for (let idx = 0; idx < max; idx++) { | ||
| const code = map.indexOf(data.charAt(idx)) | ||
| // Skip CR/LF | ||
| if (code > 64) continue; | ||
| if (code > 64) continue | ||
| // Fail on illegal characters | ||
| if (code < 0) return false; | ||
| if (code < 0) return false | ||
| bitlen += 6; | ||
| bitlen += 6 | ||
| } | ||
| // If there are any bits left, source was corrupted | ||
| return (bitlen % 8) === 0; | ||
| return (bitlen % 8) === 0 | ||
| } | ||
| function constructYamlBinary(data) { | ||
| var idx, tailbits, | ||
| input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan | ||
| max = input.length, | ||
| map = BASE64_MAP, | ||
| bits = 0, | ||
| result = []; | ||
| function constructYamlBinary (data) { | ||
| const input = data.replace(/[\r\n=]/g, '') // remove CR/LF & padding to simplify scan | ||
| const max = input.length | ||
| const map = BASE64_MAP | ||
| let bits = 0 | ||
| const result = [] | ||
| // Collect by 6*4 bits (3 bytes) | ||
| for (idx = 0; idx < max; idx++) { | ||
| for (let idx = 0; idx < max; idx++) { | ||
| if ((idx % 4 === 0) && idx) { | ||
| result.push((bits >> 16) & 0xFF); | ||
| result.push((bits >> 8) & 0xFF); | ||
| result.push(bits & 0xFF); | ||
| result.push((bits >> 16) & 0xFF) | ||
| result.push((bits >> 8) & 0xFF) | ||
| result.push(bits & 0xFF) | ||
| } | ||
| bits = (bits << 6) | map.indexOf(input.charAt(idx)); | ||
| bits = (bits << 6) | map.indexOf(input.charAt(idx)) | ||
| } | ||
@@ -57,34 +53,35 @@ | ||
| tailbits = (max % 4) * 6; | ||
| const tailbits = (max % 4) * 6 | ||
| if (tailbits === 0) { | ||
| result.push((bits >> 16) & 0xFF); | ||
| result.push((bits >> 8) & 0xFF); | ||
| result.push(bits & 0xFF); | ||
| result.push((bits >> 16) & 0xFF) | ||
| result.push((bits >> 8) & 0xFF) | ||
| result.push(bits & 0xFF) | ||
| } else if (tailbits === 18) { | ||
| result.push((bits >> 10) & 0xFF); | ||
| result.push((bits >> 2) & 0xFF); | ||
| result.push((bits >> 10) & 0xFF) | ||
| result.push((bits >> 2) & 0xFF) | ||
| } else if (tailbits === 12) { | ||
| result.push((bits >> 4) & 0xFF); | ||
| result.push((bits >> 4) & 0xFF) | ||
| } | ||
| return new Uint8Array(result); | ||
| return new Uint8Array(result) | ||
| } | ||
| function representYamlBinary(object /*, style*/) { | ||
| var result = '', bits = 0, idx, tail, | ||
| max = object.length, | ||
| map = BASE64_MAP; | ||
| function representYamlBinary (object /*, style */) { | ||
| let result = '' | ||
| let bits = 0 | ||
| const max = object.length | ||
| const map = BASE64_MAP | ||
| // Convert every three bytes to 4 ASCII characters. | ||
| for (idx = 0; idx < max; idx++) { | ||
| for (let idx = 0; idx < max; idx++) { | ||
| if ((idx % 3 === 0) && idx) { | ||
| result += map[(bits >> 18) & 0x3F]; | ||
| result += map[(bits >> 12) & 0x3F]; | ||
| result += map[(bits >> 6) & 0x3F]; | ||
| result += map[bits & 0x3F]; | ||
| result += map[(bits >> 18) & 0x3F] | ||
| result += map[(bits >> 12) & 0x3F] | ||
| result += map[(bits >> 6) & 0x3F] | ||
| result += map[bits & 0x3F] | ||
| } | ||
| bits = (bits << 8) + object[idx]; | ||
| bits = (bits << 8) + object[idx] | ||
| } | ||
@@ -94,26 +91,26 @@ | ||
| tail = max % 3; | ||
| const tail = max % 3 | ||
| if (tail === 0) { | ||
| result += map[(bits >> 18) & 0x3F]; | ||
| result += map[(bits >> 12) & 0x3F]; | ||
| result += map[(bits >> 6) & 0x3F]; | ||
| result += map[bits & 0x3F]; | ||
| result += map[(bits >> 18) & 0x3F] | ||
| result += map[(bits >> 12) & 0x3F] | ||
| result += map[(bits >> 6) & 0x3F] | ||
| result += map[bits & 0x3F] | ||
| } else if (tail === 2) { | ||
| result += map[(bits >> 10) & 0x3F]; | ||
| result += map[(bits >> 4) & 0x3F]; | ||
| result += map[(bits << 2) & 0x3F]; | ||
| result += map[64]; | ||
| result += map[(bits >> 10) & 0x3F] | ||
| result += map[(bits >> 4) & 0x3F] | ||
| result += map[(bits << 2) & 0x3F] | ||
| result += map[64] | ||
| } else if (tail === 1) { | ||
| result += map[(bits >> 2) & 0x3F]; | ||
| result += map[(bits << 4) & 0x3F]; | ||
| result += map[64]; | ||
| result += map[64]; | ||
| result += map[(bits >> 2) & 0x3F] | ||
| result += map[(bits << 4) & 0x3F] | ||
| result += map[64] | ||
| result += map[64] | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
| function isBinary(obj) { | ||
| return Object.prototype.toString.call(obj) === '[object Uint8Array]'; | ||
| function isBinary (obj) { | ||
| return Object.prototype.toString.call(obj) === '[object Uint8Array]' | ||
| } | ||
@@ -127,2 +124,2 @@ | ||
| represent: representYamlBinary | ||
| }); | ||
| }) |
+14
-14
@@ -1,22 +0,22 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| function resolveYamlBoolean(data) { | ||
| if (data === null) return false; | ||
| function resolveYamlBoolean (data) { | ||
| if (data === null) return false | ||
| var max = data.length; | ||
| const max = data.length | ||
| return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || | ||
| (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); | ||
| (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')) | ||
| } | ||
| function constructYamlBoolean(data) { | ||
| function constructYamlBoolean (data) { | ||
| return data === 'true' || | ||
| data === 'True' || | ||
| data === 'TRUE'; | ||
| data === 'TRUE' | ||
| } | ||
| function isBoolean(object) { | ||
| return Object.prototype.toString.call(object) === '[object Boolean]'; | ||
| function isBoolean (object) { | ||
| return Object.prototype.toString.call(object) === '[object Boolean]' | ||
| } | ||
@@ -30,7 +30,7 @@ | ||
| represent: { | ||
| lowercase: function (object) { return object ? 'true' : 'false'; }, | ||
| uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, | ||
| camelcase: function (object) { return object ? 'True' : 'False'; } | ||
| lowercase: function (object) { return object ? 'true' : 'false' }, | ||
| uppercase: function (object) { return object ? 'TRUE' : 'FALSE' }, | ||
| camelcase: function (object) { return object ? 'True' : 'False' } | ||
| }, | ||
| defaultStyle: 'lowercase' | ||
| }); | ||
| }) |
+47
-45
@@ -1,78 +0,80 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var common = require('../common'); | ||
| var Type = require('../type'); | ||
| const common = require('../common') | ||
| const Type = require('../type') | ||
| var YAML_FLOAT_PATTERN = new RegExp( | ||
| const YAML_FLOAT_PATTERN = new RegExp( | ||
| // 2.5e4, 2.5 and integers | ||
| '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + | ||
| '^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?' + | ||
| // .2e4, .2 | ||
| // special case, seems not from spec | ||
| '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + | ||
| '|\\.[0-9]+(?:[eE][-+]?[0-9]+)?' + | ||
| // .inf | ||
| '|[-+]?\\.(?:inf|Inf|INF)' + | ||
| // .nan | ||
| '|\\.(?:nan|NaN|NAN))$'); | ||
| '|\\.(?:nan|NaN|NAN))$') | ||
| function resolveYamlFloat(data) { | ||
| if (data === null) return false; | ||
| const YAML_FLOAT_SPECIAL_PATTERN = new RegExp( | ||
| '^(?:' + | ||
| // .inf | ||
| '[-+]?\\.(?:inf|Inf|INF)' + | ||
| // .nan | ||
| '|\\.(?:nan|NaN|NAN))$') | ||
| if (!YAML_FLOAT_PATTERN.test(data) || | ||
| // Quick hack to not allow integers end with `_` | ||
| // Probably should update regexp & check speed | ||
| data[data.length - 1] === '_') { | ||
| return false; | ||
| function resolveYamlFloat (data) { | ||
| if (data === null) return false | ||
| if (!YAML_FLOAT_PATTERN.test(data)) { | ||
| return false | ||
| } | ||
| return true; | ||
| if (Number.isFinite(parseFloat(data, 10))) { | ||
| return true | ||
| } | ||
| return YAML_FLOAT_SPECIAL_PATTERN.test(data) | ||
| } | ||
| function constructYamlFloat(data) { | ||
| var value, sign; | ||
| function constructYamlFloat (data) { | ||
| let value = data.toLowerCase() | ||
| const sign = value[0] === '-' ? -1 : 1 | ||
| value = data.replace(/_/g, '').toLowerCase(); | ||
| sign = value[0] === '-' ? -1 : 1; | ||
| if ('+-'.indexOf(value[0]) >= 0) { | ||
| value = value.slice(1); | ||
| value = value.slice(1) | ||
| } | ||
| if (value === '.inf') { | ||
| return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; | ||
| return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY | ||
| } else if (value === '.nan') { | ||
| return NaN; | ||
| return NaN | ||
| } | ||
| return sign * parseFloat(value, 10); | ||
| return sign * parseFloat(value, 10) | ||
| } | ||
| const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/ | ||
| var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; | ||
| function representYamlFloat(object, style) { | ||
| var res; | ||
| function representYamlFloat (object, style) { | ||
| if (isNaN(object)) { | ||
| switch (style) { | ||
| case 'lowercase': return '.nan'; | ||
| case 'uppercase': return '.NAN'; | ||
| case 'camelcase': return '.NaN'; | ||
| case 'lowercase': return '.nan' | ||
| case 'uppercase': return '.NAN' | ||
| case 'camelcase': return '.NaN' | ||
| } | ||
| } else if (Number.POSITIVE_INFINITY === object) { | ||
| switch (style) { | ||
| case 'lowercase': return '.inf'; | ||
| case 'uppercase': return '.INF'; | ||
| case 'camelcase': return '.Inf'; | ||
| case 'lowercase': return '.inf' | ||
| case 'uppercase': return '.INF' | ||
| case 'camelcase': return '.Inf' | ||
| } | ||
| } else if (Number.NEGATIVE_INFINITY === object) { | ||
| switch (style) { | ||
| case 'lowercase': return '-.inf'; | ||
| case 'uppercase': return '-.INF'; | ||
| case 'camelcase': return '-.Inf'; | ||
| case 'lowercase': return '-.inf' | ||
| case 'uppercase': return '-.INF' | ||
| case 'camelcase': return '-.Inf' | ||
| } | ||
| } else if (common.isNegativeZero(object)) { | ||
| return '-0.0'; | ||
| return '-0.0' | ||
| } | ||
| res = object.toString(10); | ||
| const res = object.toString(10) | ||
@@ -82,8 +84,8 @@ // JS stringifier can build scientific format without dots: 5e-100, | ||
| return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; | ||
| return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res | ||
| } | ||
| function isFloat(object) { | ||
| function isFloat (object) { | ||
| return (Object.prototype.toString.call(object) === '[object Number]') && | ||
| (object % 1 !== 0 || common.isNegativeZero(object)); | ||
| (object % 1 !== 0 || common.isNegativeZero(object)) | ||
| } | ||
@@ -98,2 +100,2 @@ | ||
| defaultStyle: 'lowercase' | ||
| }); | ||
| }) |
+65
-79
@@ -1,35 +0,34 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var common = require('../common'); | ||
| var Type = require('../type'); | ||
| const common = require('../common') | ||
| const Type = require('../type') | ||
| function isHexCode(c) { | ||
| return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || | ||
| ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || | ||
| ((0x61/* a */ <= c) && (c <= 0x66/* f */)); | ||
| function isHexCode (c) { | ||
| return ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) || | ||
| ((c >= 0x41/* A */) && (c <= 0x46/* F */)) || | ||
| ((c >= 0x61/* a */) && (c <= 0x66/* f */)) | ||
| } | ||
| function isOctCode(c) { | ||
| return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); | ||
| function isOctCode (c) { | ||
| return ((c >= 0x30/* 0 */) && (c <= 0x37/* 7 */)) | ||
| } | ||
| function isDecCode(c) { | ||
| return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); | ||
| function isDecCode (c) { | ||
| return ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) | ||
| } | ||
| function resolveYamlInteger(data) { | ||
| if (data === null) return false; | ||
| function resolveYamlInteger (data) { | ||
| if (data === null) return false | ||
| var max = data.length, | ||
| index = 0, | ||
| hasDigits = false, | ||
| ch; | ||
| const max = data.length | ||
| let index = 0 | ||
| let hasDigits = false | ||
| if (!max) return false; | ||
| if (!max) return false | ||
| ch = data[index]; | ||
| let ch = data[index] | ||
| // sign | ||
| if (ch === '-' || ch === '+') { | ||
| ch = data[++index]; | ||
| ch = data[++index] | ||
| } | ||
@@ -39,4 +38,4 @@ | ||
| // 0 | ||
| if (index + 1 === max) return true; | ||
| ch = data[++index]; | ||
| if (index + 1 === max) return true | ||
| ch = data[++index] | ||
@@ -47,39 +46,32 @@ // base 2, base 8, base 16 | ||
| // base 2 | ||
| index++; | ||
| index++ | ||
| for (; index < max; index++) { | ||
| ch = data[index]; | ||
| if (ch === '_') continue; | ||
| if (ch !== '0' && ch !== '1') return false; | ||
| hasDigits = true; | ||
| ch = data[index] | ||
| if (ch !== '0' && ch !== '1') return false | ||
| hasDigits = true | ||
| } | ||
| return hasDigits && ch !== '_'; | ||
| return hasDigits && Number.isFinite(parseYamlInteger(data)) | ||
| } | ||
| if (ch === 'x') { | ||
| // base 16 | ||
| index++; | ||
| index++ | ||
| for (; index < max; index++) { | ||
| ch = data[index]; | ||
| if (ch === '_') continue; | ||
| if (!isHexCode(data.charCodeAt(index))) return false; | ||
| hasDigits = true; | ||
| if (!isHexCode(data.charCodeAt(index))) return false | ||
| hasDigits = true | ||
| } | ||
| return hasDigits && ch !== '_'; | ||
| return hasDigits && Number.isFinite(parseYamlInteger(data)) | ||
| } | ||
| if (ch === 'o') { | ||
| // base 8 | ||
| index++; | ||
| index++ | ||
| for (; index < max; index++) { | ||
| ch = data[index]; | ||
| if (ch === '_') continue; | ||
| if (!isOctCode(data.charCodeAt(index))) return false; | ||
| hasDigits = true; | ||
| if (!isOctCode(data.charCodeAt(index))) return false | ||
| hasDigits = true | ||
| } | ||
| return hasDigits && ch !== '_'; | ||
| return hasDigits && Number.isFinite(parseYamlInteger(data)) | ||
| } | ||
@@ -90,49 +82,44 @@ } | ||
| // value should not start with `_`; | ||
| if (ch === '_') return false; | ||
| for (; index < max; index++) { | ||
| ch = data[index]; | ||
| if (ch === '_') continue; | ||
| if (!isDecCode(data.charCodeAt(index))) { | ||
| return false; | ||
| return false | ||
| } | ||
| hasDigits = true; | ||
| hasDigits = true | ||
| } | ||
| // Should have digits and should not end with `_` | ||
| if (!hasDigits || ch === '_') return false; | ||
| if (!hasDigits) return false | ||
| return true; | ||
| return Number.isFinite(parseYamlInteger(data)) | ||
| } | ||
| function constructYamlInteger(data) { | ||
| var value = data, sign = 1, ch; | ||
| function parseYamlInteger (data) { | ||
| let value = data | ||
| let sign = 1 | ||
| if (value.indexOf('_') !== -1) { | ||
| value = value.replace(/_/g, ''); | ||
| } | ||
| let ch = value[0] | ||
| ch = value[0]; | ||
| if (ch === '-' || ch === '+') { | ||
| if (ch === '-') sign = -1; | ||
| value = value.slice(1); | ||
| ch = value[0]; | ||
| if (ch === '-') sign = -1 | ||
| value = value.slice(1) | ||
| ch = value[0] | ||
| } | ||
| if (value === '0') return 0; | ||
| if (value === '0') return 0 | ||
| if (ch === '0') { | ||
| if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); | ||
| if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); | ||
| if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); | ||
| if (value[1] === 'b') return sign * parseInt(value.slice(2), 2) | ||
| if (value[1] === 'x') return sign * parseInt(value.slice(2), 16) | ||
| if (value[1] === 'o') return sign * parseInt(value.slice(2), 8) | ||
| } | ||
| return sign * parseInt(value, 10); | ||
| return sign * parseInt(value, 10) | ||
| } | ||
| function isInteger(object) { | ||
| function constructYamlInteger (data) { | ||
| return parseYamlInteger(data) | ||
| } | ||
| function isInteger (object) { | ||
| return (Object.prototype.toString.call(object)) === '[object Number]' && | ||
| (object % 1 === 0 && !common.isNegativeZero(object)); | ||
| (object % 1 === 0 && !common.isNegativeZero(object)) | ||
| } | ||
@@ -146,15 +133,14 @@ | ||
| represent: { | ||
| binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, | ||
| octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, | ||
| decimal: function (obj) { return obj.toString(10); }, | ||
| /* eslint-disable max-len */ | ||
| hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } | ||
| binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1) }, | ||
| octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1) }, | ||
| decimal: function (obj) { return obj.toString(10) }, | ||
| hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1) } | ||
| }, | ||
| defaultStyle: 'decimal', | ||
| styleAliases: { | ||
| binary: [ 2, 'bin' ], | ||
| octal: [ 8, 'oct' ], | ||
| decimal: [ 10, 'dec' ], | ||
| hexadecimal: [ 16, 'hex' ] | ||
| binary: [2, 'bin'], | ||
| octal: [8, 'oct'], | ||
| decimal: [10, 'dec'], | ||
| hexadecimal: [16, 'hex'] | ||
| } | ||
| }); | ||
| }) |
+4
-4
@@ -1,8 +0,8 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| module.exports = new Type('tag:yaml.org,2002:map', { | ||
| kind: 'mapping', | ||
| construct: function (data) { return data !== null ? data : {}; } | ||
| }); | ||
| construct: function (data) { return data !== null ? data : {} } | ||
| }) |
@@ -1,7 +0,7 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| function resolveYamlMerge(data) { | ||
| return data === '<<' || data === null; | ||
| function resolveYamlMerge (data) { | ||
| return data === '<<' || data === null | ||
| } | ||
@@ -12,2 +12,2 @@ | ||
| resolve: resolveYamlMerge | ||
| }); | ||
| }) |
+16
-16
@@ -1,20 +0,20 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| function resolveYamlNull(data) { | ||
| if (data === null) return true; | ||
| function resolveYamlNull (data) { | ||
| if (data === null) return true | ||
| var max = data.length; | ||
| const max = data.length | ||
| return (max === 1 && data === '~') || | ||
| (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); | ||
| (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')) | ||
| } | ||
| function constructYamlNull() { | ||
| return null; | ||
| function constructYamlNull () { | ||
| return null | ||
| } | ||
| function isNull(object) { | ||
| return object === null; | ||
| function isNull (object) { | ||
| return object === null | ||
| } | ||
@@ -28,9 +28,9 @@ | ||
| represent: { | ||
| canonical: function () { return '~'; }, | ||
| lowercase: function () { return 'null'; }, | ||
| uppercase: function () { return 'NULL'; }, | ||
| camelcase: function () { return 'Null'; }, | ||
| empty: function () { return ''; } | ||
| canonical: function () { return '~' }, | ||
| lowercase: function () { return 'null' }, | ||
| uppercase: function () { return 'NULL' }, | ||
| camelcase: function () { return 'Null' }, | ||
| empty: function () { return '' } | ||
| }, | ||
| defaultStyle: 'lowercase' | ||
| }); | ||
| }) |
+22
-21
@@ -1,38 +0,39 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| var _hasOwnProperty = Object.prototype.hasOwnProperty; | ||
| var _toString = Object.prototype.toString; | ||
| const _hasOwnProperty = Object.prototype.hasOwnProperty | ||
| const _toString = Object.prototype.toString | ||
| function resolveYamlOmap(data) { | ||
| if (data === null) return true; | ||
| function resolveYamlOmap (data) { | ||
| if (data === null) return true | ||
| var objectKeys = [], index, length, pair, pairKey, pairHasKey, | ||
| object = data; | ||
| const objectKeys = [] | ||
| const object = data | ||
| for (index = 0, length = object.length; index < length; index += 1) { | ||
| pair = object[index]; | ||
| pairHasKey = false; | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| const pair = object[index] | ||
| let pairHasKey = false | ||
| if (_toString.call(pair) !== '[object Object]') return false; | ||
| if (_toString.call(pair) !== '[object Object]') return false | ||
| let pairKey | ||
| for (pairKey in pair) { | ||
| if (_hasOwnProperty.call(pair, pairKey)) { | ||
| if (!pairHasKey) pairHasKey = true; | ||
| else return false; | ||
| if (!pairHasKey) pairHasKey = true | ||
| else return false | ||
| } | ||
| } | ||
| if (!pairHasKey) return false; | ||
| if (!pairHasKey) return false | ||
| if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); | ||
| else return false; | ||
| if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey) | ||
| else return false | ||
| } | ||
| return true; | ||
| return true | ||
| } | ||
| function constructYamlOmap(data) { | ||
| return data !== null ? data : []; | ||
| function constructYamlOmap (data) { | ||
| return data !== null ? data : [] | ||
| } | ||
@@ -44,2 +45,2 @@ | ||
| construct: constructYamlOmap | ||
| }); | ||
| }) |
+24
-27
@@ -1,47 +0,44 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| var _toString = Object.prototype.toString; | ||
| const _toString = Object.prototype.toString | ||
| function resolveYamlPairs(data) { | ||
| if (data === null) return true; | ||
| function resolveYamlPairs (data) { | ||
| if (data === null) return true | ||
| var index, length, pair, keys, result, | ||
| object = data; | ||
| const object = data | ||
| result = new Array(object.length); | ||
| const result = new Array(object.length) | ||
| for (index = 0, length = object.length; index < length; index += 1) { | ||
| pair = object[index]; | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| const pair = object[index] | ||
| if (_toString.call(pair) !== '[object Object]') return false; | ||
| if (_toString.call(pair) !== '[object Object]') return false | ||
| keys = Object.keys(pair); | ||
| const keys = Object.keys(pair) | ||
| if (keys.length !== 1) return false; | ||
| if (keys.length !== 1) return false | ||
| result[index] = [ keys[0], pair[keys[0]] ]; | ||
| result[index] = [keys[0], pair[keys[0]]] | ||
| } | ||
| return true; | ||
| return true | ||
| } | ||
| function constructYamlPairs(data) { | ||
| if (data === null) return []; | ||
| function constructYamlPairs (data) { | ||
| if (data === null) return [] | ||
| var index, length, pair, keys, result, | ||
| object = data; | ||
| const object = data | ||
| const result = new Array(object.length) | ||
| result = new Array(object.length); | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| const pair = object[index] | ||
| for (index = 0, length = object.length; index < length; index += 1) { | ||
| pair = object[index]; | ||
| const keys = Object.keys(pair) | ||
| keys = Object.keys(pair); | ||
| result[index] = [ keys[0], pair[keys[0]] ]; | ||
| result[index] = [keys[0], pair[keys[0]]] | ||
| } | ||
| return result; | ||
| return result | ||
| } | ||
@@ -53,2 +50,2 @@ | ||
| construct: constructYamlPairs | ||
| }); | ||
| }) |
+4
-4
@@ -1,8 +0,8 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| module.exports = new Type('tag:yaml.org,2002:seq', { | ||
| kind: 'sequence', | ||
| construct: function (data) { return data !== null ? data : []; } | ||
| }); | ||
| construct: function (data) { return data !== null ? data : [] } | ||
| }) |
+12
-12
@@ -1,23 +0,23 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| var _hasOwnProperty = Object.prototype.hasOwnProperty; | ||
| const _hasOwnProperty = Object.prototype.hasOwnProperty | ||
| function resolveYamlSet(data) { | ||
| if (data === null) return true; | ||
| function resolveYamlSet (data) { | ||
| if (data === null) return true | ||
| var key, object = data; | ||
| const object = data | ||
| for (key in object) { | ||
| for (const key in object) { | ||
| if (_hasOwnProperty.call(object, key)) { | ||
| if (object[key] !== null) return false; | ||
| if (object[key] !== null) return false | ||
| } | ||
| } | ||
| return true; | ||
| return true | ||
| } | ||
| function constructYamlSet(data) { | ||
| return data !== null ? data : {}; | ||
| function constructYamlSet (data) { | ||
| return data !== null ? data : {} | ||
| } | ||
@@ -29,2 +29,2 @@ | ||
| construct: constructYamlSet | ||
| }); | ||
| }) |
+4
-4
@@ -1,8 +0,8 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| module.exports = new Type('tag:yaml.org,2002:str', { | ||
| kind: 'scalar', | ||
| construct: function (data) { return data !== null ? data : ''; } | ||
| }); | ||
| construct: function (data) { return data !== null ? data : '' } | ||
| }) |
+49
-49
@@ -1,46 +0,46 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var Type = require('../type'); | ||
| const Type = require('../type') | ||
| var YAML_DATE_REGEXP = new RegExp( | ||
| '^([0-9][0-9][0-9][0-9])' + // [1] year | ||
| '-([0-9][0-9])' + // [2] month | ||
| '-([0-9][0-9])$'); // [3] day | ||
| const YAML_DATE_REGEXP = new RegExp( | ||
| '^([0-9][0-9][0-9][0-9])' + // [1] year | ||
| '-([0-9][0-9])' + // [2] month | ||
| '-([0-9][0-9])$') // [3] day | ||
| var YAML_TIMESTAMP_REGEXP = new RegExp( | ||
| '^([0-9][0-9][0-9][0-9])' + // [1] year | ||
| '-([0-9][0-9]?)' + // [2] month | ||
| '-([0-9][0-9]?)' + // [3] day | ||
| '(?:[Tt]|[ \\t]+)' + // ... | ||
| '([0-9][0-9]?)' + // [4] hour | ||
| ':([0-9][0-9])' + // [5] minute | ||
| ':([0-9][0-9])' + // [6] second | ||
| '(?:\\.([0-9]*))?' + // [7] fraction | ||
| '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour | ||
| '(?::([0-9][0-9]))?))?$'); // [11] tz_minute | ||
| const YAML_TIMESTAMP_REGEXP = new RegExp( | ||
| '^([0-9][0-9][0-9][0-9])' + // [1] year | ||
| '-([0-9][0-9]?)' + // [2] month | ||
| '-([0-9][0-9]?)' + // [3] day | ||
| '(?:[Tt]|[ \\t]+)' + // ... | ||
| '([0-9][0-9]?)' + // [4] hour | ||
| ':([0-9][0-9])' + // [5] minute | ||
| ':([0-9][0-9])' + // [6] second | ||
| '(?:\\.([0-9]*))?' + // [7] fraction | ||
| '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tzHour | ||
| '(?::([0-9][0-9]))?))?$') // [11] tzMinute | ||
| function resolveYamlTimestamp(data) { | ||
| if (data === null) return false; | ||
| if (YAML_DATE_REGEXP.exec(data) !== null) return true; | ||
| if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; | ||
| return false; | ||
| function resolveYamlTimestamp (data) { | ||
| if (data === null) return false | ||
| if (YAML_DATE_REGEXP.exec(data) !== null) return true | ||
| if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true | ||
| return false | ||
| } | ||
| function constructYamlTimestamp(data) { | ||
| var match, year, month, day, hour, minute, second, fraction = 0, | ||
| delta = null, tz_hour, tz_minute, date; | ||
| function constructYamlTimestamp (data) { | ||
| let fraction = 0 | ||
| let delta = null | ||
| match = YAML_DATE_REGEXP.exec(data); | ||
| if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); | ||
| let match = YAML_DATE_REGEXP.exec(data) | ||
| if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data) | ||
| if (match === null) throw new Error('Date resolve error'); | ||
| if (match === null) throw new Error('Date resolve error') | ||
| // match: [1] year [2] month [3] day | ||
| year = +(match[1]); | ||
| month = +(match[2]) - 1; // JS month starts with 0 | ||
| day = +(match[3]); | ||
| const year = +(match[1]) | ||
| const month = +(match[2]) - 1 // JS month starts with 0 | ||
| const day = +(match[3]) | ||
| if (!match[4]) { // no hour | ||
| return new Date(Date.UTC(year, month, day)); | ||
| return new Date(Date.UTC(year, month, day)) | ||
| } | ||
@@ -50,32 +50,32 @@ | ||
| hour = +(match[4]); | ||
| minute = +(match[5]); | ||
| second = +(match[6]); | ||
| const hour = +(match[4]) | ||
| const minute = +(match[5]) | ||
| const second = +(match[6]) | ||
| if (match[7]) { | ||
| fraction = match[7].slice(0, 3); | ||
| fraction = match[7].slice(0, 3) | ||
| while (fraction.length < 3) { // milli-seconds | ||
| fraction += '0'; | ||
| fraction += '0' | ||
| } | ||
| fraction = +fraction; | ||
| fraction = +fraction | ||
| } | ||
| // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute | ||
| // match: [8] tz [9] tz_sign [10] tzHour [11] tzMinute | ||
| if (match[9]) { | ||
| tz_hour = +(match[10]); | ||
| tz_minute = +(match[11] || 0); | ||
| delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds | ||
| if (match[9] === '-') delta = -delta; | ||
| const tzHour = +(match[10]) | ||
| const tzMinute = +(match[11] || 0) | ||
| delta = (tzHour * 60 + tzMinute) * 60000 // delta in mili-seconds | ||
| if (match[9] === '-') delta = -delta | ||
| } | ||
| date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); | ||
| const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)) | ||
| if (delta) date.setTime(date.getTime() - delta); | ||
| if (delta) date.setTime(date.getTime() - delta) | ||
| return date; | ||
| return date | ||
| } | ||
| function representYamlTimestamp(object /*, style*/) { | ||
| return object.toISOString(); | ||
| function representYamlTimestamp (object /*, style */) { | ||
| return object.toISOString() | ||
| } | ||
@@ -89,2 +89,2 @@ | ||
| represent: representYamlTimestamp | ||
| }); | ||
| }) |
+32
-21
| { | ||
| "name": "js-yaml", | ||
| "version": "4.1.1", | ||
| "version": "4.2.0", | ||
| "description": "YAML 1.2 parser and serializer", | ||
@@ -19,2 +19,12 @@ "keywords": [ | ||
| "repository": "nodeca/js-yaml", | ||
| "funding": [ | ||
| { | ||
| "type": "github", | ||
| "url": "https://github.com/sponsors/puzrin" | ||
| }, | ||
| { | ||
| "type": "github", | ||
| "url": "https://github.com/sponsors/nodeca" | ||
| } | ||
| ], | ||
| "files": [ | ||
@@ -39,8 +49,12 @@ "index.js", | ||
| "lint": "eslint .", | ||
| "test": "npm run lint && mocha", | ||
| "coverage": "npm run lint && nyc mocha && nyc report --reporter html", | ||
| "demo": "npm run lint && node support/build_demo.js", | ||
| "gh-demo": "npm run demo && gh-pages -d demo -f", | ||
| "browserify": "rollup -c support/rollup.config.js", | ||
| "prepublishOnly": "npm run gh-demo" | ||
| "lint-fix": "eslint . --fix", | ||
| "test": "npm run lint && npm run test:core && npm run test:build", | ||
| "test:core": "node --test test/core/*.test.*", | ||
| "test:build": "npm run build && node --test test/build/*.test.*", | ||
| "coverage": "npm run build && c8 --include 'lib/**' -r text -r html -r lcov node --test test/core/*.test.*", | ||
| "build": "node support/build-dist.mjs", | ||
| "build:demo": "npm run lint && node support/build_demo.mjs", | ||
| "gh-demo": "npm run build:demo && gh-pages -d demo -f", | ||
| "prepack": "npm test && npm run build && npm run build:demo", | ||
| "postpublish": "npm run gh-demo" | ||
| }, | ||
@@ -53,17 +67,14 @@ "unpkg": "dist/js-yaml.min.js", | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^17.0.0", | ||
| "@rollup/plugin-node-resolve": "^11.0.0", | ||
| "ansi": "^0.3.1", | ||
| "benchmark": "^2.1.4", | ||
| "codemirror": "^5.13.4", | ||
| "eslint": "^7.0.0", | ||
| "fast-check": "^2.8.0", | ||
| "gh-pages": "^3.1.0", | ||
| "mocha": "^8.2.1", | ||
| "nyc": "^15.1.0", | ||
| "rollup": "^2.34.1", | ||
| "rollup-plugin-node-polyfills": "^0.2.1", | ||
| "rollup-plugin-terser": "^7.0.2", | ||
| "shelljs": "^0.8.4" | ||
| "c8": "^11.0.0", | ||
| "codemirror": "^5.65.21", | ||
| "eslint": "^9.39.4", | ||
| "fast-check": "^4.8.0", | ||
| "gh-pages": "^6.3.0", | ||
| "neostandard": "^0.13.0", | ||
| "tinybench": "^6.0.2", | ||
| "vite": "^8.0.14", | ||
| "vite-plugin-node-polyfills": "^0.28.0", | ||
| "vite-plugin-singlefile": "^2.3.3", | ||
| "workerpool": "^10.0.2" | ||
| } | ||
| } |
+4
-20
| JS-YAML - YAML 1.2 parser / writer for JavaScript | ||
| ================================================= | ||
| [](https://github.com/nodeca/js-yaml/actions) | ||
| [](https://github.com/nodeca/js-yaml/actions/workflows/ci.yml) | ||
| [](https://www.npmjs.org/package/js-yaml) | ||
@@ -91,2 +91,5 @@ | ||
| - `json` _(default: false)_ - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error. | ||
| - `maxDepth` _(default: 100)_ - limits nesting depth for collections. | ||
| - `maxMergeSeqLength` _(default: 20)_ - limits the number of elements in merge | ||
| (`<<`) sequences. | ||
@@ -230,20 +233,1 @@ NOTE: This function **does not** understand multi-document sources, it throws | ||
| ``` | ||
| Also, reading of properties on implicit block mapping keys is not supported yet. | ||
| So, the following YAML document cannot be loaded. | ||
| ``` yaml | ||
| &anchor foo: | ||
| foo: bar | ||
| *anchor: duplicate key | ||
| baz: bat | ||
| *anchor: duplicate key | ||
| ``` | ||
| js-yaml for enterprise | ||
| ---------------------- | ||
| Available as part of the Tidelift Subscription | ||
| The maintainers of js-yaml and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-js-yaml?utm_source=npm-js-yaml&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
873981
126.26%11
-21.43%36
12.5%8273
-12.86%232
-6.45%