Comparing version 2.3.0 to 2.3.1
@@ -6,2 +6,202 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Hjson = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var common=require("./hjson-common"); | ||
function makeComment(b, a, x) { | ||
var c; | ||
if (b) c={ b: b }; | ||
if (a) (c=c||{}).a=a; | ||
if (x) (c=c||{}).x=x; | ||
return c; | ||
} | ||
function extractComments(value, root) { | ||
if (value===null || typeof value!=='object') return; | ||
var comments=common.getComment(value); | ||
if (comments) common.removeComment(value); | ||
var i, length; // loop | ||
var any, res; | ||
if (Object.prototype.toString.apply(value) === '[object Array]') { | ||
res={ a: [] }; | ||
for (i=0, length=value.length; i<length; i++) { | ||
if (saveComment(res.a, i, comments.a[i], extractComments(value[i]))) | ||
any=true; | ||
} | ||
if (!any && comments.e){ | ||
res.e=makeComment(comments.e[0], comments.e[1]); | ||
any=true; | ||
} | ||
} else { | ||
res={ s: {} }; | ||
// get key order (comments and current) | ||
var keys, currentKeys=Object.keys(value); | ||
if (comments && comments.o) { | ||
keys=[]; | ||
comments.o.concat(currentKeys).forEach(function(key) { | ||
if (Object.prototype.hasOwnProperty.call(value, key) && keys.indexOf(key)<0) | ||
keys.push(key); | ||
}); | ||
} else keys=currentKeys; | ||
res.o=keys; | ||
// extract comments | ||
for (i=0, length=keys.length; i<length; i++) { | ||
var key=keys[i]; | ||
if (saveComment(res.s, key, comments.c[key], extractComments(value[key]))) | ||
any=true; | ||
} | ||
if (!any && comments.e) { | ||
res.e=makeComment(comments.e[0], comments.e[1]); | ||
any=true; | ||
} | ||
} | ||
if (root && comments && comments.r) { | ||
res.r=makeComment(comments.r[0], comments.r[1]); | ||
} | ||
return any?res:undefined; | ||
} | ||
function mergeStr() { | ||
var res=""; | ||
[].forEach.call(arguments, function(c) { | ||
if (c && c.trim()!=="") { | ||
if (res) res+="; "; | ||
res+=c.trim(); | ||
} | ||
}); | ||
return res; | ||
} | ||
function mergeComments(comments, value) { | ||
var dropped=[]; | ||
merge(comments, value, dropped, []); | ||
// append dropped comments: | ||
if (dropped.length>0) { | ||
var text=rootComment(value, null, 1); | ||
text+="\n# Orphaned comments:\n"; | ||
dropped.forEach(function(c) { | ||
text+=("# "+c.path.join('/')+": "+mergeStr(c.b, c.a, c.e)).replace("\n", "\\n ")+"\n"; | ||
}); | ||
rootComment(value, text, 1); | ||
} | ||
} | ||
function saveComment(res, key, item, col) { | ||
var c=makeComment(item?item[0]:undefined, item?item[1]:undefined, col); | ||
if (c) res[key]=c; | ||
return c; | ||
} | ||
function droppedComment(path, c) { | ||
var res=makeComment(c.b, c.a); | ||
res.path=path; | ||
return res; | ||
} | ||
function dropAll(comments, dropped, path) { | ||
if (!comments) return; | ||
var i, length; // loop | ||
if (comments.a) { | ||
for (i=0, length=comments.a.length; i<length; i++) { | ||
var kpath=path.slice().concat([i]); | ||
var c=comments.a[i]; | ||
if (c) { | ||
dropped.push(droppedComment(kpath, c)); | ||
dropAll(c.x, dropped, kpath); | ||
} | ||
} | ||
} else if (comments.o) { | ||
comments.o.forEach(function(key) { | ||
var kpath=path.slice().concat([key]); | ||
var c=comments.s[key]; | ||
if (c) { | ||
dropped.push(droppedComment(kpath, c)); | ||
dropAll(c.x, dropped, kpath); | ||
} | ||
}); | ||
} | ||
if (comments.e) | ||
dropped.push(droppedComment(path, comments.e)); | ||
} | ||
function merge(comments, value, dropped, path) { | ||
if (!comments) return; | ||
if (value===null || typeof value!=='object') { | ||
dropAll(comments, dropped, path); | ||
return; | ||
} | ||
var i, length; // loop | ||
var setComments=common.createComment(value); | ||
if (path.length===0 && comments.r) | ||
setComments.r=[comments.r.b, comments.r.a]; | ||
if (Object.prototype.toString.apply(value) === '[object Array]') { | ||
setComments.a=[]; | ||
for (i=0, length=(comments.a||[]).length; i<length; i++) { | ||
var kpath=path.slice().concat([i]); | ||
var c=comments.a[i]; | ||
if (!c) continue; | ||
if (i<value.length) { | ||
setComments.a.push([c.b, c.a]); | ||
merge(c.x, value[i], dropped, kpath); | ||
} else { | ||
dropped.push(droppedComment(kpath, c)); | ||
dropAll(c.x, dropped, kpath); | ||
} | ||
} | ||
if (i===0 && comments.e) setComments.e=[comments.e.b, comments.e.a]; | ||
} else { | ||
setComments.c={}; | ||
setComments.o=[]; | ||
(comments.o||[]).forEach(function(key) { | ||
var kpath=path.slice().concat([key]); | ||
var c=comments.s[key]; | ||
if (Object.prototype.hasOwnProperty.call(value, key)) { | ||
setComments.o.push(key); | ||
if (c) { | ||
setComments.c[key]=[c.b, c.a]; | ||
merge(c.x, value[key], dropped, kpath); | ||
} | ||
} else if (c) { | ||
dropped.push(droppedComment(kpath, c)); | ||
dropAll(c.x, dropped, kpath); | ||
} | ||
}); | ||
if (comments.e) setComments.e=[comments.e.b, comments.e.a]; | ||
} | ||
} | ||
function rootComment(value, setText, header) { | ||
var comment=common.createComment(value, common.getComment(value)); | ||
if (!comment.r) comment.r=["", ""]; | ||
if (setText || setText==="") comment.r[header]=common.forceComment(setText); | ||
return comment.r[header]||""; | ||
} | ||
module.exports={ | ||
extract: function(value) { return extractComments(value, true); }, | ||
merge: mergeComments, | ||
header: function(value, setText) { return rootComment(value, setText, 0); }, | ||
footer: function(value, setText) { return rootComment(value, setText, 1); }, | ||
}; | ||
},{"./hjson-common":2}],2:[function(require,module,exports){ | ||
/* Hjson http://hjson.org */ | ||
/* jslint node: true */ | ||
"use strict"; | ||
var os=require('os'); // will be {} when used in a browser | ||
@@ -68,8 +268,48 @@ | ||
function createComment(value, comment) { | ||
if (Object.defineProperty) Object.defineProperty(value, "__COMMENTS__", { enumerable: false, writable: true }); | ||
return (value.__COMMENTS__ = comment||{}); | ||
} | ||
function removeComment(value) { | ||
Object.defineProperty(value, "__COMMENTS__", { value: undefined }); | ||
} | ||
function getComment(value) { | ||
return value.__COMMENTS__; | ||
} | ||
function forceComment(text) { | ||
if (!text) return ""; | ||
var a = text.split('\n'); | ||
var str, i, j, len; | ||
for (j = 0; j < a.length; j++) { | ||
str = a[j]; | ||
len = str.length; | ||
for (i = 0; i < len; i++) { | ||
var c = str[i]; | ||
if (c === '#') break; | ||
else if (c === '/' && (str[i+1] === '/' || str[i+1] === '*')) { | ||
if (str[i+1] === '*') j = a.length; // assume /**/ covers whole block, bail out | ||
break; | ||
} | ||
else if (c > ' ') { | ||
a[j] = '# ' + str; | ||
break; | ||
} | ||
} | ||
} | ||
return a.join('\n'); | ||
} | ||
module.exports = { | ||
EOL: os.EOL || '\n', | ||
tryParseNumber: tryParseNumber, | ||
createComment: createComment, | ||
removeComment: removeComment, | ||
getComment: getComment, | ||
forceComment: forceComment, | ||
}; | ||
},{"os":7}],2:[function(require,module,exports){ | ||
},{"os":8}],3:[function(require,module,exports){ | ||
/* Hjson http://hjson.org */ | ||
@@ -206,3 +446,3 @@ /* jslint node: true */ | ||
},{"./hjson-common":1}],3:[function(require,module,exports){ | ||
},{"./hjson-common":2}],4:[function(require,module,exports){ | ||
/* Hjson http://hjson.org */ | ||
@@ -231,3 +471,3 @@ /* jslint node: true */ | ||
var keepWsc; // keep whitespace | ||
var keepComments; | ||
var runDsf; // domain specific formats | ||
@@ -429,3 +669,3 @@ | ||
function getComment(cAt) { | ||
function getComment(cAt, first) { | ||
var i; | ||
@@ -443,4 +683,7 @@ cAt--; | ||
var j = res.indexOf('\n'); | ||
if (j >= 0) return [res.substr(0, j), res.substr(j+1)]; | ||
else return [res]; | ||
if (j >= 0) { | ||
var c = [res.substr(0, j), res.substr(j+1)]; | ||
if (first && c[0].trim().length === 0) c.shift(); | ||
return c; | ||
} else return [res]; | ||
} | ||
@@ -492,6 +735,3 @@ } | ||
try { | ||
if (keepWsc) { | ||
if (Object.defineProperty) Object.defineProperty(array, "__COMMENTS__", { enumerable: false, writable: true }); | ||
array.__COMMENTS__ = comments = []; | ||
} | ||
if (keepComments) comments = common.createComment(array, { a: [] }); | ||
@@ -501,6 +741,6 @@ next(); | ||
white(); | ||
if (comments) nextComment = getComment(cAt).join(''); | ||
if (comments) nextComment = getComment(cAt, true).join('\n'); | ||
if (ch === ']') { | ||
next(); | ||
if (comments) comments.push([nextComment]); | ||
if (comments) comments.e = [nextComment]; | ||
return array; // empty array | ||
@@ -518,3 +758,3 @@ } | ||
var c = getComment(cAt); | ||
comments.push([nextComment||"", c[0]||""]); | ||
comments.a.push([nextComment||"", c[0]||""]); | ||
nextComment = c[1]; | ||
@@ -524,3 +764,3 @@ } | ||
next(); | ||
if (comments) comments[comments.length-1][1] += nextComment||""; | ||
if (comments) comments.a[comments.a.length-1][1] += nextComment||""; | ||
return array; | ||
@@ -545,6 +785,3 @@ } | ||
try { | ||
if (keepWsc) { | ||
if (Object.defineProperty) Object.defineProperty(object, "__COMMENTS__", { enumerable: false, writable: true }); | ||
object.__COMMENTS__ = comments = { c: {}, o: [] }; | ||
} | ||
if (keepComments) comments = common.createComment(object, { c: {}, o: [] }); | ||
@@ -558,5 +795,5 @@ if (!withoutBraces) { | ||
white(); | ||
if (comments) nextComment = getComment(cAt).join(''); | ||
if (comments) nextComment = getComment(cAt, true).join('\n'); | ||
if (ch === '}' && !withoutBraces) { | ||
if (comments) comments.c[""] = [nextComment]; | ||
if (comments) comments.e = [nextComment]; | ||
next(); | ||
@@ -581,3 +818,3 @@ return object; // empty object | ||
nextComment = c[1]; | ||
if (key) comments.o.push(key); | ||
comments.o.push(key); | ||
} | ||
@@ -612,5 +849,13 @@ if (ch === '}' && !withoutBraces) { | ||
function checkTrailing(v) { | ||
function checkTrailing(v, c) { | ||
var cAt = at; | ||
white(); | ||
if (ch) error("Syntax error, found trailing characters"); | ||
if (keepComments) { | ||
var b = c.join('\n'), a = getComment(cAt).join('\n'); | ||
if (a || b) { | ||
var comments = common.createComment(v, common.getComment(v)); | ||
comments.r = [b, a]; | ||
} | ||
} | ||
return v; | ||
@@ -622,5 +867,6 @@ } | ||
white(); | ||
var c = keepComments ? getComment(1) : null; | ||
switch (ch) { | ||
case '{': return checkTrailing(object()); | ||
case '[': return checkTrailing(array()); | ||
case '{': return checkTrailing(object(), c); | ||
case '[': return checkTrailing(array(), c); | ||
} | ||
@@ -630,7 +876,7 @@ | ||
// assume we have a root object without braces | ||
return checkTrailing(object(true)); | ||
return checkTrailing(object(true), c); | ||
} catch (e) { | ||
// test if we are dealing with a single JSON value instead (true/false/null/num/"") | ||
resetAt(); | ||
try { return checkTrailing(value()); } | ||
try { return checkTrailing(value(), c); } | ||
catch (e2) { throw e; } // throw original error | ||
@@ -644,3 +890,3 @@ } | ||
if (opt && typeof opt === 'object') { | ||
keepWsc = opt.keepWsc; | ||
keepComments = opt.keepWsc; | ||
dsfDef = opt.dsf; | ||
@@ -657,3 +903,3 @@ } | ||
},{"./hjson-common":1,"./hjson-dsf":2}],4:[function(require,module,exports){ | ||
},{"./hjson-common":2,"./hjson-dsf":3}],5:[function(require,module,exports){ | ||
/* Hjson http://hjson.org */ | ||
@@ -692,3 +938,3 @@ /* jslint node: true */ | ||
// options | ||
var eol, keepWsc, bracesSameLine, quoteAlways; | ||
var eol, keepComments, bracesSameLine, quoteAlways; | ||
var token = { | ||
@@ -794,10 +1040,6 @@ obj: [ '{', '}' ], | ||
if (!str) return ""; | ||
var i, s = -1, len = str.length; | ||
for (i = 0; i < len; i++) { | ||
var c = str[i]; | ||
if (c === '#' || c === '/' && (str[i+1] === '/' || str[i+1] === '*')) break; | ||
else if (c > ' ') { str = '# ' + str; break; } | ||
else s = i; // space | ||
} | ||
if (trim && s >= 0) str = str.substr(s + 1); | ||
str = common.forceComment(str); | ||
var i, len = str.length; | ||
for (i = 0; i < len && str[i] <= ' '; i++) {} | ||
if (trim && i > 0) str = str.substr(i); | ||
if (i < len) return prefix + wrap(token.rem, str); | ||
@@ -833,4 +1075,4 @@ else return str; | ||
var comments, lastComment; // whitespace & comments | ||
if (keepWsc) comments = value.__COMMENTS__; | ||
var comments; // whitespace & comments | ||
if (keepComments) comments = common.getComment(value); | ||
@@ -857,8 +1099,8 @@ var isArray = Object.prototype.toString.apply(value) === '[object Array]'; | ||
if (comments) { | ||
c = comments[i]||[]; | ||
ca = commentOnThisLine(c[1]) ? c[1] : ""; | ||
c = comments.a[i]||[]; | ||
ca = commentOnThisLine(c[1]); | ||
partial.push(makeComment(c[0], "\n") + eolGap); | ||
} | ||
partial.push(str(value[i], comments ? ca : false, true) || wrap(token.lit, 'null')); | ||
if (ca) partial.push(makeComment(ca, " ", true)); | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
} | ||
@@ -869,4 +1111,3 @@ | ||
// when empty | ||
c = comments[0]; | ||
partial.push(makeComment(c[0], "\n") + eolMind); | ||
partial.push((comments.e ? makeComment(comments.e[0], "\n") : "") + eolMind); | ||
} | ||
@@ -895,3 +1136,3 @@ else partial.push(eolMind); | ||
c = comments.c[k]||[]; | ||
ca = commentOnThisLine(c[1]) ? c[1] : ""; | ||
ca = commentOnThisLine(c[1]); | ||
partial.push(makeComment(c[0], "\n") + eolGap); | ||
@@ -901,8 +1142,7 @@ | ||
if (v) partial.push(quoteKey(k) + token.col + (startsWithNL(v) ? '' : ' ') + v); | ||
if (ca) partial.push(makeComment(ca, " ", true)); | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
} | ||
if (length === 0) { | ||
// when empty | ||
c = comments.c[""]; | ||
partial.push(makeComment(c[0], "\n") + eolMind); | ||
partial.push((comments.e ? makeComment(comments.e[0], "\n") : "") + eolMind); | ||
} | ||
@@ -941,3 +1181,3 @@ else partial.push(eolMind); | ||
indent = ' '; | ||
keepWsc = false; | ||
keepComments = false; | ||
bracesSameLine = false; | ||
@@ -949,3 +1189,3 @@ quoteAlways = false; | ||
space = opt.space; | ||
keepWsc = opt.keepWsc; | ||
keepComments = opt.keepWsc; | ||
bracesSameLine = opt.bracesSameLine; | ||
@@ -987,4 +1227,12 @@ quoteAlways = opt.quotes === 'always'; | ||
// Return the result of stringifying the value. | ||
return str(value, null, true, true); | ||
var res = ""; | ||
var comments = keepComments ? comments = (common.getComment(value) || {}).r : null; | ||
if (comments && comments[0]) res = comments[0] + '\n'; | ||
// get the result of stringifying the value. | ||
res += str(value, null, true, true); | ||
if (comments) res += comments[1]||""; | ||
return res; | ||
} | ||
@@ -995,8 +1243,8 @@ | ||
},{"./hjson-common":1,"./hjson-dsf":2}],5:[function(require,module,exports){ | ||
module.exports="2.3.0"; | ||
},{"./hjson-common":2,"./hjson-dsf":3}],6:[function(require,module,exports){ | ||
module.exports="2.3.1"; | ||
},{}],6:[function(require,module,exports){ | ||
},{}],7:[function(require,module,exports){ | ||
/*! @preserve | ||
* Hjson v2.3.0 | ||
* Hjson v2.3.1 | ||
* http://hjson.org | ||
@@ -1130,2 +1378,3 @@ * | ||
var stringify = require("./hjson-stringify"); | ||
var comments = require("./hjson-comments"); | ||
var dsf = require("./hjson-dsf"); | ||
@@ -1157,2 +1406,4 @@ | ||
comments: comments, | ||
dsf: dsf.std, | ||
@@ -1162,5 +1413,5 @@ | ||
},{"./hjson-common":1,"./hjson-dsf":2,"./hjson-parse":3,"./hjson-stringify":4,"./hjson-version":5}],7:[function(require,module,exports){ | ||
},{"./hjson-comments":1,"./hjson-common":2,"./hjson-dsf":3,"./hjson-parse":4,"./hjson-stringify":5,"./hjson-version":6}],8:[function(require,module,exports){ | ||
},{}]},{},[6])(6) | ||
},{}]},{},[7])(7) | ||
}); |
@@ -1,3 +0,3 @@ | ||
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.Hjson=r()}}(function(){return function r(n,t,e){function o(f,u){if(!t[f]){if(!n[f]){var s="function"==typeof require&&require;if(!u&&s)return s(f,!0);if(i)return i(f,!0);var a=new Error("Cannot find module '"+f+"'");throw a.code="MODULE_NOT_FOUND",a}var c=t[f]={exports:{}};n[f][0].call(c.exports,function(r){var t=n[f][1][r];return o(t?t:r)},c,c.exports,r,n,t,e)}return t[f].exports}for(var i="function"==typeof require&&require,f=0;f<e.length;f++)o(e[f]);return o}({1:[function(r,n,t){"use strict";function e(r,n){function t(){return o=r.charAt(s),s++,o}var e,o,i="",f=0,u=!0,s=0;for(t(),"-"===o&&(i="-",t());o>="0"&&o<="9";)u&&("0"==o?f++:u=!1),i+=o,t();if(u&&f--,"."===o)for(i+=".";t()&&o>="0"&&o<="9";)i+=o;if("e"===o||"E"===o)for(i+=o,t(),"-"!==o&&"+"!==o||(i+=o,t());o>="0"&&o<="9";)i+=o,t();for(;o&&o<=" ";)t();return n&&(","!==o&&"}"!==o&&"]"!==o&&"#"!==o&&("/"!==o||"/"!==r[s]&&"*"!==r[s])||(o=0)),e=+i,o||f||!isFinite(e)?void 0:e}var o=r("os");n.exports={EOL:o.EOL||"\n",tryParseNumber:e}},{os:7}],2:[function(r,n,t){"use strict";function e(r,n){function t(r){return"[object Function]"==={}.toString.call(r)}if("[object Array]"!==Object.prototype.toString.apply(r)){if(r)throw new Error("dsf option must contain an array!");return i}if(0===r.length)return i;var e=[];return r.forEach(function(r){if(!r.name||!t(r.parse)||!t(r.stringify))throw new Error("extension does not match the DSF interface");e.push(function(){try{if("parse"==n)return r.parse.apply(null,arguments);if("stringify"==n){var t=r.stringify.apply(null,arguments);if(void 0!==t&&("string"!=typeof t||0===t.length||'"'===t[0]||[].some.call(t,function(r){return f(r)})))throw new Error("value may not be empty, start with a quote or contain a punctuator character except colon: "+t);return t}throw new Error("Invalid type")}catch(n){throw new Error("DSF-"+r.name+" failed; "+n.message)}})}),o.bind(null,e)}function o(r,n){if(r)for(var t=0;t<r.length;t++){var e=r[t](n);if(void 0!==e)return e}}function i(r){}function f(r){return"{"===r||"}"===r||"["===r||"]"===r||","===r}function u(r){return{name:"math",parse:function(r){switch(r){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(r){if("number"==typeof r)return 1/r===-(1/0)?"-0":r===1/0?"Inf":r===-(1/0)?"-Inf":isNaN(r)?"NaN":void 0}}}function s(r){var n=r&&r.out;return{name:"hex",parse:function(r){if(/^0x[0-9A-Fa-f]+$/.test(r))return parseInt(r,16)},stringify:function(r){if(n&&Number.isInteger(r))return"0x"+r.toString(16)}}}function a(r){return{name:"date",parse:function(r){if(/^\d{4}-\d{2}-\d{2}$/.test(r)||/^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}(?:.\d+)(?:Z|[+-]\d{2}:\d{2})$/.test(r)){var n=Date.parse(r);if(!isNaN(n))return new Date(n)}},stringify:function(r){if("[object Date]"===Object.prototype.toString.call(r)){var n=r.toISOString();return n.indexOf("T00:00:00.000Z",n.length-14)!==-1?n.substr(0,10):n}}}}r("./hjson-common");u.description="support for Inf/inf, -Inf/-inf, Nan/naN and -0",s.description="parse hexadecimal numbers prefixed with 0x",a.description="support ISO dates",n.exports={loadDsf:e,std:{math:u,hex:s,date:a}}},{"./hjson-common":1}],3:[function(r,n,t){"use strict";n.exports=function(n,t){function e(){w=0,O=" "}function o(r){return"{"===r||"}"===r||"["===r||"]"===r||","===r||":"===r}function i(r){var n,t=0,e=1;for(n=w-1;n>0&&"\n"!==x[n];n--,t++);for(;n>0;n--)"\n"===x[n]&&e++;throw new Error(r+" at line "+e+","+t+" >>>"+x.substr(w-t,20)+" ...")}function f(){return O=x.charAt(w),w++,O}function u(r){return x.charAt(w+r)}function s(){var r="";if('"'===O)for(;f();){if('"'===O)return f(),r;if("\\"===O)if(f(),"u"===O){for(var n=0,t=0;t<4;t++){f();var e,o=O.charCodeAt(0);O>="0"&&O<="9"?e=o-48:O>="a"&&O<="f"?e=o-97+10:O>="A"&&O<="F"?e=o-65+10:i("Bad \\u char "+O),n=16*n+e}r+=String.fromCharCode(n)}else{if("string"!=typeof _[O])break;r+=_[O]}else r+=O}i("Bad string")}function a(){function r(){for(var r=e;O&&O<=" "&&"\n"!==O&&r-- >0;)f()}for(var n="",t=0,e=0;;){var o=u(-e-5);if(!o||"\n"===o)break;e++}for(;O&&O<=" "&&"\n"!==O;)f();for("\n"===O&&(f(),r());;){if(O){if("'"===O){if(t++,f(),3===t)return"\n"===n.slice(-1)&&(n=n.slice(0,-1)),n;continue}for(;t>0;)n+="'",t--}else i("Bad multiline string");"\n"===O?(n+="\n",f(),r()):("\r"!==O&&(n+=O),f())}}function c(){if('"'===O)return s();for(var r="",n=w,t=-1;;){if(":"===O)return r?t>=0&&t!==r.length&&(w=n+t,i("Found whitespace in your key name (use quotes to include)")):i("Found ':' but no key name (for an empty key name use quotes)"),r;O<=" "?O?t<0&&(t=r.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)"):r+=O,f()}}function l(){for(;O;){for(;O&&O<=" ";)f();if("#"===O||"/"===O&&"/"===u(0))for(;O&&"\n"!==O;)f();else{if("/"!==O||"*"!==u(0))break;for(f(),f();O&&("*"!==O||"/"!==u(0));)f();O&&(f(),f())}}}function p(){var r=O;for(o(O)&&i("Found a punctuator character '"+O+"' when expecting a quoteless string (check your syntax)");;){if(f(),3===r.length&&"'''"===r)return a();var n="\r"===O||"\n"===O||""===O;if(n||","===O||"}"===O||"]"===O||"#"===O||"/"===O&&("/"===u(0)||"*"===u(0))){var t=r[0];switch(t){case"f":if("false"===r.trim())return!1;break;case"n":if("null"===r.trim())return null;break;case"t":if("true"===r.trim())return!0;break;default:if("-"===t||t>="0"&&t<="9"){var e=N.tryParseNumber(r);if(void 0!==e)return e}}if(n){r=r.trim();var s=E(r);return void 0!==s?s:r}}r+=O}}function h(r){var n;for(r--,n=w-2;n>r&&x[n]<=" "&&"\n"!==x[n];n--);"\n"===x[n]&&n--,"\r"===x[n]&&n--;var t=x.substr(r,n-r+1);for(n=0;n<t.length;n++)if(t[n]>" "){var e=t.indexOf("\n");return e>=0?[t.substr(0,e),t.substr(e+1)]:[t]}return[]}function d(r){function n(r,t){var e,o,i,f;switch(typeof r){case"string":r.indexOf(t)>=0&&(f=r);break;case"object":if("[object Array]"===Object.prototype.toString.apply(r))for(e=0,i=r.length;e<i;e++)f=n(r[e],t)||f;else for(o in r)Object.prototype.hasOwnProperty.call(r,o)&&(f=n(r[o],t)||f)}return f}function t(t){var e=n(r,t);return e?"found '"+t+"' in a string value, your mistake could be with:\n > "+e+"\n (unquoted strings contain everything up to the next line!)":""}return t("}")||t("]")}function m(){var r,n,t,e=[];try{if(k&&(Object.defineProperty&&Object.defineProperty(e,"__COMMENTS__",{enumerable:!1,writable:!0}),e.__COMMENTS__=r=[]),f(),n=w,l(),r&&(t=h(n).join("")),"]"===O)return f(),r&&r.push([t]),e;for(;O;){if(e.push(b()),n=w,l(),","===O&&(f(),n=w,l()),r){var o=h(n);r.push([t||"",o[0]||""]),t=o[1]}if("]"===O)return f(),r&&(r[r.length-1][1]+=t||""),e;l()}i("End of input while parsing an array (missing ']')")}catch(r){throw r.hint=r.hint||d(e),r}}function y(r){var n,t,e,o="",u={};try{if(k&&(Object.defineProperty&&Object.defineProperty(u,"__COMMENTS__",{enumerable:!1,writable:!0}),u.__COMMENTS__=n={c:{},o:[]}),r?t=1:(f(),t=w),l(),n&&(e=h(t).join("")),"}"===O&&!r)return n&&(n.c[""]=[e]),f(),u;for(;O;){if(o=c(),l(),":"!==O&&i("Expected ':' instead of '"+O+"'"),f(),u[o]=b(),t=w,l(),","===O&&(f(),t=w,l()),n){var s=h(t);n.c[o]=[e||"",s[0]||""],e=s[1],o&&n.o.push(o)}if("}"===O&&!r)return f(),n&&(n.c[o][1]+=e||""),u;l()}if(r)return u;i("End of input while parsing an object (missing '}')")}catch(r){throw r.hint=r.hint||d(u),r}}function b(){switch(l(),O){case"{":return y();case"[":return m();case'"':return s();default:return p()}}function g(r){return l(),O&&i("Syntax error, found trailing characters"),r}function v(){switch(l(),O){case"{":return g(y());case"[":return g(m())}try{return g(y(!0))}catch(r){e();try{return g(b())}catch(n){throw r}}}function j(r,n){if("string"!=typeof r)throw new Error("source is not a string");var t=null;return n&&"object"==typeof n&&(k=n.keepWsc,t=n.dsf),E=S.loadDsf(t,"parse"),x=r,e(),v()}var x,w,O,k,E,N=r("./hjson-common"),S=r("./hjson-dsf"),_={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};return j(n,t)}},{"./hjson-common":1,"./hjson-dsf":2}],4:[function(r,n,t){"use strict";n.exports=function(n,t){function e(r,n){return r[0]+n+r[1]}function o(r){return r.replace(b,function(r){var n=x[r];return"string"==typeof n?e(E.esc,n):e(E.uni,("0000"+r.charCodeAt(0).toString(16)).slice(-4))})}function i(r,n,t,i){return r?(g.lastIndex=0,j.lastIndex=0,d||t||g.test(r)||void 0!==m.tryParseNumber(r,!0)||j.test(r)?(b.lastIndex=0,v.lastIndex=0,b.test(r)?v.test(r)||i?e(E.qstr,o(r)):f(r,n):e(E.qstr,r)):e(E.str,r)):e(E.qstr,"")}function f(r,n){var t,o=r.replace(/\r/g,"").split("\n");if(n+=k,1===o.length)return e(E.mstr,o[0]);var i=l+n+E.mstr[0];for(t=0;t<o.length;t++)i+=l,o[t]&&(i+=n+o[t]);return i+l+n+E.mstr[1]}function u(r){return r?w.test(r)?(b.lastIndex=0,e(E.qkey,b.test(r)?o(r):r)):e(E.key,r):'""'}function s(r,n,t,o){function f(r){return r&&"\n"===r["\r"===r[0]?1:0]}function a(r){return r&&!f(r)}function d(r,n,t){if(!r)return"";var o,i=-1,f=r.length;for(o=0;o<f;o++){var u=r[o];if("#"===u||"/"===u&&("/"===r[o+1]||"*"===r[o+1]))break;if(u>" "){r="# "+r;break}i=o}return t&&i>=0&&(r=r.substr(i+1)),o<f?n+e(E.rem,r):r}var m=c(r);if(void 0!==m)return e(E.dsf,m);switch(typeof r){case"string":return i(r,O,n,o);case"number":return isFinite(r)?e(E.num,String(r)):e(E.lit,"null");case"boolean":return e(E.lit,String(r));case"object":if(!r)return e(E.lit,"null");var y;p&&(y=r.__COMMENTS__);var b="[object Array]"===Object.prototype.toString.apply(r),g=O;O+=k;var v,j,x,w,N,S,_=l+g,q=l+O,I=t||h?"":_,F=[];if(b){for(v=0,j=r.length;v<j;v++)y&&(N=y[v]||[],S=a(N[1])?N[1]:"",F.push(d(N[0],"\n")+q)),F.push(s(r[v],!!y&&S,!0)||e(E.lit,"null")),S&&F.push(d(S," ",!0));y&&(0===j?(N=y[0],F.push(d(N[0],"\n")+_)):F.push(_)),w=y?I+e(E.arr,F.join("")):0===F.length?e(E.arr,""):I+e(E.arr,q+F.join(q)+_)}else{if(y){var M=y.o.slice();for(x in r)Object.prototype.hasOwnProperty.call(r,x)&&M.indexOf(x)<0&&M.push(x);for(v=0,j=M.length;v<j;v++)x=M[v],N=y.c[x]||[],S=a(N[1])?N[1]:"",F.push(d(N[0],"\n")+q),w=s(r[x],S),w&&F.push(u(x)+E.col+(f(w)?"":" ")+w),S&&F.push(d(S," ",!0));0===j?(N=y.c[""],F.push(d(N[0],"\n")+_)):F.push(_)}else for(x in r)Object.prototype.hasOwnProperty.call(r,x)&&(w=s(r[x]),w&&F.push(u(x)+E.col+(f(w)?"":" ")+w));w=0===F.length?e(E.obj,""):y?I+e(E.obj,F.join("")):I+e(E.obj,q+F.join(q)+_)}return O=g,w}}function a(r,n){var t,e,o=null;if(l=m.EOL,k=" ",p=!1,h=!1,d=!1,n&&"object"==typeof n&&("\n"!==n.eol&&"\r\n"!==n.eol||(l=n.eol),e=n.space,p=n.keepWsc,h=n.bracesSameLine,d="always"===n.quotes,o=n.dsf,n.colors===!0&&(E={obj:["[30;1m{[0m","[30;1m}[0m"],arr:["[30;1m[[0m","[30;1m][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:["[30;1m","[0m"]})),c=y.loadDsf(o,"stringify"),"number"==typeof e)for(k="",t=0;t<e;t++)k+=" ";else"string"==typeof e&&(k=e);return s(r,null,!0,!0)}var c,l,p,h,d,m=r("./hjson-common"),y=r("./hjson-dsf"),b=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g=/^\s|^"|^'''|^#|^\/\*|^\/\/|^\{|^\}|^\[|^\]|^:|^,|\s$|[\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,v=/'''|[\x00-\x09\x0b\x0c\x0e-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,j=/^(true|false|null)\s*((,|\]|\}|#|\/\/|\/\*).*)?$/,x={"\b":"b","\t":"t","\n":"n","\f":"f","\r":"r",'"':'"',"\\":"\\"},w=/[,\{\[\}\]\s:#"]|\/\/|\/\*|'''/,O="",k=" ",E={obj:["{","}"],arr:["[","]"],key:["",""],qkey:['"','"'],col:[":"],str:["",""],qstr:['"','"'],mstr:["'''","'''"],num:["",""],lit:["",""],dsf:["",""],esc:["\\",""],uni:["\\u",""],rem:["",""]};return a(n,t)}},{"./hjson-common":1,"./hjson-dsf":2}],5:[function(r,n,t){n.exports="2.3.0"},{}],6:[function(r,n,t){/*! @preserve | ||
* Hjson v2.3.0 | ||
!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(f,u){if(!e[f]){if(!r[f]){var a="function"==typeof require&&require;if(!u&&a)return a(f,!0);if(i)return i(f,!0);var s=new Error("Cannot find module '"+f+"'");throw s.code="MODULE_NOT_FOUND",s}var c=e[f]={exports:{}};r[f][0].call(c.exports,function(n){var e=r[f][1][n];return o(e?e:n)},c,c.exports,n,r,e,t)}return e[f].exports}for(var i="function"==typeof require&&require,f=0;f<t.length;f++)o(t[f]);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=m.getComment(n);e&&m.removeComment(n);var i,f,a,s;if("[object Array]"===Object.prototype.toString.apply(n)){for(s={a:[]},i=0,f=n.length;i<f;i++)u(s.a,i,e.a[i],o(n[i]))&&(a=!0);!a&&e.e&&(s.e=t(e.e[0],e.e[1]),a=!0)}else{s={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,s.o=c,i=0,f=c.length;i<f;i++){var p=c[i];u(s.s,p,e.c[p],o(n[p]))&&(a=!0)}!a&&e.e&&(s.e=t(e.e[0],e.e[1]),a=!0)}return r&&e&&e.r&&(s.r=t(e.r[0],e.r[1])),a?s:void 0}}function i(){var n="";return[].forEach.call(arguments,function(r){r&&""!==r.trim()&&(n&&(n+="; "),n+=r.trim())}),n}function f(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 a(n,r){var e=t(r.b,r.a);return e.path=n,e}function s(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]),f=n.a[t];f&&(r.push(a(i,f)),s(f.x,r,i))}else n.o&&n.o.forEach(function(t){var o=e.slice().concat([t]),i=n.s[t];i&&(r.push(a(o,i)),s(i.x,r,o))});n.e&&r.push(a(e,n.e))}}function c(n,r,e,t){if(n){if(null===r||"object"!=typeof r)return void s(n,e,t);var o,i,f=m.createComment(r);if(0===t.length&&n.r&&(f.r=[n.r.b,n.r.a]),"[object Array]"===Object.prototype.toString.apply(r)){for(f.a=[],o=0,i=(n.a||[]).length;o<i;o++){var u=t.slice().concat([o]),l=n.a[o];l&&(o<r.length?(f.a.push([l.b,l.a]),c(l.x,r[o],e,u)):(e.push(a(u,l)),s(l.x,e,u)))}0===o&&n.e&&(f.e=[n.e.b,n.e.a])}else f.c={},f.o=[],(n.o||[]).forEach(function(o){var i=t.slice().concat([o]),u=n.s[o];Object.prototype.hasOwnProperty.call(r,o)?(f.o.push(o),u&&(f.c[o]=[u.b,u.a],c(u.x,r[o],e,i))):u&&(e.push(a(i,u)),s(u.x,e,i))}),n.e&&(f.e=[n.e.b,n.e.a])}}function l(n,r,e){var t=m.createComment(n,m.getComment(n));return t.r||(t.r=["",""]),(r||""===r)&&(t.r[e]=m.forceComment(r)),t.r[e]||""}var m=n("./hjson-common");r.exports={extract:function(n){return o(n,!0)},merge:f,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(a),a++,o}var t,o,i="",f=0,u=!0,a=0;for(e(),"-"===o&&(i="-",e());o>="0"&&o<="9";)u&&("0"==o?f++:u=!1),i+=o,e();if(u&&f--,"."===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[a]&&"*"!==n[a])||(o=0)),t=+i,o||f||!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 f(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 f=r[e];if("#"===f)break;if("/"===f&&("/"===r[e+1]||"*"===r[e+1])){"*"===r[e+1]&&(t=i.length);break}if(f>" "){i[t]="# "+r;break}}return i.join("\n")}var a=n("os");r.exports={EOL:a.EOL||"\n",tryParseNumber:t,createComment:o,removeComment:i,getComment:f,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 f(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(n){}function f(n){return"{"===n||"}"===n||"["===n||"]"===n||","===n}function u(n){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 a(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 s(n){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}}}}n("./hjson-common");u.description="support for Inf/inf, -Inf/-inf, Nan/naN and -0",a.description="parse hexadecimal numbers prefixed with 0x",s.description="support ISO dates",r.exports={loadDsf:t,std:{math:u,hex:a,date:s}}},{"./hjson-common":2}],4:[function(n,r,e){"use strict";r.exports=function(r,e){function t(){w=0,O=" "}function o(n){return"{"===n||"}"===n||"["===n||"]"===n||","===n||":"===n}function i(n){var r,e=0,t=1;for(r=w-1;r>0&&"\n"!==x[r];r--,e++);for(;r>0;r--)"\n"===x[r]&&t++;throw new Error(n+" at line "+t+","+e+" >>>"+x.substr(w-e,20)+" ...")}function f(){return O=x.charAt(w),w++,O}function u(n){return x.charAt(w+n)}function a(){var n="";if('"'===O)for(;f();){if('"'===O)return f(),n;if("\\"===O)if(f(),"u"===O){for(var r=0,e=0;e<4;e++){f();var t,o=O.charCodeAt(0);O>="0"&&O<="9"?t=o-48:O>="a"&&O<="f"?t=o-97+10:O>="A"&&O<="F"?t=o-65+10:i("Bad \\u char "+O),r=16*r+t}n+=String.fromCharCode(r)}else{if("string"!=typeof N[O])break;n+=N[O]}else n+=O}i("Bad string")}function s(){function n(){for(var n=t;O&&O<=" "&&"\n"!==O&&n-- >0;)f()}for(var r="",e=0,t=0;;){var o=u(-t-5);if(!o||"\n"===o)break;t++}for(;O&&O<=" "&&"\n"!==O;)f();for("\n"===O&&(f(),n());;){if(O){if("'"===O){if(e++,f(),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",f(),n()):("\r"!==O&&(r+=O),f())}}function c(){if('"'===O)return a();for(var n="",r=w,e=-1;;){if(":"===O)return n?e>=0&&e!==n.length&&(w=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,f()}}function l(){for(;O;){for(;O&&O<=" ";)f();if("#"===O||"/"===O&&"/"===u(0))for(;O&&"\n"!==O;)f();else{if("/"!==O||"*"!==u(0))break;for(f(),f();O&&("*"!==O||"/"!==u(0));)f();O&&(f(),f())}}}function m(){var n=O;for(o(O)&&i("Found a punctuator character '"+O+"' when expecting a quoteless string (check your syntax)");;){if(f(),3===n.length&&"'''"===n)return s();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 a=E(n);return void 0!==a?a:n}}n+=O}}function p(n,r){var e;for(n--,e=w-2;e>n&&x[e]<=" "&&"\n"!==x[e];e--);"\n"===x[e]&&e--,"\r"===x[e]&&e--;var t=x.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 h(n){function r(n,e){var t,o,i,f;switch(typeof n){case"string":n.indexOf(e)>=0&&(f=n);break;case"object":if("[object Array]"===Object.prototype.toString.apply(n))for(t=0,i=n.length;t<i;t++)f=r(n[t],e)||f;else for(o in n)Object.prototype.hasOwnProperty.call(n,o)&&(f=r(n[o],e)||f)}return f}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:[]})),f(),r=w,l(),n&&(e=p(r,!0).join("\n")),"]"===O)return f(),n&&(n.e=[e]),t;for(;O;){if(t.push(v()),r=w,l(),","===O&&(f(),r=w,l()),n){var o=p(r);n.a.push([e||"",o[0]||""]),e=o[1]}if("]"===O)return f(),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||h(t),n}}function y(n){var r,e,t,o="",u={};try{if(k&&(r=C.createComment(u,{c:{},o:[]})),n?e=1:(f(),e=w),l(),r&&(t=p(e,!0).join("\n")),"}"===O&&!n)return r&&(r.e=[t]),f(),u;for(;O;){if(o=c(),l(),":"!==O&&i("Expected ':' instead of '"+O+"'"),f(),u[o]=v(),e=w,l(),","===O&&(f(),e=w,l()),r){var a=p(e);r.c[o]=[t||"",a[0]||""],t=a[1],r.o.push(o)}if("}"===O&&!n)return f(),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||h(u),n}}function v(){switch(l(),O){case"{":return y();case"[":return d();case'"':return a();default:return m()}}function g(n,r){var e=w;if(l(),O&&i("Syntax error, found trailing characters"),k){var t=r.join("\n"),o=p(e).join("\n");if(o||t){var f=C.createComment(n,C.getComment(n));f.r=[t,o]}}return n}function b(){l();var n=k?p(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}}}function j(n,r){if("string"!=typeof n)throw new Error("source is not a string");var e=null;return r&&"object"==typeof r&&(k=r.keepWsc,e=r.dsf),E=S.loadDsf(e,"parse"),x=n,t(),b()}var x,w,O,k,E,C=n("./hjson-common"),S=n("./hjson-dsf"),N={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};return j(r,e)}},{"./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(v,function(n){var r=x[n];return"string"==typeof r?t(E.esc,r):t(E.uni,("0000"+n.charCodeAt(0).toString(16)).slice(-4))})}function i(n,r,e,i){return n?(g.lastIndex=0,j.lastIndex=0,h||e||g.test(n)||void 0!==d.tryParseNumber(n,!0)||j.test(n)?(v.lastIndex=0,b.lastIndex=0,v.test(n)?b.test(n)||i?t(E.qstr,o(n)):f(n,r):t(E.qstr,n)):t(E.str,n)):t(E.qstr,"")}function f(n,r){var e,o=n.replace(/\r/g,"").split("\n");if(r+=k,1===o.length)return t(E.mstr,o[0]);var i=l+r+E.mstr[0];for(e=0;e<o.length;e++)i+=l,o[e]&&(i+=r+o[e]);return i+l+r+E.mstr[1]}function u(n){return n?w.test(n)?(v.lastIndex=0,t(E.qkey,v.test(n)?o(n):n)):t(E.key,n):'""'}function a(n,r,e,o){function f(n){return n&&"\n"===n["\r"===n[0]?1:0]}function s(n){return n&&!f(n)}function h(n,r,e){if(!n)return"";n=d.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(E.rem,n):n}var y=c(n);if(void 0!==y)return t(E.dsf,y);switch(typeof n){case"string":return i(n,O,r,o);case"number":return isFinite(n)?t(E.num,String(n)):t(E.lit,"null");case"boolean":return t(E.lit,String(n));case"object":if(!n)return t(E.lit,"null");var v;m&&(v=d.getComment(n));var g="[object Array]"===Object.prototype.toString.apply(n),b=O;O+=k;var j,x,w,C,S,N,q=l+b,_=l+O,I=e||p?"":q,F=[];if(g){for(j=0,x=n.length;j<x;j++)v&&(S=v.a[j]||[],N=s(S[1]),F.push(h(S[0],"\n")+_)),F.push(a(n[j],!!v&&N,!0)||t(E.lit,"null")),v&&S[1]&&F.push(h(S[1],N?" ":"\n",N));v&&(0===x?F.push((v.e?h(v.e[0],"\n"):"")+q):F.push(q)),C=v?I+t(E.arr,F.join("")):0===F.length?t(E.arr,""):I+t(E.arr,_+F.join(_)+q)}else{if(v){var A=v.o.slice();for(w in n)Object.prototype.hasOwnProperty.call(n,w)&&A.indexOf(w)<0&&A.push(w);for(j=0,x=A.length;j<x;j++)w=A[j],S=v.c[w]||[],N=s(S[1]),F.push(h(S[0],"\n")+_),C=a(n[w],N),C&&F.push(u(w)+E.col+(f(C)?"":" ")+C),v&&S[1]&&F.push(h(S[1],N?" ":"\n",N));0===x?F.push((v.e?h(v.e[0],"\n"):"")+q):F.push(q)}else for(w in n)Object.prototype.hasOwnProperty.call(n,w)&&(C=a(n[w]),C&&F.push(u(w)+E.col+(f(C)?"":" ")+C));C=0===F.length?t(E.obj,""):v?I+t(E.obj,F.join("")):I+t(E.obj,_+F.join(_)+q)}return O=b,C}}function s(n,r){var e,t,o=null;if(l=d.EOL,k=" ",m=!1,p=!1,h=!1,r&&"object"==typeof r&&("\n"!==r.eol&&"\r\n"!==r.eol||(l=r.eol),t=r.space,m=r.keepWsc,p=r.bracesSameLine,h="always"===r.quotes,o=r.dsf,r.colors===!0&&(E={obj:["[30;1m{[0m","[30;1m}[0m"],arr:["[30;1m[[0m","[30;1m][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:["[30;1m","[0m"]})),c=y.loadDsf(o,"stringify"),"number"==typeof t)for(k="",e=0;e<t;e++)k+=" ";else"string"==typeof t&&(k=t);var i="",f=m?f=(d.getComment(n)||{}).r:null;return f&&f[0]&&(i=f[0]+"\n"),i+=a(n,null,!0,!0),f&&(i+=f[1]||""),i}var c,l,m,p,h,d=n("./hjson-common"),y=n("./hjson-dsf"),v=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g=/^\s|^"|^'''|^#|^\/\*|^\/\/|^\{|^\}|^\[|^\]|^:|^,|\s$|[\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,b=/'''|[\x00-\x09\x0b\x0c\x0e-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,j=/^(true|false|null)\s*((,|\]|\}|#|\/\/|\/\*).*)?$/,x={"\b":"b","\t":"t","\n":"n","\f":"f","\r":"r",'"':'"',"\\":"\\"},w=/[,\{\[\}\]\s:#"]|\/\/|\/\*|'''/,O="",k=" ",E={obj:["{","}"],arr:["[","]"],key:["",""],qkey:['"','"'],col:[":"],str:["",""],qstr:['"','"'],mstr:["'''","'''"],num:["",""],lit:["",""],dsf:["",""],esc:["\\",""],uni:["\\u",""],rem:["",""]};return s(r,e)}},{"./hjson-common":2,"./hjson-dsf":3}],6:[function(n,r,e){r.exports="2.3.1"},{}],7:[function(n,r,e){/*! @preserve | ||
* Hjson v2.3.1 | ||
* http://hjson.org | ||
@@ -12,2 +12,2 @@ * | ||
*/ | ||
"use strict";var e=r("./hjson-common"),o=r("./hjson-version"),i=r("./hjson-parse"),f=r("./hjson-stringify"),u=r("./hjson-dsf");n.exports={parse:i,stringify:f,endOfLine:function(){return e.EOL},setEndOfLine:function(r){"\n"!==r&&"\r\n"!==r||(e.EOL=r)},version:o,rt:{parse:function(r,n){return(n=n||{}).keepWsc=!0,i(r,n)},stringify:function(r,n){return(n=n||{}).keepWsc=!0,f(r,n)}},dsf:u.std}},{"./hjson-common":1,"./hjson-dsf":2,"./hjson-parse":3,"./hjson-stringify":4,"./hjson-version":5}],7:[function(r,n,t){},{}]},{},[6])(6)}); | ||
"use strict";var t=n("./hjson-common"),o=n("./hjson-version"),i=n("./hjson-parse"),f=n("./hjson-stringify"),u=n("./hjson-comments"),a=n("./hjson-dsf");r.exports={parse:i,stringify:f,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,f(n,r)}},comments:u,dsf:a.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)}); |
# hjson-js History | ||
- v2.3.1 | ||
- add comments api (merge/extract) | ||
- v2.3.0 | ||
@@ -4,0 +6,0 @@ - improved comment round trip |
@@ -66,5 +66,45 @@ /* Hjson http://hjson.org */ | ||
function createComment(value, comment) { | ||
if (Object.defineProperty) Object.defineProperty(value, "__COMMENTS__", { enumerable: false, writable: true }); | ||
return (value.__COMMENTS__ = comment||{}); | ||
} | ||
function removeComment(value) { | ||
Object.defineProperty(value, "__COMMENTS__", { value: undefined }); | ||
} | ||
function getComment(value) { | ||
return value.__COMMENTS__; | ||
} | ||
function forceComment(text) { | ||
if (!text) return ""; | ||
var a = text.split('\n'); | ||
var str, i, j, len; | ||
for (j = 0; j < a.length; j++) { | ||
str = a[j]; | ||
len = str.length; | ||
for (i = 0; i < len; i++) { | ||
var c = str[i]; | ||
if (c === '#') break; | ||
else if (c === '/' && (str[i+1] === '/' || str[i+1] === '*')) { | ||
if (str[i+1] === '*') j = a.length; // assume /**/ covers whole block, bail out | ||
break; | ||
} | ||
else if (c > ' ') { | ||
a[j] = '# ' + str; | ||
break; | ||
} | ||
} | ||
} | ||
return a.join('\n'); | ||
} | ||
module.exports = { | ||
EOL: os.EOL || '\n', | ||
tryParseNumber: tryParseNumber, | ||
createComment: createComment, | ||
removeComment: removeComment, | ||
getComment: getComment, | ||
forceComment: forceComment, | ||
}; |
@@ -24,3 +24,3 @@ /* Hjson http://hjson.org */ | ||
var keepWsc; // keep whitespace | ||
var keepComments; | ||
var runDsf; // domain specific formats | ||
@@ -222,3 +222,3 @@ | ||
function getComment(cAt) { | ||
function getComment(cAt, first) { | ||
var i; | ||
@@ -236,4 +236,7 @@ cAt--; | ||
var j = res.indexOf('\n'); | ||
if (j >= 0) return [res.substr(0, j), res.substr(j+1)]; | ||
else return [res]; | ||
if (j >= 0) { | ||
var c = [res.substr(0, j), res.substr(j+1)]; | ||
if (first && c[0].trim().length === 0) c.shift(); | ||
return c; | ||
} else return [res]; | ||
} | ||
@@ -285,6 +288,3 @@ } | ||
try { | ||
if (keepWsc) { | ||
if (Object.defineProperty) Object.defineProperty(array, "__COMMENTS__", { enumerable: false, writable: true }); | ||
array.__COMMENTS__ = comments = []; | ||
} | ||
if (keepComments) comments = common.createComment(array, { a: [] }); | ||
@@ -294,6 +294,6 @@ next(); | ||
white(); | ||
if (comments) nextComment = getComment(cAt).join(''); | ||
if (comments) nextComment = getComment(cAt, true).join('\n'); | ||
if (ch === ']') { | ||
next(); | ||
if (comments) comments.push([nextComment]); | ||
if (comments) comments.e = [nextComment]; | ||
return array; // empty array | ||
@@ -311,3 +311,3 @@ } | ||
var c = getComment(cAt); | ||
comments.push([nextComment||"", c[0]||""]); | ||
comments.a.push([nextComment||"", c[0]||""]); | ||
nextComment = c[1]; | ||
@@ -317,3 +317,3 @@ } | ||
next(); | ||
if (comments) comments[comments.length-1][1] += nextComment||""; | ||
if (comments) comments.a[comments.a.length-1][1] += nextComment||""; | ||
return array; | ||
@@ -338,6 +338,3 @@ } | ||
try { | ||
if (keepWsc) { | ||
if (Object.defineProperty) Object.defineProperty(object, "__COMMENTS__", { enumerable: false, writable: true }); | ||
object.__COMMENTS__ = comments = { c: {}, o: [] }; | ||
} | ||
if (keepComments) comments = common.createComment(object, { c: {}, o: [] }); | ||
@@ -351,5 +348,5 @@ if (!withoutBraces) { | ||
white(); | ||
if (comments) nextComment = getComment(cAt).join(''); | ||
if (comments) nextComment = getComment(cAt, true).join('\n'); | ||
if (ch === '}' && !withoutBraces) { | ||
if (comments) comments.c[""] = [nextComment]; | ||
if (comments) comments.e = [nextComment]; | ||
next(); | ||
@@ -374,3 +371,3 @@ return object; // empty object | ||
nextComment = c[1]; | ||
if (key) comments.o.push(key); | ||
comments.o.push(key); | ||
} | ||
@@ -405,5 +402,13 @@ if (ch === '}' && !withoutBraces) { | ||
function checkTrailing(v) { | ||
function checkTrailing(v, c) { | ||
var cAt = at; | ||
white(); | ||
if (ch) error("Syntax error, found trailing characters"); | ||
if (keepComments) { | ||
var b = c.join('\n'), a = getComment(cAt).join('\n'); | ||
if (a || b) { | ||
var comments = common.createComment(v, common.getComment(v)); | ||
comments.r = [b, a]; | ||
} | ||
} | ||
return v; | ||
@@ -415,5 +420,6 @@ } | ||
white(); | ||
var c = keepComments ? getComment(1) : null; | ||
switch (ch) { | ||
case '{': return checkTrailing(object()); | ||
case '[': return checkTrailing(array()); | ||
case '{': return checkTrailing(object(), c); | ||
case '[': return checkTrailing(array(), c); | ||
} | ||
@@ -423,7 +429,7 @@ | ||
// assume we have a root object without braces | ||
return checkTrailing(object(true)); | ||
return checkTrailing(object(true), c); | ||
} catch (e) { | ||
// test if we are dealing with a single JSON value instead (true/false/null/num/"") | ||
resetAt(); | ||
try { return checkTrailing(value()); } | ||
try { return checkTrailing(value(), c); } | ||
catch (e2) { throw e; } // throw original error | ||
@@ -437,3 +443,3 @@ } | ||
if (opt && typeof opt === 'object') { | ||
keepWsc = opt.keepWsc; | ||
keepComments = opt.keepWsc; | ||
dsfDef = opt.dsf; | ||
@@ -440,0 +446,0 @@ } |
@@ -34,3 +34,3 @@ /* Hjson http://hjson.org */ | ||
// options | ||
var eol, keepWsc, bracesSameLine, quoteAlways; | ||
var eol, keepComments, bracesSameLine, quoteAlways; | ||
var token = { | ||
@@ -136,10 +136,6 @@ obj: [ '{', '}' ], | ||
if (!str) return ""; | ||
var i, s = -1, len = str.length; | ||
for (i = 0; i < len; i++) { | ||
var c = str[i]; | ||
if (c === '#' || c === '/' && (str[i+1] === '/' || str[i+1] === '*')) break; | ||
else if (c > ' ') { str = '# ' + str; break; } | ||
else s = i; // space | ||
} | ||
if (trim && s >= 0) str = str.substr(s + 1); | ||
str = common.forceComment(str); | ||
var i, len = str.length; | ||
for (i = 0; i < len && str[i] <= ' '; i++) {} | ||
if (trim && i > 0) str = str.substr(i); | ||
if (i < len) return prefix + wrap(token.rem, str); | ||
@@ -175,4 +171,4 @@ else return str; | ||
var comments, lastComment; // whitespace & comments | ||
if (keepWsc) comments = value.__COMMENTS__; | ||
var comments; // whitespace & comments | ||
if (keepComments) comments = common.getComment(value); | ||
@@ -199,8 +195,8 @@ var isArray = Object.prototype.toString.apply(value) === '[object Array]'; | ||
if (comments) { | ||
c = comments[i]||[]; | ||
ca = commentOnThisLine(c[1]) ? c[1] : ""; | ||
c = comments.a[i]||[]; | ||
ca = commentOnThisLine(c[1]); | ||
partial.push(makeComment(c[0], "\n") + eolGap); | ||
} | ||
partial.push(str(value[i], comments ? ca : false, true) || wrap(token.lit, 'null')); | ||
if (ca) partial.push(makeComment(ca, " ", true)); | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
} | ||
@@ -211,4 +207,3 @@ | ||
// when empty | ||
c = comments[0]; | ||
partial.push(makeComment(c[0], "\n") + eolMind); | ||
partial.push((comments.e ? makeComment(comments.e[0], "\n") : "") + eolMind); | ||
} | ||
@@ -237,3 +232,3 @@ else partial.push(eolMind); | ||
c = comments.c[k]||[]; | ||
ca = commentOnThisLine(c[1]) ? c[1] : ""; | ||
ca = commentOnThisLine(c[1]); | ||
partial.push(makeComment(c[0], "\n") + eolGap); | ||
@@ -243,8 +238,7 @@ | ||
if (v) partial.push(quoteKey(k) + token.col + (startsWithNL(v) ? '' : ' ') + v); | ||
if (ca) partial.push(makeComment(ca, " ", true)); | ||
if (comments && c[1]) partial.push(makeComment(c[1], ca ? " " : "\n", ca)); | ||
} | ||
if (length === 0) { | ||
// when empty | ||
c = comments.c[""]; | ||
partial.push(makeComment(c[0], "\n") + eolMind); | ||
partial.push((comments.e ? makeComment(comments.e[0], "\n") : "") + eolMind); | ||
} | ||
@@ -283,3 +277,3 @@ else partial.push(eolMind); | ||
indent = ' '; | ||
keepWsc = false; | ||
keepComments = false; | ||
bracesSameLine = false; | ||
@@ -291,3 +285,3 @@ quoteAlways = false; | ||
space = opt.space; | ||
keepWsc = opt.keepWsc; | ||
keepComments = opt.keepWsc; | ||
bracesSameLine = opt.bracesSameLine; | ||
@@ -329,4 +323,12 @@ quoteAlways = opt.quotes === 'always'; | ||
// Return the result of stringifying the value. | ||
return str(value, null, true, true); | ||
var res = ""; | ||
var comments = keepComments ? comments = (common.getComment(value) || {}).r : null; | ||
if (comments && comments[0]) res = comments[0] + '\n'; | ||
// get the result of stringifying the value. | ||
res += str(value, null, true, true); | ||
if (comments) res += comments[1]||""; | ||
return res; | ||
} | ||
@@ -333,0 +335,0 @@ |
@@ -1,1 +0,1 @@ | ||
module.exports="2.3.0"; | ||
module.exports="2.3.1"; |
/*! @preserve | ||
* Hjson v2.3.0 | ||
* Hjson v2.3.1 | ||
* http://hjson.org | ||
@@ -131,2 +131,3 @@ * | ||
var stringify = require("./hjson-stringify"); | ||
var comments = require("./hjson-comments"); | ||
var dsf = require("./hjson-dsf"); | ||
@@ -158,4 +159,6 @@ | ||
comments: comments, | ||
dsf: dsf.std, | ||
}; |
@@ -6,3 +6,3 @@ { | ||
"author": "Christian Zangl", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"keywords": [ | ||
@@ -9,0 +9,0 @@ "json", |
Sorry, the diff of this file is not supported yet
134469
2876