Comparing version 3.0.2 to 3.1.0
/*! | ||
* Hjson v3.0.2 | ||
* Hjson v3.1.0 | ||
* http://hjson.org | ||
@@ -517,3 +517,3 @@ * | ||
next(); | ||
if (allowML && ch === "'" && string.length === 0) { | ||
if (allowML && exitCh === "'" && ch === "'" && string.length === 0) { | ||
// ''' indicates a multiline string | ||
@@ -918,13 +918,3 @@ next(); | ||
// options | ||
var eol = common.EOL; | ||
var indent = ' '; | ||
var keepComments = false; | ||
var bracesSameLine = false; | ||
var quoteKeys = false; | ||
var quoteStrings = false; | ||
var multiline = 1; // std=1, no-tabs=2, off=0 | ||
var separator = ''; // comma separator | ||
var dsfDef = null; | ||
var token = { | ||
var plainToken = { | ||
obj: [ '{', '}' ], | ||
@@ -934,3 +924,4 @@ arr: [ '[', ']' ], | ||
qkey: [ '"', '"' ], | ||
col: [ ':' ], | ||
col: [ ':', '' ], | ||
com: [ ',', '' ], | ||
str: [ '', '' ], | ||
@@ -947,2 +938,15 @@ qstr: [ '"', '"' ], | ||
// options | ||
var eol = common.EOL; | ||
var indent = ' '; | ||
var keepComments = false; | ||
var bracesSameLine = false; | ||
var quoteKeys = false; | ||
var quoteStrings = false; | ||
var condense = 0; | ||
var multiline = 1; // std=1, no-tabs=2, off=0 | ||
var separator = ''; // comma separator | ||
var dsfDef = null; | ||
var token = plainToken; | ||
if (opt && typeof opt === 'object') { | ||
@@ -953,2 +957,3 @@ opt.quotes = opt.quotes === 'always' ? 'strings' : opt.quotes; // legacy | ||
keepComments = opt.keepWsc; | ||
condense = opt.condense || 0; | ||
bracesSameLine = opt.bracesSameLine; | ||
@@ -959,3 +964,3 @@ quoteKeys = opt.quotes === 'all' || opt.quotes === 'keys'; | ||
else multiline = opt.multiline == 'no-tabs' ? 2 : 1; | ||
separator = opt.separator === true ? ',' : ''; | ||
separator = opt.separator === true ? token.com[0] : ''; | ||
dsfDef = opt.dsf; | ||
@@ -978,3 +983,4 @@ | ||
qkey: [ '\x1b[33m"', '"\x1b[0m' ], | ||
col: [ '\x1b[37m:\x1b[0m' ], | ||
col: [ '\x1b[37m:\x1b[0m', '' ], | ||
com: [ '\x1b[37m,\x1b[0m', '' ], | ||
str: [ '\x1b[37;1m', '\x1b[0m' ], | ||
@@ -991,2 +997,8 @@ qstr: [ '\x1b[37;1m"', '"\x1b[0m' ], | ||
} | ||
var i, ckeys=Object.keys(plainToken); | ||
for (i = ckeys.length - 1; i >= 0; i--) { | ||
var k = ckeys[i]; | ||
token[k].push(plainToken[k][0].length, plainToken[k][1].length); | ||
} | ||
} | ||
@@ -1018,4 +1030,9 @@ | ||
var gap = ''; | ||
// | ||
var wrapLen = 0; | ||
function wrap(tk, v) { return tk[0] + v + tk[1]; } | ||
function wrap(tk, v) { | ||
wrapLen += tk[0].length + tk[1].length - tk[2] - tk[3]; | ||
return tk[0] + v + tk[1]; | ||
} | ||
@@ -1149,6 +1166,13 @@ function quoteReplace(string) { | ||
var partial = []; | ||
var setsep; | ||
// condense helpers: | ||
var cpartial = condense ? [] : null; | ||
var saveQuoteStrings = quoteStrings, saveMultiline = multiline; | ||
var iseparator = separator ? '' : token.com[0]; | ||
var cwrapLen = 0; | ||
var i, length; // loop | ||
var k, v; // key, value | ||
var k, v, vs; // key, value | ||
var c, ca; | ||
var res, cres; | ||
@@ -1160,2 +1184,3 @@ if (isArray) { | ||
for (i = 0, length = value.length; i < length; i++) { | ||
setsep = i < length -1; | ||
if (comments) { | ||
@@ -1165,14 +1190,31 @@ c = comments.a[i]||[]; | ||
partial.push(makeComment(c[0], "\n") + eolGap); | ||
if (cpartial && (c[0] || c[1] || ca)) cpartial = null; | ||
} | ||
partial.push(str(value[i], comments ? ca : false, true) + (i < length -1 ? separator : '') || wrap(token.lit, 'null')); | ||
else partial.push(eolGap); | ||
wrapLen = 0; | ||
v = value[i]; | ||
partial.push(str(v, comments ? ca : false, true) + (setsep ? separator : '')); | ||
if (cpartial) { | ||
// prepare the condensed version | ||
switch (typeof v) { | ||
case 'string': | ||
wrapLen = 0; | ||
quoteStrings = true; multiline = 0; | ||
cpartial.push(str(v, false, true) + (setsep ? token.com[0] : '')); | ||
quoteStrings = saveQuoteStrings; multiline = saveMultiline; | ||
break; | ||
case 'object': if (v) { cpartial = null; break; } // falls through | ||
default: cpartial.push(partial[partial.length - 1] + (setsep ? iseparator : '')); break; | ||
} | ||
if (setsep) wrapLen += token.com[0].length - token.com[2]; | ||
cwrapLen += wrapLen; | ||
} | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
} | ||
if (comments) { | ||
if (length === 0) { | ||
// when empty | ||
partial.push((comments.e ? makeComment(comments.e[0], "\n") : "") + eolMind); | ||
} | ||
else partial.push(eolMind); | ||
if (length === 0) { | ||
// when empty | ||
if (comments && comments.e) partial.push(makeComment(comments.e[0], "\n") + eolMind); | ||
} | ||
else partial.push(eolMind); | ||
@@ -1182,51 +1224,70 @@ // Join all of the elements together, separated with newline, and wrap them in | ||
if (comments) v = prefix + wrap(token.arr, partial.join('')); | ||
else if (partial.length === 0) v = wrap(token.arr, ''); | ||
else v = prefix + wrap(token.arr, eolGap + partial.join(eolGap) + eolMind); | ||
if (partial.length === 0) res = wrap(token.arr, ''); | ||
else { | ||
res = prefix + wrap(token.arr, partial.join('')); | ||
// try if the condensed version can fit (parent key name is not included) | ||
if (cpartial) { | ||
cres = cpartial.join(' '); | ||
if (cres.length - cwrapLen <= condense) res = wrap(token.arr, cres); | ||
} | ||
} | ||
} else { | ||
// Otherwise, iterate through all of the keys in the object. | ||
var keys; | ||
var keys = comments ? comments.o.slice() : []; | ||
for (k in value) { | ||
if (Object.prototype.hasOwnProperty.call(value, k) && keys.indexOf(k) < 0) | ||
keys.push(k); | ||
} | ||
if (comments) { | ||
keys = comments.o.slice(); | ||
for (k in value) { | ||
if (Object.prototype.hasOwnProperty.call(value, k) && keys.indexOf(k) < 0) | ||
keys.push(k); | ||
} | ||
for (i = 0, length = keys.length; i < length; i++) { | ||
k = keys[i]; | ||
for (i = 0, length = keys.length; i < length; i++) { | ||
setsep = i < length - 1; | ||
k = keys[i]; | ||
if (comments) { | ||
c = comments.c[k]||[]; | ||
ca = commentOnThisLine(c[1]); | ||
partial.push(makeComment(c[0], "\n") + eolGap); | ||
v = str(value[k], ca); | ||
if (v) partial.push(quoteKey(k) + token.col + (startsWithNL(v) ? '' : ' ') + v + (i < length - 1 ? separator : '')); | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
if (cpartial && (c[0] || c[1] || ca)) cpartial = null; | ||
} | ||
if (length === 0) { | ||
// when empty | ||
partial.push((comments.e ? makeComment(comments.e[0], "\n") : "") + eolMind); | ||
} | ||
else partial.push(eolMind); | ||
else partial.push(eolGap); | ||
} else { | ||
keys = Object.keys(value); | ||
for (i = 0, length = keys.length; i < length; i++) { | ||
k = keys[i]; | ||
if (Object.prototype.hasOwnProperty.call(value, k)) { | ||
v = str(value[k]); | ||
if (v) partial.push(quoteKey(k) + token.col + (startsWithNL(v) ? '' : ' ') + v + (i < length - 1 ? separator : '')); | ||
wrapLen = 0; | ||
v = value[k]; | ||
vs = str(v, comments && ca); | ||
partial.push(quoteKey(k) + token.col[0] + (startsWithNL(vs) ? '' : ' ') + vs + (setsep ? separator : '')); | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
if (cpartial) { | ||
// prepare the condensed version | ||
switch (typeof v) { | ||
case 'string': | ||
wrapLen = 0; | ||
quoteStrings = true; multiline = 0; | ||
vs = str(v, false); | ||
quoteStrings = saveQuoteStrings; multiline = saveMultiline; | ||
cpartial.push(quoteKey(k) + token.col[0] + ' ' + vs + (setsep ? token.com[0] : '')); | ||
break; | ||
case 'object': if (v) { cpartial = null; break; } // falls through | ||
default: cpartial.push(partial[partial.length - 1] + (setsep ? iseparator : '')); break; | ||
} | ||
wrapLen += token.col[0].length - token.col[2]; | ||
if (setsep) wrapLen += token.com[0].length - token.com[2]; | ||
cwrapLen += wrapLen; | ||
} | ||
} | ||
if (length === 0) { | ||
// when empty | ||
if (comments && comments.e) partial.push(makeComment(comments.e[0], "\n") + eolMind); | ||
} | ||
else partial.push(eolMind); | ||
// Join all of the member texts together, separated with newlines | ||
if (partial.length === 0) { | ||
v = wrap(token.obj, ''); | ||
res = wrap(token.obj, ''); | ||
} else { | ||
// and wrap them in braces | ||
if (comments) v = prefix + wrap(token.obj, partial.join('')); | ||
else v = prefix + wrap(token.obj, eolGap + partial.join(eolGap) + eolMind); | ||
res = prefix + wrap(token.obj, partial.join('')); | ||
// try if the condensed version can fit | ||
if (cpartial) { | ||
cres = cpartial.join(' '); | ||
if (cres.length - cwrapLen <= condense) res = wrap(token.obj, cres); | ||
} | ||
} | ||
@@ -1236,3 +1297,3 @@ } | ||
gap = mind; | ||
return v; | ||
return res; | ||
} | ||
@@ -1257,7 +1318,7 @@ } | ||
},{"./hjson-common":2,"./hjson-dsf":3}],6:[function(require,module,exports){ | ||
module.exports="3.0.2"; | ||
module.exports="3.1.0"; | ||
},{}],7:[function(require,module,exports){ | ||
/*! | ||
* Hjson v3.0.2 | ||
* Hjson v3.1.0 | ||
* http://hjson.org | ||
@@ -1302,2 +1363,6 @@ * | ||
condense integer, will try to fit objects/arrays onto one line | ||
when the output is shorter than condense characters | ||
and the fragment contains no comments. Default 0 (off). | ||
bracesSameLine | ||
@@ -1307,5 +1372,2 @@ boolean, makes braces appear on the same line as the key | ||
emitRootBraces | ||
obsolete: will always emit braces | ||
quotes string, controls how strings are displayed. | ||
@@ -1338,2 +1400,5 @@ setting separator implies "strings" | ||
dsf array of DSF (see Hjson.dsf) | ||
emitRootBraces | ||
obsolete: will always emit braces | ||
} | ||
@@ -1340,0 +1405,0 @@ |
/*! | ||
* Hjson v3.0.2 | ||
* Hjson v3.1.0 | ||
* http://hjson.org | ||
@@ -12,4 +12,4 @@ * | ||
*/ | ||
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.Hjson=n()}}(function(){return function n(r,e,t){function o(a,u){if(!e[a]){if(!r[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=e[a]={exports:{}};r[a][0].call(c.exports,function(n){var e=r[a][1][n];return o(e?e:n)},c,c.exports,n,r,e,t)}return e[a].exports}for(var i="function"==typeof require&&require,a=0;a<t.length;a++)o(t[a]);return o}({1:[function(n,r,e){"use strict";function t(n,r,e){var t;return n&&(t={b:n}),r&&((t=t||{}).a=r),e&&((t=t||{}).x=e),t}function o(n,r){if(null!==n&&"object"==typeof n){var e=p.getComment(n);e&&p.removeComment(n);var i,a,s,f;if("[object Array]"===Object.prototype.toString.apply(n)){for(f={a:[]},i=0,a=n.length;i<a;i++)u(f.a,i,e.a[i],o(n[i]))&&(s=!0);!s&&e.e&&(f.e=t(e.e[0],e.e[1]),s=!0)}else{f={s:{}};var c,l=Object.keys(n);for(e&&e.o?(c=[],e.o.concat(l).forEach(function(r){Object.prototype.hasOwnProperty.call(n,r)&&c.indexOf(r)<0&&c.push(r)})):c=l,f.o=c,i=0,a=c.length;i<a;i++){var h=c[i];u(f.s,h,e.c[h],o(n[h]))&&(s=!0)}!s&&e.e&&(f.e=t(e.e[0],e.e[1]),s=!0)}return r&&e&&e.r&&(f.r=t(e.r[0],e.r[1])),s?f:void 0}}function i(){var n="";return[].forEach.call(arguments,function(r){r&&""!==r.trim()&&(n&&(n+="; "),n+=r.trim())}),n}function a(n,r){var e=[];if(c(n,r,e,[]),e.length>0){var t=l(r,null,1);t+="\n# Orphaned comments:\n",e.forEach(function(n){t+=("# "+n.path.join("/")+": "+i(n.b,n.a,n.e)).replace("\n","\\n ")+"\n"}),l(r,t,1)}}function u(n,r,e,o){var i=t(e?e[0]:void 0,e?e[1]:void 0,o);return i&&(n[r]=i),i}function s(n,r){var e=t(r.b,r.a);return e.path=n,e}function f(n,r,e){if(n){var t,o;if(n.a)for(t=0,o=n.a.length;t<o;t++){var i=e.slice().concat([t]),a=n.a[t];a&&(r.push(s(i,a)),f(a.x,r,i))}else n.o&&n.o.forEach(function(t){var o=e.slice().concat([t]),i=n.s[t];i&&(r.push(s(o,i)),f(i.x,r,o))});n.e&&r.push(s(e,n.e))}}function c(n,r,e,t){if(n){if(null===r||"object"!=typeof r)return void f(n,e,t);var o,i,a=p.createComment(r);if(0===t.length&&n.r&&(a.r=[n.r.b,n.r.a]),"[object Array]"===Object.prototype.toString.apply(r)){for(a.a=[],o=0,i=(n.a||[]).length;o<i;o++){var u=t.slice().concat([o]),l=n.a[o];l&&(o<r.length?(a.a.push([l.b,l.a]),c(l.x,r[o],e,u)):(e.push(s(u,l)),f(l.x,e,u)))}0===o&&n.e&&(a.e=[n.e.b,n.e.a])}else a.c={},a.o=[],(n.o||[]).forEach(function(o){var i=t.slice().concat([o]),u=n.s[o];Object.prototype.hasOwnProperty.call(r,o)?(a.o.push(o),u&&(a.c[o]=[u.b,u.a],c(u.x,r[o],e,i))):u&&(e.push(s(i,u)),f(u.x,e,i))}),n.e&&(a.e=[n.e.b,n.e.a])}}function l(n,r,e){var t=p.createComment(n,p.getComment(n));return t.r||(t.r=["",""]),(r||""===r)&&(t.r[e]=p.forceComment(r)),t.r[e]||""}var p=n("./hjson-common");r.exports={extract:function(n){return o(n,!0)},merge:a,header:function(n,r){return l(n,r,0)},footer:function(n,r){return l(n,r,1)}}},{"./hjson-common":2}],2:[function(n,r,e){"use strict";function t(n,r){function e(){return o=n.charAt(s),s++,o}var t,o,i="",a=0,u=!0,s=0;for(e(),"-"===o&&(i="-",e());o>="0"&&o<="9";)u&&("0"==o?a++:u=!1),i+=o,e();if(u&&a--,"."===o)for(i+=".";e()&&o>="0"&&o<="9";)i+=o;if("e"===o||"E"===o)for(i+=o,e(),"-"!==o&&"+"!==o||(i+=o,e());o>="0"&&o<="9";)i+=o,e();for(;o&&o<=" ";)e();return r&&(","!==o&&"}"!==o&&"]"!==o&&"#"!==o&&("/"!==o||"/"!==n[s]&&"*"!==n[s])||(o=0)),t=+i,o||a||!isFinite(t)?void 0:t}function o(n,r){return Object.defineProperty&&Object.defineProperty(n,"__COMMENTS__",{enumerable:!1,writable:!0}),n.__COMMENTS__=r||{}}function i(n){Object.defineProperty(n,"__COMMENTS__",{value:void 0})}function a(n){return n.__COMMENTS__}function u(n){if(!n)return"";var r,e,t,o,i=n.split("\n");for(t=0;t<i.length;t++)for(r=i[t],o=r.length,e=0;e<o;e++){var a=r[e];if("#"===a)break;if("/"===a&&("/"===r[e+1]||"*"===r[e+1])){"*"===r[e+1]&&(t=i.length);break}if(a>" "){i[t]="# "+r;break}}return i.join("\n")}var s=n("os");r.exports={EOL:s.EOL||"\n",tryParseNumber:t,createComment:o,removeComment:i,getComment:a,forceComment:u}},{os:8}],3:[function(n,r,e){"use strict";function t(n,r){function e(n){return"[object Function]"==={}.toString.call(n)}if("[object Array]"!==Object.prototype.toString.apply(n)){if(n)throw new Error("dsf option must contain an array!");return i}if(0===n.length)return i;var t=[];return n.forEach(function(n){if(!n.name||!e(n.parse)||!e(n.stringify))throw new Error("extension does not match the DSF interface");t.push(function(){try{if("parse"==r)return n.parse.apply(null,arguments);if("stringify"==r){var e=n.stringify.apply(null,arguments);if(void 0!==e&&("string"!=typeof e||0===e.length||'"'===e[0]||[].some.call(e,function(n){return a(n)})))throw new Error("value may not be empty, start with a quote or contain a punctuator character except colon: "+e);return e}throw new Error("Invalid type")}catch(r){throw new Error("DSF-"+n.name+" failed; "+r.message)}})}),o.bind(null,t)}function o(n,r){if(n)for(var e=0;e<n.length;e++){var t=n[e](r);if(void 0!==t)return t}}function i(){}function a(n){return"{"===n||"}"===n||"["===n||"]"===n||","===n}function u(){return{name:"math",parse:function(n){switch(n){case"+inf":case"inf":case"+Inf":case"Inf":return 1/0;case"-inf":case"-Inf":return-(1/0);case"nan":case"NaN":return NaN}},stringify:function(n){if("number"==typeof n)return 1/n===-(1/0)?"-0":n===1/0?"Inf":n===-(1/0)?"-Inf":isNaN(n)?"NaN":void 0}}}function s(n){var r=n&&n.out;return{name:"hex",parse:function(n){if(/^0x[0-9A-Fa-f]+$/.test(n))return parseInt(n,16)},stringify:function(n){if(r&&Number.isInteger(n))return"0x"+n.toString(16)}}}function f(){return{name:"date",parse:function(n){if(/^\d{4}-\d{2}-\d{2}$/.test(n)||/^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}(?:.\d+)(?:Z|[+-]\d{2}:\d{2})$/.test(n)){var r=Date.parse(n);if(!isNaN(r))return new Date(r)}},stringify:function(n){if("[object Date]"===Object.prototype.toString.call(n)){var r=n.toISOString();return r.indexOf("T00:00:00.000Z",r.length-14)!==-1?r.substr(0,10):r}}}}u.description="support for Inf/inf, -Inf/-inf, Nan/naN and -0",s.description="parse hexadecimal numbers prefixed with 0x",f.description="support ISO dates",r.exports={loadDsf:t,std:{math:u,hex:s,date:f}}},{}],4:[function(n,r,e){"use strict";r.exports=function(r,e){function t(){x=0,O=" "}function o(n){return"{"===n||"}"===n||"["===n||"]"===n||","===n||":"===n}function i(n){var r,e=0,t=1;for(r=x-1;r>0&&"\n"!==w[r];r--,e++);for(;r>0;r--)"\n"===w[r]&&t++;throw new Error(n+" at line "+t+","+e+" >>>"+w.substr(x-e,20)+" ...")}function a(){return O=w.charAt(x),x++,O}function u(n){return w.charAt(x+n)}function s(n){for(var r="",e=O;a();){if(O===e)return a(),n&&"'"===O&&0===r.length?(a(),f()):r;if("\\"===O)if(a(),"u"===O){for(var t=0,o=0;o<4;o++){a();var u,s=O.charCodeAt(0);O>="0"&&O<="9"?u=s-48:O>="a"&&O<="f"?u=s-97+10:O>="A"&&O<="F"?u=s-65+10:i("Bad \\u char "+O),t=16*t+u}r+=String.fromCharCode(t)}else{if("string"!=typeof S[O])break;r+=S[O]}else"\n"===O||"\r"===O?i("Bad string containing newline"):r+=O}i("Bad string")}function f(){function n(){for(var n=t;O&&O<=" "&&"\n"!==O&&n-- >0;)a()}for(var r="",e=0,t=0;;){var o=u(-t-5);if(!o||"\n"===o)break;t++}for(;O&&O<=" "&&"\n"!==O;)a();for("\n"===O&&(a(),n());;){if(O){if("'"===O){if(e++,a(),3===e)return"\n"===r.slice(-1)&&(r=r.slice(0,-1)),r;continue}for(;e>0;)r+="'",e--}else i("Bad multiline string");"\n"===O?(r+="\n",a(),n()):("\r"!==O&&(r+=O),a())}}function c(){if('"'===O||"'"===O)return s(!1);for(var n="",r=x,e=-1;;){if(":"===O)return n?e>=0&&e!==n.length&&(x=r+e,i("Found whitespace in your key name (use quotes to include)")):i("Found ':' but no key name (for an empty key name use quotes)"),n;O<=" "?O?e<0&&(e=n.length):i("Found EOF while looking for a key name (check your syntax)"):o(O)?i("Found '"+O+"' where a key name was expected (check your syntax or use quotes if the key name includes {}[],: or whitespace)"):n+=O,a()}}function l(){for(;O;){for(;O&&O<=" ";)a();if("#"===O||"/"===O&&"/"===u(0))for(;O&&"\n"!==O;)a();else{if("/"!==O||"*"!==u(0))break;for(a(),a();O&&("*"!==O||"/"!==u(0));)a();O&&(a(),a())}}}function p(){var n=O;for(o(O)&&i("Found a punctuator character '"+O+"' when expecting a quoteless string (check your syntax)");;){a();var r="\r"===O||"\n"===O||""===O;if(r||","===O||"}"===O||"]"===O||"#"===O||"/"===O&&("/"===u(0)||"*"===u(0))){var e=n[0];switch(e){case"f":if("false"===n.trim())return!1;break;case"n":if("null"===n.trim())return null;break;case"t":if("true"===n.trim())return!0;break;default:if("-"===e||e>="0"&&e<="9"){var t=C.tryParseNumber(n);if(void 0!==t)return t}}if(r){n=n.trim();var s=E(n);return void 0!==s?s:n}}n+=O}}function h(n,r){var e;for(n--,e=x-2;e>n&&w[e]<=" "&&"\n"!==w[e];e--);"\n"===w[e]&&e--,"\r"===w[e]&&e--;var t=w.substr(n,e-n+1);for(e=0;e<t.length;e++)if(t[e]>" "){var o=t.indexOf("\n");if(o>=0){var i=[t.substr(0,o),t.substr(o+1)];return r&&0===i[0].trim().length&&i.shift(),i}return[t]}return[]}function m(n){function r(n,e){var t,o,i,a;switch(typeof n){case"string":n.indexOf(e)>=0&&(a=n);break;case"object":if("[object Array]"===Object.prototype.toString.apply(n))for(t=0,i=n.length;t<i;t++)a=r(n[t],e)||a;else for(o in n)Object.prototype.hasOwnProperty.call(n,o)&&(a=r(n[o],e)||a)}return a}function e(e){var t=r(n,e);return t?"found '"+e+"' in a string value, your mistake could be with:\n > "+t+"\n (unquoted strings contain everything up to the next line!)":""}return e("}")||e("]")}function d(){var n,r,e,t=[];try{if(k&&(n=C.createComment(t,{a:[]})),a(),r=x,l(),n&&(e=h(r,!0).join("\n")),"]"===O)return a(),n&&(n.e=[e]),t;for(;O;){if(t.push(v()),r=x,l(),","===O&&(a(),r=x,l()),n){var o=h(r);n.a.push([e||"",o[0]||""]),e=o[1]}if("]"===O)return a(),n&&(n.a[n.a.length-1][1]+=e||""),t;l()}i("End of input while parsing an array (missing ']')")}catch(n){throw n.hint=n.hint||m(t),n}}function y(n){var r,e,t,o="",u={};try{if(k&&(r=C.createComment(u,{c:{},o:[]})),n?e=1:(a(),e=x),l(),r&&(t=h(e,!0).join("\n")),"}"===O&&!n)return r&&(r.e=[t]),a(),u;for(;O;){if(o=c(),l(),":"!==O&&i("Expected ':' instead of '"+O+"'"),a(),u[o]=v(),e=x,l(),","===O&&(a(),e=x,l()),r){var s=h(e);r.c[o]=[t||"",s[0]||""],t=s[1],r.o.push(o)}if("}"===O&&!n)return a(),r&&(r.c[o][1]+=t||""),u;l()}if(n)return u;i("End of input while parsing an object (missing '}')")}catch(n){throw n.hint=n.hint||m(u),n}}function v(){switch(l(),O){case"{":return y();case"[":return d();case"'":case'"':return s(!0);default:return p()}}function g(n,r){var e=x;if(l(),O&&i("Syntax error, found trailing characters"),k){var t=r.join("\n"),o=h(e).join("\n");if(o||t){var a=C.createComment(n,C.getComment(n));a.r=[t,o]}}return n}function b(){l();var n=k?h(1):null;switch(O){case"{":return g(y(),n);case"[":return g(d(),n);default:return g(v(),n)}}function j(){l();var n=k?h(1):null;switch(O){case"{":return g(y(),n);case"[":return g(d(),n)}try{return g(y(!0),n)}catch(r){t();try{return g(v(),n)}catch(n){throw r}}}var w,x,O,k,E,C=n("./hjson-common"),q=n("./hjson-dsf"),S={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};if("string"!=typeof r)throw new Error("source is not a string");var N=null,_=!0;return e&&"object"==typeof e&&(k=e.keepWsc,N=e.dsf,_=e.legacyRoot!==!1),E=q.loadDsf(N,"parse"),w=r,t(),_?j():b()}},{"./hjson-common":2,"./hjson-dsf":3}],5:[function(n,r,e){"use strict";r.exports=function(r,e){function t(n,r){return n[0]+r+n[1]}function o(n){return n.replace(O,function(n){var r=q[n];return"string"==typeof r?t(j.esc,r):t(j.uni,("0000"+n.charCodeAt(0).toString(16)).slice(-4))})}function i(n,r,e,i){return n?(k.lastIndex=0,C.lastIndex=0,y||e||k.test(n)||void 0!==f.tryParseNumber(n,!0)||C.test(n)?(O.lastIndex=0,E.lastIndex=0,O.test(n)?E.test(n)||i||!v?t(j.qstr,o(n)):a(n,r):t(j.qstr,n)):t(j.str,n)):t(j.qstr,"")}function a(n,r){var e,o=n.replace(/\r/g,"").split("\n");if(r+=p,1===o.length)return t(j.mstr,o[0]);var i=l+r+j.mstr[0];for(e=0;e<o.length;e++)i+=l,o[e]&&(i+=r+o[e]);return i+l+r+j.mstr[1]}function u(n){return n?d||S.test(n)?(O.lastIndex=0,t(j.qkey,O.test(n)?o(n):n)):t(j.key,n):'""'}function s(n,r,e,o){function a(n){return n&&"\n"===n["\r"===n[0]?1:0]}function c(n){return n&&!a(n)}function d(n,r,e){if(!n)return"";n=f.forceComment(n);var o,i=n.length;for(o=0;o<i&&n[o]<=" ";o++);return e&&o>0&&(n=n.substr(o)),o<i?r+t(j.rem,n):n}var y=w(n);if(void 0!==y)return t(j.dsf,y);switch(typeof n){case"string":return i(n,N,r,o);case"number":return isFinite(n)?t(j.num,String(n)):t(j.lit,"null");case"boolean":return t(j.lit,String(n));case"object":if(!n)return t(j.lit,"null");var v;h&&(v=f.getComment(n));var b="[object Array]"===Object.prototype.toString.apply(n),x=N;N+=p;var O,k,E,C,q,S,_=l+x,I=l+N,F=e||m?"":_,A=[];if(b){for(O=0,k=n.length;O<k;O++)v&&(q=v.a[O]||[],S=c(q[1]),A.push(d(q[0],"\n")+I)),A.push(s(n[O],!!v&&S,!0)+(O<k-1?g:"")||t(j.lit,"null")),v&&q[1]&&A.push(d(q[1],S?" ":"\n",S));v&&(0===k?A.push((v.e?d(v.e[0],"\n"):"")+_):A.push(_)),C=v?F+t(j.arr,A.join("")):0===A.length?t(j.arr,""):F+t(j.arr,I+A.join(I)+_)}else{var P;if(v){P=v.o.slice();for(E in n)Object.prototype.hasOwnProperty.call(n,E)&&P.indexOf(E)<0&&P.push(E);for(O=0,k=P.length;O<k;O++)E=P[O],q=v.c[E]||[],S=c(q[1]),A.push(d(q[0],"\n")+I),C=s(n[E],S),C&&A.push(u(E)+j.col+(a(C)?"":" ")+C+(O<k-1?g:"")),v&&q[1]&&A.push(d(q[1],S?" ":"\n",S));0===k?A.push((v.e?d(v.e[0],"\n"):"")+_):A.push(_)}else for(P=Object.keys(n),O=0,k=P.length;O<k;O++)E=P[O],Object.prototype.hasOwnProperty.call(n,E)&&(C=s(n[E]),C&&A.push(u(E)+j.col+(a(C)?"":" ")+C+(O<k-1?g:"")));C=0===A.length?t(j.obj,""):v?F+t(j.obj,A.join("")):F+t(j.obj,I+A.join(I)+_)}return N=x,C}}var f=n("./hjson-common"),c=n("./hjson-dsf"),l=f.EOL,p=" ",h=!1,m=!1,d=!1,y=!1,v=1,g="",b=null,j={obj:["{","}"],arr:["[","]"],key:["",""],qkey:['"','"'],col:[":"],str:["",""],qstr:['"','"'],mstr:["'''","'''"],num:["",""],lit:["",""],dsf:["",""],esc:["\\",""],uni:["\\u",""],rem:["",""]};e&&"object"==typeof e&&(e.quotes="always"===e.quotes?"strings":e.quotes,"\n"!==e.eol&&"\r\n"!==e.eol||(l=e.eol),h=e.keepWsc,m=e.bracesSameLine,d="all"===e.quotes||"keys"===e.quotes,y="all"===e.quotes||"strings"===e.quotes||e.separator===!0,v=y||"off"==e.multiline?0:"no-tabs"==e.multiline?2:1,g=e.separator===!0?",":"",b=e.dsf,"number"==typeof e.space?p=new Array(e.space+1).join(" "):"string"==typeof e.space&&(p=e.space),e.colors===!0&&(j={obj:["[37m{[0m","[37m}[0m"],arr:["[37m[[0m","[37m][0m"],key:["[33m","[0m"],qkey:['[33m"','"[0m'],col:["[37m:[0m"],str:["[37;1m","[0m"],qstr:['[37;1m"','"[0m'],mstr:["[37;1m'''","'''[0m"],num:["[36;1m","[0m"],lit:["[36m","[0m"],dsf:["[37m","[0m"],esc:["[31m\\","[0m"],uni:["[31m\\u","[0m"],rem:["[35m","[0m"]}));var w,x="--឴឵-\u2028- -\ufeff-",O=new RegExp('[\\\\\\"\0-'+x+"]","g"),k=new RegExp("^\\s|^\"|^'|^#|^\\/\\*|^\\/\\/|^\\{|^\\}|^\\[|^\\]|^:|^,|\\s$|[\0-"+x+"]","g"),E=new RegExp("'''|^[\\s]+$|[\0-"+(2===v?"\t":"\b")+"\v\f-"+x+"]","g"),C=new RegExp("^(true|false|null)\\s*((,|\\]|\\}|#|//|/\\*).*)?$"),q={"\b":"b","\t":"t","\n":"n","\f":"f","\r":"r",'"':'"',"\\":"\\"},S=/[,\{\[\}\]\s:#"']|\/\/|\/\*/,N="";w=c.loadDsf(b,"stringify");var _="",I=h?I=(f.getComment(r)||{}).r:null;return I&&I[0]&&(_=I[0]+"\n"),_+=s(r,null,!0,!0),I&&(_+=I[1]||""),_}},{"./hjson-common":2,"./hjson-dsf":3}],6:[function(n,r,e){r.exports="3.0.2"},{}],7:[function(n,r,e){/*! | ||
* Hjson v3.0.2 | ||
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Hjson=n()}}(function(){return function n(e,r,t){function o(a,u){if(!r[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(n){var r=e[a][1][n];return o(r?r:n)},c,c.exports,n,e,r,t)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a<t.length;a++)o(t[a]);return o}({1:[function(n,e,r){"use strict";function t(n,e,r){var t;return n&&(t={b:n}),e&&((t=t||{}).a=e),r&&((t=t||{}).x=r),t}function o(n,e){if(null!==n&&"object"==typeof n){var r=h.getComment(n);r&&h.removeComment(n);var i,a,s,f;if("[object Array]"===Object.prototype.toString.apply(n)){for(f={a:[]},i=0,a=n.length;i<a;i++)u(f.a,i,r.a[i],o(n[i]))&&(s=!0);!s&&r.e&&(f.e=t(r.e[0],r.e[1]),s=!0)}else{f={s:{}};var c,l=Object.keys(n);for(r&&r.o?(c=[],r.o.concat(l).forEach(function(e){Object.prototype.hasOwnProperty.call(n,e)&&c.indexOf(e)<0&&c.push(e)})):c=l,f.o=c,i=0,a=c.length;i<a;i++){var p=c[i];u(f.s,p,r.c[p],o(n[p]))&&(s=!0)}!s&&r.e&&(f.e=t(r.e[0],r.e[1]),s=!0)}return e&&r&&r.r&&(f.r=t(r.r[0],r.r[1])),s?f:void 0}}function i(){var n="";return[].forEach.call(arguments,function(e){e&&""!==e.trim()&&(n&&(n+="; "),n+=e.trim())}),n}function a(n,e){var r=[];if(c(n,e,r,[]),r.length>0){var t=l(e,null,1);t+="\n# Orphaned comments:\n",r.forEach(function(n){t+=("# "+n.path.join("/")+": "+i(n.b,n.a,n.e)).replace("\n","\\n ")+"\n"}),l(e,t,1)}}function u(n,e,r,o){var i=t(r?r[0]:void 0,r?r[1]:void 0,o);return i&&(n[e]=i),i}function s(n,e){var r=t(e.b,e.a);return r.path=n,r}function f(n,e,r){if(n){var t,o;if(n.a)for(t=0,o=n.a.length;t<o;t++){var i=r.slice().concat([t]),a=n.a[t];a&&(e.push(s(i,a)),f(a.x,e,i))}else n.o&&n.o.forEach(function(t){var o=r.slice().concat([t]),i=n.s[t];i&&(e.push(s(o,i)),f(i.x,e,o))});n.e&&e.push(s(r,n.e))}}function c(n,e,r,t){if(n){if(null===e||"object"!=typeof e)return void f(n,r,t);var o,i,a=h.createComment(e);if(0===t.length&&n.r&&(a.r=[n.r.b,n.r.a]),"[object Array]"===Object.prototype.toString.apply(e)){for(a.a=[],o=0,i=(n.a||[]).length;o<i;o++){var u=t.slice().concat([o]),l=n.a[o];l&&(o<e.length?(a.a.push([l.b,l.a]),c(l.x,e[o],r,u)):(r.push(s(u,l)),f(l.x,r,u)))}0===o&&n.e&&(a.e=[n.e.b,n.e.a])}else a.c={},a.o=[],(n.o||[]).forEach(function(o){var i=t.slice().concat([o]),u=n.s[o];Object.prototype.hasOwnProperty.call(e,o)?(a.o.push(o),u&&(a.c[o]=[u.b,u.a],c(u.x,e[o],r,i))):u&&(r.push(s(i,u)),f(u.x,r,i))}),n.e&&(a.e=[n.e.b,n.e.a])}}function l(n,e,r){var t=h.createComment(n,h.getComment(n));return t.r||(t.r=["",""]),(e||""===e)&&(t.r[r]=h.forceComment(e)),t.r[r]||""}var h=n("./hjson-common");e.exports={extract:function(n){return o(n,!0)},merge:a,header:function(n,e){return l(n,e,0)},footer:function(n,e){return l(n,e,1)}}},{"./hjson-common":2}],2:[function(n,e,r){"use strict";function t(n,e){function r(){return o=n.charAt(s),s++,o}var t,o,i="",a=0,u=!0,s=0;for(r(),"-"===o&&(i="-",r());o>="0"&&o<="9";)u&&("0"==o?a++:u=!1),i+=o,r();if(u&&a--,"."===o)for(i+=".";r()&&o>="0"&&o<="9";)i+=o;if("e"===o||"E"===o)for(i+=o,r(),"-"!==o&&"+"!==o||(i+=o,r());o>="0"&&o<="9";)i+=o,r();for(;o&&o<=" ";)r();return e&&(","!==o&&"}"!==o&&"]"!==o&&"#"!==o&&("/"!==o||"/"!==n[s]&&"*"!==n[s])||(o=0)),t=+i,o||a||!isFinite(t)?void 0:t}function o(n,e){return Object.defineProperty&&Object.defineProperty(n,"__COMMENTS__",{enumerable:!1,writable:!0}),n.__COMMENTS__=e||{}}function i(n){Object.defineProperty(n,"__COMMENTS__",{value:void 0})}function a(n){return n.__COMMENTS__}function u(n){if(!n)return"";var e,r,t,o,i=n.split("\n");for(t=0;t<i.length;t++)for(e=i[t],o=e.length,r=0;r<o;r++){var a=e[r];if("#"===a)break;if("/"===a&&("/"===e[r+1]||"*"===e[r+1])){"*"===e[r+1]&&(t=i.length);break}if(a>" "){i[t]="# "+e;break}}return i.join("\n")}var s=n("os");e.exports={EOL:s.EOL||"\n",tryParseNumber:t,createComment:o,removeComment:i,getComment:a,forceComment:u}},{os:8}],3:[function(n,e,r){"use strict";function t(n,e){function r(n){return"[object Function]"==={}.toString.call(n)}if("[object Array]"!==Object.prototype.toString.apply(n)){if(n)throw new Error("dsf option must contain an array!");return i}if(0===n.length)return i;var t=[];return n.forEach(function(n){if(!n.name||!r(n.parse)||!r(n.stringify))throw new Error("extension does not match the DSF interface");t.push(function(){try{if("parse"==e)return n.parse.apply(null,arguments);if("stringify"==e){var r=n.stringify.apply(null,arguments);if(void 0!==r&&("string"!=typeof r||0===r.length||'"'===r[0]||[].some.call(r,function(n){return a(n)})))throw new Error("value may not be empty, start with a quote or contain a punctuator character except colon: "+r);return r}throw new Error("Invalid type")}catch(e){throw new Error("DSF-"+n.name+" failed; "+e.message)}})}),o.bind(null,t)}function o(n,e){if(n)for(var r=0;r<n.length;r++){var t=n[r](e);if(void 0!==t)return t}}function i(){}function a(n){return"{"===n||"}"===n||"["===n||"]"===n||","===n}function u(){return{name:"math",parse:function(n){switch(n){case"+inf":case"inf":case"+Inf":case"Inf":return 1/0;case"-inf":case"-Inf":return-(1/0);case"nan":case"NaN":return NaN}},stringify:function(n){if("number"==typeof n)return 1/n===-(1/0)?"-0":n===1/0?"Inf":n===-(1/0)?"-Inf":isNaN(n)?"NaN":void 0}}}function s(n){var e=n&&n.out;return{name:"hex",parse:function(n){if(/^0x[0-9A-Fa-f]+$/.test(n))return parseInt(n,16)},stringify:function(n){if(e&&Number.isInteger(n))return"0x"+n.toString(16)}}}function f(){return{name:"date",parse:function(n){if(/^\d{4}-\d{2}-\d{2}$/.test(n)||/^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}(?:.\d+)(?:Z|[+-]\d{2}:\d{2})$/.test(n)){var e=Date.parse(n);if(!isNaN(e))return new Date(e)}},stringify:function(n){if("[object Date]"===Object.prototype.toString.call(n)){var e=n.toISOString();return e.indexOf("T00:00:00.000Z",e.length-14)!==-1?e.substr(0,10):e}}}}u.description="support for Inf/inf, -Inf/-inf, Nan/naN and -0",s.description="parse hexadecimal numbers prefixed with 0x",f.description="support ISO dates",e.exports={loadDsf:t,std:{math:u,hex:s,date:f}}},{}],4:[function(n,e,r){"use strict";e.exports=function(e,r){function t(){x=0,O=" "}function o(n){return"{"===n||"}"===n||"["===n||"]"===n||","===n||":"===n}function i(n){var e,r=0,t=1;for(e=x-1;e>0&&"\n"!==w[e];e--,r++);for(;e>0;e--)"\n"===w[e]&&t++;throw new Error(n+" at line "+t+","+r+" >>>"+w.substr(x-r,20)+" ...")}function a(){return O=w.charAt(x),x++,O}function u(n){return w.charAt(x+n)}function s(n){for(var e="",r=O;a();){if(O===r)return a(),n&&"'"===r&&"'"===O&&0===e.length?(a(),f()):e;if("\\"===O)if(a(),"u"===O){for(var t=0,o=0;o<4;o++){a();var u,s=O.charCodeAt(0);O>="0"&&O<="9"?u=s-48:O>="a"&&O<="f"?u=s-97+10:O>="A"&&O<="F"?u=s-65+10:i("Bad \\u char "+O),t=16*t+u}e+=String.fromCharCode(t)}else{if("string"!=typeof S[O])break;e+=S[O]}else"\n"===O||"\r"===O?i("Bad string containing newline"):e+=O}i("Bad string")}function f(){function n(){for(var n=t;O&&O<=" "&&"\n"!==O&&n-- >0;)a()}for(var e="",r=0,t=0;;){var o=u(-t-5);if(!o||"\n"===o)break;t++}for(;O&&O<=" "&&"\n"!==O;)a();for("\n"===O&&(a(),n());;){if(O){if("'"===O){if(r++,a(),3===r)return"\n"===e.slice(-1)&&(e=e.slice(0,-1)),e;continue}for(;r>0;)e+="'",r--}else i("Bad multiline string");"\n"===O?(e+="\n",a(),n()):("\r"!==O&&(e+=O),a())}}function c(){if('"'===O||"'"===O)return s(!1);for(var n="",e=x,r=-1;;){if(":"===O)return n?r>=0&&r!==n.length&&(x=e+r,i("Found whitespace in your key name (use quotes to include)")):i("Found ':' but no key name (for an empty key name use quotes)"),n;O<=" "?O?r<0&&(r=n.length):i("Found EOF while looking for a key name (check your syntax)"):o(O)?i("Found '"+O+"' where a key name was expected (check your syntax or use quotes if the key name includes {}[],: or whitespace)"):n+=O,a()}}function l(){for(;O;){for(;O&&O<=" ";)a();if("#"===O||"/"===O&&"/"===u(0))for(;O&&"\n"!==O;)a();else{if("/"!==O||"*"!==u(0))break;for(a(),a();O&&("*"!==O||"/"!==u(0));)a();O&&(a(),a())}}}function h(){var n=O;for(o(O)&&i("Found a punctuator character '"+O+"' when expecting a quoteless string (check your syntax)");;){a();var e="\r"===O||"\n"===O||""===O;if(e||","===O||"}"===O||"]"===O||"#"===O||"/"===O&&("/"===u(0)||"*"===u(0))){var r=n[0];switch(r){case"f":if("false"===n.trim())return!1;break;case"n":if("null"===n.trim())return null;break;case"t":if("true"===n.trim())return!0;break;default:if("-"===r||r>="0"&&r<="9"){var t=C.tryParseNumber(n);if(void 0!==t)return t}}if(e){n=n.trim();var s=E(n);return void 0!==s?s:n}}n+=O}}function p(n,e){var r;for(n--,r=x-2;r>n&&w[r]<=" "&&"\n"!==w[r];r--);"\n"===w[r]&&r--,"\r"===w[r]&&r--;var t=w.substr(n,r-n+1);for(r=0;r<t.length;r++)if(t[r]>" "){var o=t.indexOf("\n");if(o>=0){var i=[t.substr(0,o),t.substr(o+1)];return e&&0===i[0].trim().length&&i.shift(),i}return[t]}return[]}function m(n){function e(n,r){var t,o,i,a;switch(typeof n){case"string":n.indexOf(r)>=0&&(a=n);break;case"object":if("[object Array]"===Object.prototype.toString.apply(n))for(t=0,i=n.length;t<i;t++)a=e(n[t],r)||a;else for(o in n)Object.prototype.hasOwnProperty.call(n,o)&&(a=e(n[o],r)||a)}return a}function r(r){var t=e(n,r);return t?"found '"+r+"' in a string value, your mistake could be with:\n > "+t+"\n (unquoted strings contain everything up to the next line!)":""}return r("}")||r("]")}function d(){var n,e,r,t=[];try{if(k&&(n=C.createComment(t,{a:[]})),a(),e=x,l(),n&&(r=p(e,!0).join("\n")),"]"===O)return a(),n&&(n.e=[r]),t;for(;O;){if(t.push(y()),e=x,l(),","===O&&(a(),e=x,l()),n){var o=p(e);n.a.push([r||"",o[0]||""]),r=o[1]}if("]"===O)return a(),n&&(n.a[n.a.length-1][1]+=r||""),t;l()}i("End of input while parsing an array (missing ']')")}catch(n){throw n.hint=n.hint||m(t),n}}function g(n){var e,r,t,o="",u={};try{if(k&&(e=C.createComment(u,{c:{},o:[]})),n?r=1:(a(),r=x),l(),e&&(t=p(r,!0).join("\n")),"}"===O&&!n)return e&&(e.e=[t]),a(),u;for(;O;){if(o=c(),l(),":"!==O&&i("Expected ':' instead of '"+O+"'"),a(),u[o]=y(),r=x,l(),","===O&&(a(),r=x,l()),e){var s=p(r);e.c[o]=[t||"",s[0]||""],t=s[1],e.o.push(o)}if("}"===O&&!n)return a(),e&&(e.c[o][1]+=t||""),u;l()}if(n)return u;i("End of input while parsing an object (missing '}')")}catch(n){throw n.hint=n.hint||m(u),n}}function y(){switch(l(),O){case"{":return g();case"[":return d();case"'":case'"':return s(!0);default:return h()}}function v(n,e){var r=x;if(l(),O&&i("Syntax error, found trailing characters"),k){var t=e.join("\n"),o=p(r).join("\n");if(o||t){var a=C.createComment(n,C.getComment(n));a.r=[t,o]}}return n}function b(){l();var n=k?p(1):null;switch(O){case"{":return v(g(),n);case"[":return v(d(),n);default:return v(y(),n)}}function j(){l();var n=k?p(1):null;switch(O){case"{":return v(g(),n);case"[":return v(d(),n)}try{return v(g(!0),n)}catch(e){t();try{return v(y(),n)}catch(n){throw e}}}var w,x,O,k,E,C=n("./hjson-common"),q=n("./hjson-dsf"),S={'"':'"',"'":"'","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};if("string"!=typeof e)throw new Error("source is not a string");var N=null,_=!0;return r&&"object"==typeof r&&(k=r.keepWsc,N=r.dsf,_=r.legacyRoot!==!1),E=q.loadDsf(N,"parse"),w=e,t(),_?j():b()}},{"./hjson-common":2,"./hjson-dsf":3}],5:[function(n,e,r){"use strict";e.exports=function(e,r){function t(n,e){return P+=n[0].length+n[1].length-n[2]-n[3],n[0]+e+n[1]}function o(n){return n.replace(S,function(n){var e=F[n];return"string"==typeof e?t(x.esc,e):t(x.uni,("0000"+n.charCodeAt(0).toString(16)).slice(-4))})}function i(n,e,r,i){return n?(N.lastIndex=0,I.lastIndex=0,y||r||N.test(n)||void 0!==f.tryParseNumber(n,!0)||I.test(n)?(S.lastIndex=0,_.lastIndex=0,S.test(n)?_.test(n)||i||!b?t(x.qstr,o(n)):a(n,e):t(x.qstr,n)):t(x.str,n)):t(x.qstr,"")}function a(n,e){var r,o=n.replace(/\r/g,"").split("\n");if(e+=p,1===o.length)return t(x.mstr,o[0]);var i=h+e+x.mstr[0];for(r=0;r<o.length;r++)i+=h,o[r]&&(i+=e+o[r]);return i+h+e+x.mstr[1]}function u(n){return n?g||A.test(n)?(S.lastIndex=0,t(x.qkey,S.test(n)?o(n):n)):t(x.key,n):'""'}function s(n,e,r,o){function a(n){return n&&"\n"===n["\r"===n[0]?1:0]}function c(n){return n&&!a(n)}function l(n,e,r){if(!n)return"";n=f.forceComment(n);var o,i=n.length;for(o=0;o<i&&n[o]<=" ";o++);return r&&o>0&&(n=n.substr(o)),o<i?e+t(x.rem,n):n}var g=C(n);if(void 0!==g)return t(x.dsf,g);switch(typeof n){case"string":return i(n,D,e,o);case"number":return isFinite(n)?t(x.num,String(n)):t(x.lit,"null");case"boolean":return t(x.lit,String(n));case"object":if(!n)return t(x.lit,"null");var w;m&&(w=f.getComment(n));var O="[object Array]"===Object.prototype.toString.apply(n),k=D;D+=p;var E,q,S,N,_,I,F,A,L,M,T=h+k,$=h+D,R=r||d?"":T,B=[],W=v?[]:null,U=y,Z=b,H=j?"":x.com[0],z=0;if(O){for(q=0,S=n.length;q<S;q++){if(E=q<S-1,w?(F=w.a[q]||[],A=c(F[1]),B.push(l(F[0],"\n")+$),W&&(F[0]||F[1]||A)&&(W=null)):B.push($),P=0,_=n[q],B.push(s(_,!!w&&A,!0)+(E?j:"")),W){switch(typeof _){case"string":P=0,y=!0,b=0,W.push(s(_,!1,!0)+(E?x.com[0]:"")),y=U,b=Z;break;case"object":if(_){W=null;break}default:W.push(B[B.length-1]+(E?H:""))}E&&(P+=x.com[0].length-x.com[2]),z+=P}w&&F[1]&&B.push(l(F[1],A?" ":"\n",A))}0===S?w&&w.e&&B.push(l(w.e[0],"\n")+T):B.push(T),0===B.length?L=t(x.arr,""):(L=R+t(x.arr,B.join("")),W&&(M=W.join(" "),M.length-z<=v&&(L=t(x.arr,M))))}else{var G=w?w.o.slice():[];for(N in n)Object.prototype.hasOwnProperty.call(n,N)&&G.indexOf(N)<0&&G.push(N);for(q=0,S=G.length;q<S;q++)if(E=q<S-1,N=G[q],w?(F=w.c[N]||[],A=c(F[1]),B.push(l(F[0],"\n")+$),W&&(F[0]||F[1]||A)&&(W=null)):B.push($),P=0,_=n[N],I=s(_,w&&A),B.push(u(N)+x.col[0]+(a(I)?"":" ")+I+(E?j:"")),w&&F[1]&&B.push(l(F[1],A?" ":"\n",A)),W){switch(typeof _){case"string":P=0,y=!0,b=0,I=s(_,!1),y=U,b=Z,W.push(u(N)+x.col[0]+" "+I+(E?x.com[0]:""));break;case"object":if(_){W=null;break}default:W.push(B[B.length-1]+(E?H:""))}P+=x.col[0].length-x.col[2],E&&(P+=x.com[0].length-x.com[2]),z+=P}0===S?w&&w.e&&B.push(l(w.e[0],"\n")+T):B.push(T),0===B.length?L=t(x.obj,""):(L=R+t(x.obj,B.join("")),W&&(M=W.join(" "),M.length-z<=v&&(L=t(x.obj,M))))}return D=k,L}}var f=n("./hjson-common"),c=n("./hjson-dsf"),l={obj:["{","}"],arr:["[","]"],key:["",""],qkey:['"','"'],col:[":",""],com:[",",""],str:["",""],qstr:['"','"'],mstr:["'''","'''"],num:["",""],lit:["",""],dsf:["",""],esc:["\\",""],uni:["\\u",""],rem:["",""]},h=f.EOL,p=" ",m=!1,d=!1,g=!1,y=!1,v=0,b=1,j="",w=null,x=l;if(r&&"object"==typeof r){r.quotes="always"===r.quotes?"strings":r.quotes,"\n"!==r.eol&&"\r\n"!==r.eol||(h=r.eol),m=r.keepWsc,v=r.condense||0,d=r.bracesSameLine,g="all"===r.quotes||"keys"===r.quotes,y="all"===r.quotes||"strings"===r.quotes||r.separator===!0,b=y||"off"==r.multiline?0:"no-tabs"==r.multiline?2:1,j=r.separator===!0?x.com[0]:"",w=r.dsf,"number"==typeof r.space?p=new Array(r.space+1).join(" "):"string"==typeof r.space&&(p=r.space),r.colors===!0&&(x={obj:["[37m{[0m","[37m}[0m"],arr:["[37m[[0m","[37m][0m"],key:["[33m","[0m"],qkey:['[33m"','"[0m'],col:["[37m:[0m",""],com:["[37m,[0m",""],str:["[37;1m","[0m"],qstr:['[37;1m"','"[0m'],mstr:["[37;1m'''","'''[0m"],num:["[36;1m","[0m"],lit:["[36m","[0m"],dsf:["[37m","[0m"],esc:["[31m\\","[0m"],uni:["[31m\\u","[0m"],rem:["[35m","[0m"]});var O,k=Object.keys(l);for(O=k.length-1;O>=0;O--){var E=k[O];x[E].push(l[E][0].length,l[E][1].length)}}var C,q="--឴឵-\u2028- -\ufeff-",S=new RegExp('[\\\\\\"\0-'+q+"]","g"),N=new RegExp("^\\s|^\"|^'|^#|^\\/\\*|^\\/\\/|^\\{|^\\}|^\\[|^\\]|^:|^,|\\s$|[\0-"+q+"]","g"),_=new RegExp("'''|^[\\s]+$|[\0-"+(2===b?"\t":"\b")+"\v\f-"+q+"]","g"),I=new RegExp("^(true|false|null)\\s*((,|\\]|\\}|#|//|/\\*).*)?$"),F={"\b":"b","\t":"t","\n":"n","\f":"f","\r":"r",'"':'"',"\\":"\\"},A=/[,\{\[\}\]\s:#"']|\/\/|\/\*/,D="",P=0;C=c.loadDsf(w,"stringify");var L="",M=m?M=(f.getComment(e)||{}).r:null;return M&&M[0]&&(L=M[0]+"\n"),L+=s(e,null,!0,!0),M&&(L+=M[1]||""),L}},{"./hjson-common":2,"./hjson-dsf":3}],6:[function(n,e,r){e.exports="3.1.0"},{}],7:[function(n,e,r){/*! | ||
* Hjson v3.1.0 | ||
* http://hjson.org | ||
@@ -24,2 +24,2 @@ * | ||
*/ | ||
"use strict";var t=n("./hjson-common"),o=n("./hjson-version"),i=n("./hjson-parse"),a=n("./hjson-stringify"),u=n("./hjson-comments"),s=n("./hjson-dsf");r.exports={parse:i,stringify:a,endOfLine:function(){return t.EOL},setEndOfLine:function(n){"\n"!==n&&"\r\n"!==n||(t.EOL=n)},version:o,rt:{parse:function(n,r){return(r=r||{}).keepWsc=!0,i(n,r)},stringify:function(n,r){return(r=r||{}).keepWsc=!0,a(n,r)}},comments:u,dsf:s.std}},{"./hjson-comments":1,"./hjson-common":2,"./hjson-dsf":3,"./hjson-parse":4,"./hjson-stringify":5,"./hjson-version":6}],8:[function(n,r,e){},{}]},{},[7])(7)}); | ||
"use strict";var t=n("./hjson-common"),o=n("./hjson-version"),i=n("./hjson-parse"),a=n("./hjson-stringify"),u=n("./hjson-comments"),s=n("./hjson-dsf");e.exports={parse:i,stringify:a,endOfLine:function(){return t.EOL},setEndOfLine:function(n){"\n"!==n&&"\r\n"!==n||(t.EOL=n)},version:o,rt:{parse:function(n,e){return(e=e||{}).keepWsc=!0,i(n,e)},stringify:function(n,e){return(e=e||{}).keepWsc=!0,a(n,e)}},comments:u,dsf:s.std}},{"./hjson-comments":1,"./hjson-common":2,"./hjson-dsf":3,"./hjson-parse":4,"./hjson-stringify":5,"./hjson-version":6}],8:[function(n,e,r){},{}]},{},[7])(7)}); |
@@ -66,3 +66,3 @@ /* Hjson http://hjson.org */ | ||
next(); | ||
if (allowML && ch === "'" && string.length === 0) { | ||
if (allowML && exitCh === "'" && ch === "'" && string.length === 0) { | ||
// ''' indicates a multiline string | ||
@@ -69,0 +69,0 @@ next(); |
@@ -9,13 +9,3 @@ /* Hjson http://hjson.org */ | ||
// options | ||
var eol = common.EOL; | ||
var indent = ' '; | ||
var keepComments = false; | ||
var bracesSameLine = false; | ||
var quoteKeys = false; | ||
var quoteStrings = false; | ||
var multiline = 1; // std=1, no-tabs=2, off=0 | ||
var separator = ''; // comma separator | ||
var dsfDef = null; | ||
var token = { | ||
var plainToken = { | ||
obj: [ '{', '}' ], | ||
@@ -25,3 +15,4 @@ arr: [ '[', ']' ], | ||
qkey: [ '"', '"' ], | ||
col: [ ':' ], | ||
col: [ ':', '' ], | ||
com: [ ',', '' ], | ||
str: [ '', '' ], | ||
@@ -38,2 +29,15 @@ qstr: [ '"', '"' ], | ||
// options | ||
var eol = common.EOL; | ||
var indent = ' '; | ||
var keepComments = false; | ||
var bracesSameLine = false; | ||
var quoteKeys = false; | ||
var quoteStrings = false; | ||
var condense = 0; | ||
var multiline = 1; // std=1, no-tabs=2, off=0 | ||
var separator = ''; // comma separator | ||
var dsfDef = null; | ||
var token = plainToken; | ||
if (opt && typeof opt === 'object') { | ||
@@ -44,2 +48,3 @@ opt.quotes = opt.quotes === 'always' ? 'strings' : opt.quotes; // legacy | ||
keepComments = opt.keepWsc; | ||
condense = opt.condense || 0; | ||
bracesSameLine = opt.bracesSameLine; | ||
@@ -50,3 +55,3 @@ quoteKeys = opt.quotes === 'all' || opt.quotes === 'keys'; | ||
else multiline = opt.multiline == 'no-tabs' ? 2 : 1; | ||
separator = opt.separator === true ? ',' : ''; | ||
separator = opt.separator === true ? token.com[0] : ''; | ||
dsfDef = opt.dsf; | ||
@@ -69,3 +74,4 @@ | ||
qkey: [ '\x1b[33m"', '"\x1b[0m' ], | ||
col: [ '\x1b[37m:\x1b[0m' ], | ||
col: [ '\x1b[37m:\x1b[0m', '' ], | ||
com: [ '\x1b[37m,\x1b[0m', '' ], | ||
str: [ '\x1b[37;1m', '\x1b[0m' ], | ||
@@ -82,2 +88,8 @@ qstr: [ '\x1b[37;1m"', '"\x1b[0m' ], | ||
} | ||
var i, ckeys=Object.keys(plainToken); | ||
for (i = ckeys.length - 1; i >= 0; i--) { | ||
var k = ckeys[i]; | ||
token[k].push(plainToken[k][0].length, plainToken[k][1].length); | ||
} | ||
} | ||
@@ -109,4 +121,9 @@ | ||
var gap = ''; | ||
// | ||
var wrapLen = 0; | ||
function wrap(tk, v) { return tk[0] + v + tk[1]; } | ||
function wrap(tk, v) { | ||
wrapLen += tk[0].length + tk[1].length - tk[2] - tk[3]; | ||
return tk[0] + v + tk[1]; | ||
} | ||
@@ -240,6 +257,13 @@ function quoteReplace(string) { | ||
var partial = []; | ||
var setsep; | ||
// condense helpers: | ||
var cpartial = condense ? [] : null; | ||
var saveQuoteStrings = quoteStrings, saveMultiline = multiline; | ||
var iseparator = separator ? '' : token.com[0]; | ||
var cwrapLen = 0; | ||
var i, length; // loop | ||
var k, v; // key, value | ||
var k, v, vs; // key, value | ||
var c, ca; | ||
var res, cres; | ||
@@ -251,2 +275,3 @@ if (isArray) { | ||
for (i = 0, length = value.length; i < length; i++) { | ||
setsep = i < length -1; | ||
if (comments) { | ||
@@ -256,14 +281,31 @@ c = comments.a[i]||[]; | ||
partial.push(makeComment(c[0], "\n") + eolGap); | ||
if (cpartial && (c[0] || c[1] || ca)) cpartial = null; | ||
} | ||
partial.push(str(value[i], comments ? ca : false, true) + (i < length -1 ? separator : '') || wrap(token.lit, 'null')); | ||
else partial.push(eolGap); | ||
wrapLen = 0; | ||
v = value[i]; | ||
partial.push(str(v, comments ? ca : false, true) + (setsep ? separator : '')); | ||
if (cpartial) { | ||
// prepare the condensed version | ||
switch (typeof v) { | ||
case 'string': | ||
wrapLen = 0; | ||
quoteStrings = true; multiline = 0; | ||
cpartial.push(str(v, false, true) + (setsep ? token.com[0] : '')); | ||
quoteStrings = saveQuoteStrings; multiline = saveMultiline; | ||
break; | ||
case 'object': if (v) { cpartial = null; break; } // falls through | ||
default: cpartial.push(partial[partial.length - 1] + (setsep ? iseparator : '')); break; | ||
} | ||
if (setsep) wrapLen += token.com[0].length - token.com[2]; | ||
cwrapLen += wrapLen; | ||
} | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
} | ||
if (comments) { | ||
if (length === 0) { | ||
// when empty | ||
partial.push((comments.e ? makeComment(comments.e[0], "\n") : "") + eolMind); | ||
} | ||
else partial.push(eolMind); | ||
if (length === 0) { | ||
// when empty | ||
if (comments && comments.e) partial.push(makeComment(comments.e[0], "\n") + eolMind); | ||
} | ||
else partial.push(eolMind); | ||
@@ -273,51 +315,70 @@ // Join all of the elements together, separated with newline, and wrap them in | ||
if (comments) v = prefix + wrap(token.arr, partial.join('')); | ||
else if (partial.length === 0) v = wrap(token.arr, ''); | ||
else v = prefix + wrap(token.arr, eolGap + partial.join(eolGap) + eolMind); | ||
if (partial.length === 0) res = wrap(token.arr, ''); | ||
else { | ||
res = prefix + wrap(token.arr, partial.join('')); | ||
// try if the condensed version can fit (parent key name is not included) | ||
if (cpartial) { | ||
cres = cpartial.join(' '); | ||
if (cres.length - cwrapLen <= condense) res = wrap(token.arr, cres); | ||
} | ||
} | ||
} else { | ||
// Otherwise, iterate through all of the keys in the object. | ||
var keys; | ||
var keys = comments ? comments.o.slice() : []; | ||
for (k in value) { | ||
if (Object.prototype.hasOwnProperty.call(value, k) && keys.indexOf(k) < 0) | ||
keys.push(k); | ||
} | ||
if (comments) { | ||
keys = comments.o.slice(); | ||
for (k in value) { | ||
if (Object.prototype.hasOwnProperty.call(value, k) && keys.indexOf(k) < 0) | ||
keys.push(k); | ||
} | ||
for (i = 0, length = keys.length; i < length; i++) { | ||
k = keys[i]; | ||
for (i = 0, length = keys.length; i < length; i++) { | ||
setsep = i < length - 1; | ||
k = keys[i]; | ||
if (comments) { | ||
c = comments.c[k]||[]; | ||
ca = commentOnThisLine(c[1]); | ||
partial.push(makeComment(c[0], "\n") + eolGap); | ||
v = str(value[k], ca); | ||
if (v) partial.push(quoteKey(k) + token.col + (startsWithNL(v) ? '' : ' ') + v + (i < length - 1 ? separator : '')); | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
if (cpartial && (c[0] || c[1] || ca)) cpartial = null; | ||
} | ||
if (length === 0) { | ||
// when empty | ||
partial.push((comments.e ? makeComment(comments.e[0], "\n") : "") + eolMind); | ||
} | ||
else partial.push(eolMind); | ||
else partial.push(eolGap); | ||
} else { | ||
keys = Object.keys(value); | ||
for (i = 0, length = keys.length; i < length; i++) { | ||
k = keys[i]; | ||
if (Object.prototype.hasOwnProperty.call(value, k)) { | ||
v = str(value[k]); | ||
if (v) partial.push(quoteKey(k) + token.col + (startsWithNL(v) ? '' : ' ') + v + (i < length - 1 ? separator : '')); | ||
wrapLen = 0; | ||
v = value[k]; | ||
vs = str(v, comments && ca); | ||
partial.push(quoteKey(k) + token.col[0] + (startsWithNL(vs) ? '' : ' ') + vs + (setsep ? separator : '')); | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
if (cpartial) { | ||
// prepare the condensed version | ||
switch (typeof v) { | ||
case 'string': | ||
wrapLen = 0; | ||
quoteStrings = true; multiline = 0; | ||
vs = str(v, false); | ||
quoteStrings = saveQuoteStrings; multiline = saveMultiline; | ||
cpartial.push(quoteKey(k) + token.col[0] + ' ' + vs + (setsep ? token.com[0] : '')); | ||
break; | ||
case 'object': if (v) { cpartial = null; break; } // falls through | ||
default: cpartial.push(partial[partial.length - 1] + (setsep ? iseparator : '')); break; | ||
} | ||
wrapLen += token.col[0].length - token.col[2]; | ||
if (setsep) wrapLen += token.com[0].length - token.com[2]; | ||
cwrapLen += wrapLen; | ||
} | ||
} | ||
if (length === 0) { | ||
// when empty | ||
if (comments && comments.e) partial.push(makeComment(comments.e[0], "\n") + eolMind); | ||
} | ||
else partial.push(eolMind); | ||
// Join all of the member texts together, separated with newlines | ||
if (partial.length === 0) { | ||
v = wrap(token.obj, ''); | ||
res = wrap(token.obj, ''); | ||
} else { | ||
// and wrap them in braces | ||
if (comments) v = prefix + wrap(token.obj, partial.join('')); | ||
else v = prefix + wrap(token.obj, eolGap + partial.join(eolGap) + eolMind); | ||
res = prefix + wrap(token.obj, partial.join('')); | ||
// try if the condensed version can fit | ||
if (cpartial) { | ||
cres = cpartial.join(' '); | ||
if (cres.length - cwrapLen <= condense) res = wrap(token.obj, cres); | ||
} | ||
} | ||
@@ -327,3 +388,3 @@ } | ||
gap = mind; | ||
return v; | ||
return res; | ||
} | ||
@@ -330,0 +391,0 @@ } |
@@ -1,1 +0,1 @@ | ||
module.exports="3.0.2"; | ||
module.exports="3.1.0"; |
/*! | ||
* Hjson v3.0.2 | ||
* Hjson v3.1.0 | ||
* http://hjson.org | ||
@@ -42,2 +42,6 @@ * | ||
condense integer, will try to fit objects/arrays onto one line | ||
when the output is shorter than condense characters | ||
and the fragment contains no comments. Default 0 (off). | ||
bracesSameLine | ||
@@ -47,5 +51,2 @@ boolean, makes braces appear on the same line as the key | ||
emitRootBraces | ||
obsolete: will always emit braces | ||
quotes string, controls how strings are displayed. | ||
@@ -78,2 +79,5 @@ setting separator implies "strings" | ||
dsf array of DSF (see Hjson.dsf) | ||
emitRootBraces | ||
obsolete: will always emit braces | ||
} | ||
@@ -80,0 +84,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"author": "Christian Zangl", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"keywords": [ | ||
@@ -9,0 +9,0 @@ "json", |
@@ -78,2 +78,3 @@ # hjson-js | ||
-nocol disable colors | ||
-cond=n set condense option (default 60, 0 to disable) | ||
@@ -113,2 +114,3 @@ Domain specific formats are optional extensions to Hjson and can be enabled with the following options: | ||
- *keepWsc*: boolean, keep white space. See parse. | ||
- *condense*: integer, will try to fit objects/arrays onto one line. Default 0 (off). | ||
- *bracesSameLine*: boolean, makes braces appear on the same line as the key name. Default false. | ||
@@ -115,0 +117,0 @@ - *emitRootBraces*: boolean, show braces for the root object. Default true. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121835
2637
174