json-asty 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/json-asty.browser.js +1 -1
- package/package.json +7 -7
package/lib/json-asty.browser.js
CHANGED
|
@@ -49,6 +49,6 @@ const conversions=_dereq_("./conversions");function buildGraph(){const n={},e=Ob
|
|
|
49
49
|
},{}],11:[function(_dereq_,module,exports){
|
|
50
50
|
"use strict";module.exports={stdout:!1,stderr:!1};
|
|
51
51
|
},{}],12:[function(_dereq_,module,exports){
|
|
52
|
-
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_toPropertyKey(n.key),n)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}var ASTY=_dereq_("asty-astq"),PEGUtil=_dereq_("pegjs-util"),chalk=_dereq_("chalk"),PEGparser=function(){function t(e,r,n,o){var u=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(u,t.prototype),u.expected=r,u.found=n,u.location=o,u.name="SyntaxError",u}function e(t,e,r){return r=r||" ",t.length>e?t:(e-=t.length,t+(r+=r.repeat(e)).slice(0,e))}return function(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}(t,Error),t.prototype.format=function(t){var r="Error: "+this.message;if(this.location){var n,o=null;for(n=0;n<t.length;n++)if(t[n].source===this.location.source){o=t[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,l=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,a=this.location.source+":"+l.line+":"+l.column;if(o){var i=this.location.end,c=e("",l.line.toString().length," "),s=o[u.line-1],f=(u.line===i.line?i.column:s.length+1)-u.column||1;r+="\n --\x3e "+a+"\n"+c+" |\n"+l.line+" | "+s+"\n"+c+" | "+e("",u.column-1," ")+e("",f,"^")}else r+="\n at "+a}return r},t.buildMessage=function(t,e){var r={literal:function(t){return'"'+o(t.text)+'"'},class:function(t){var e=t.parts.map(function(t){return Array.isArray(t)?u(t[0])+"-"+u(t[1]):u(t)});return"["+(t.inverted?"^":"")+e.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function o(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+n(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+n(t)})}function u(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+n(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+n(t)})}function l(t){return r[t.type](t)}return"Expected "+function(t){var e,r,n=t.map(l);if(n.sort(),n.length>0){for(e=1,r=1;e<n.length;e++)n[e-1]!==n[e]&&(n[r]=n[e],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(t)+" but "+function(t){return t?'"'+o(t)+'"':"end of input"}(e)+" found."},{StartRules:["json"],SyntaxError:t,parse:function(e,r){var n,o={},u=(r=void 0!==r?r:{}).grammarSource,l={json:Vt},a=Vt,i="{",c=",",s="}",f=":",p="[",h="]",g="-",d="0",y=".",v='"',b="\\",A="b",m="f",C="n",x="r",w="t",E="u",S="null",P="false",k="true",j=/^[1-9]/,_=/^[0-9]/,F=/^[eE]/,O=/^[+\-]/,R=/^[^\0-\x1F"\\]/,$=/^["\/\\]/,T=/^[0-9a-f]/i,q=/^[ \t\n\r]/,G=Yt("{",!1),J=Yt(",",!1),N=Yt("}",!1),U=Yt(":",!1),M=Yt("[",!1),I=Yt("]",!1),K=Lt("number literal value"),Y=Yt("-",!1),D=Yt("0",!1),L=Dt([["1","9"]],!1,!1),z=Dt([["0","9"]],!1,!1),B=Yt(".",!1),H=Dt(["e","E"],!1,!1),Q=Dt(["+","-"],!1,!1),V=Lt("quoted string literal value"),W=Yt('"',!1),X=Dt([["\0",""],'"',"\\"],!0,!1),Z=Yt("\\",!1),tt=Dt(['"',"/","\\"],!1,!1),et=Yt("b",!1),rt=Yt("f",!1),nt=Yt("n",!1),ot=Yt("r",!1),ut=Yt("t",!1),lt=Yt("u",!1),at=Dt([["0","9"],["a","f"]],!1,!0),it=Lt("object null literal value"),ct=Yt("null",!1),st=Lt("boolean false literal value"),ft=Yt("false",!1),pt=Lt("boolean true literal value"),ht=Yt("true",!1),gt=Lt("whitespace"),dt=Dt([" ","\t","\n","\r"],!1,!1),yt=Lt("end of file"),vt={type:"any"},bt=function(t,e,r){return t&&e.set("prolog",t+(e.get("prolog")||"")),r&&e.set("epilog",(e.get("epilog")||"")+r),e},At=function(t,e,r){return r.reduce((t,e)=>{const r=t[t.length-1].get("epilog")||"";return t[t.length-1].set({epilog:r+e[0]}),t.concat([e[1]])},[e])},mt=function(t,e,r){return ee("object").set({prolog:t}).set({epilog:r}).add(e)},Ct=function(t,e,r){return ee("member").add(t.set({epilog:e}),r)},xt=function(t,e,r){return r.reduce((t,e)=>{const r=t[t.length-1].get("epilog")||"";return t[t.length-1].set({epilog:r+e[0]}),t.concat([e[1]])},[e])},wt=function(t,e,r){return ee("array").set({prolog:t}).set({epilog:r}).add(e)},Et=function(t,e,r){return ee("number").set({body:Kt(),value:parseFloat(Kt())})},St=function(){return"\b"},Pt=function(){return"\f"},kt=function(){return"\n"},jt=function(){return"\r"},_t=function(){return"\t"},Ft=function(t){return String.fromCharCode(parseInt(t,16))},Ot=function(t){return t},Rt=function(t){return ee("string").set({body:Kt(),value:t.join("")})},$t=function(){return ee("null").set({body:Kt(),value:null})},Tt=function(){return ee("boolean").set({body:Kt(),value:!1})},qt=function(){return ee("boolean").set({body:Kt(),value:!0})},Gt=0|r.peg$currPos,Jt=Gt,Nt=[{line:1,column:1}],Ut=Gt,Mt=r.peg$maxFailExpected||[],It=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');a=l[r.startRule]}function Kt(){return e.substring(Jt,Gt)}function Yt(t,e){return{type:"literal",text:t,ignoreCase:e}}function Dt(t,e,r){return{type:"class",parts:t,inverted:e,ignoreCase:r}}function Lt(t){return{type:"other",description:t}}function zt(t){var r,n=Nt[t];if(n)return n;if(t>=Nt.length)r=Nt.length-1;else for(r=t;!Nt[--r];);for(n={line:(n=Nt[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return Nt[t]=n,n}function Bt(t,e,r){var n=zt(t),o=zt(e),l={source:u,start:{offset:t,line:n.line,column:n.column},end:{offset:e,line:o.line,column:o.column}};return r&&u&&"function"==typeof u.offset&&(l.start=u.offset(l.start),l.end=u.offset(l.end)),l}function Ht(t){Gt<Ut||(Gt>Ut&&(Ut=Gt,Mt=[]),Mt.push(t))}function Qt(e,r,n){return new t(t.buildMessage(e,r),e,r,n)}function Vt(){var t,r,n,u;return t=Gt,(r=te())===o&&(r=null),(n=Wt())!==o?((u=te())===o&&(u=null),function(){var t,r;return It++,t=Gt,It++,e.length>Gt?(r=e.charAt(Gt),Gt++):(r=o,0===It&&Ht(vt)),It--,r===o?t=void 0:(Gt=t,t=o),It--,t===o&&(r=o,0===It&&Ht(yt)),t}()!==o?(Jt=t,t=bt(r,n,u)):(Gt=t,t=o)):(Gt=t,t=o),t}function Wt(){var t;return(t=function(){var t,r,n,u,l,a,f,p,h,g,d;if(t=Gt,r=Gt,n=Gt,(u=te())===o&&(u=null),123===e.charCodeAt(Gt)?(l=i,Gt++):(l=o,0===It&&Ht(G)),l!==o?((a=te())===o&&(a=null),n=u=[u,l,a]):(Gt=n,n=o),(r=n!==o?e.substring(r,Gt):n)!==o){if(n=Gt,(u=Xt())!==o){for(l=[],a=Gt,f=Gt,p=Gt,(h=te())===o&&(h=null),44===e.charCodeAt(Gt)?(g=c,Gt++):(g=o,0===It&&Ht(J)),g!==o?((d=te())===o&&(d=null),p=h=[h,g,d]):(Gt=p,p=o),(f=p!==o?e.substring(f,Gt):p)!==o&&(p=Xt())!==o?a=f=[f,p]:(Gt=a,a=o);a!==o;)l.push(a),a=Gt,f=Gt,p=Gt,(h=te())===o&&(h=null),44===e.charCodeAt(Gt)?(g=c,Gt++):(g=o,0===It&&Ht(J)),g!==o?((d=te())===o&&(d=null),p=h=[h,g,d]):(Gt=p,p=o),(f=p!==o?e.substring(f,Gt):p)!==o&&(p=Xt())!==o?a=f=[f,p]:(Gt=a,a=o);Jt=n,n=At(r,u,l)}else Gt=n,n=o;n===o&&(n=null),u=Gt,l=Gt,(a=te())===o&&(a=null),125===e.charCodeAt(Gt)?(f=s,Gt++):(f=o,0===It&&Ht(N)),f!==o?((p=te())===o&&(p=null),l=a=[a,f,p]):(Gt=l,l=o),(u=l!==o?e.substring(u,Gt):l)!==o?(Jt=t,t=mt(r,n,u)):(Gt=t,t=o)}else Gt=t,t=o;return t}())===o&&(t=function(){var t,r,n,u,l,a,i,s,f,g,d;if(t=Gt,r=Gt,n=Gt,(u=te())===o&&(u=null),91===e.charCodeAt(Gt)?(l=p,Gt++):(l=o,0===It&&Ht(M)),l!==o?((a=te())===o&&(a=null),n=u=[u,l,a]):(Gt=n,n=o),(r=n!==o?e.substring(r,Gt):n)!==o){if(n=Gt,(u=Wt())!==o){for(l=[],a=Gt,i=Gt,s=Gt,(f=te())===o&&(f=null),44===e.charCodeAt(Gt)?(g=c,Gt++):(g=o,0===It&&Ht(J)),g!==o?((d=te())===o&&(d=null),s=f=[f,g,d]):(Gt=s,s=o),(i=s!==o?e.substring(i,Gt):s)!==o&&(s=Wt())!==o?a=i=[i,s]:(Gt=a,a=o);a!==o;)l.push(a),a=Gt,i=Gt,s=Gt,(f=te())===o&&(f=null),44===e.charCodeAt(Gt)?(g=c,Gt++):(g=o,0===It&&Ht(J)),g!==o?((d=te())===o&&(d=null),s=f=[f,g,d]):(Gt=s,s=o),(i=s!==o?e.substring(i,Gt):s)!==o&&(s=Wt())!==o?a=i=[i,s]:(Gt=a,a=o);Jt=n,n=xt(r,u,l)}else Gt=n,n=o;n===o&&(n=null),u=Gt,l=Gt,(a=te())===o&&(a=null),93===e.charCodeAt(Gt)?(i=h,Gt++):(i=o,0===It&&Ht(I)),i!==o?((s=te())===o&&(s=null),l=a=[a,i,s]):(Gt=l,l=o),(u=l!==o?e.substring(u,Gt):l)!==o?(Jt=t,t=wt(r,n,u)):(Gt=t,t=o)}else Gt=t,t=o;return t}())===o&&(t=function(){var t,r,n,u,l,a,i,c,s;if(It++,t=Gt,45===e.charCodeAt(Gt)?(r=g,Gt++):(r=o,0===It&&Ht(Y)),r===o&&(r=null),48===e.charCodeAt(Gt)?(n=d,Gt++):(n=o,0===It&&Ht(D)),n===o)if(n=Gt,u=e.charAt(Gt),j.test(u)?Gt++:(u=o,0===It&&Ht(L)),u!==o){for(l=[],a=e.charAt(Gt),_.test(a)?Gt++:(a=o,0===It&&Ht(z));a!==o;)l.push(a),a=e.charAt(Gt),_.test(a)?Gt++:(a=o,0===It&&Ht(z));n=u=[u,l]}else Gt=n,n=o;if(n!==o){if(u=Gt,46===e.charCodeAt(Gt)?(l=y,Gt++):(l=o,0===It&&Ht(B)),l!==o){if(a=[],i=e.charAt(Gt),_.test(i)?Gt++:(i=o,0===It&&Ht(z)),i!==o)for(;i!==o;)a.push(i),i=e.charAt(Gt),_.test(i)?Gt++:(i=o,0===It&&Ht(z));else a=o;a!==o?u=l=[l,a]:(Gt=u,u=o)}else Gt=u,u=o;if(u===o&&(u=null),l=Gt,a=e.charAt(Gt),F.test(a)?Gt++:(a=o,0===It&&Ht(H)),a!==o){if(i=e.charAt(Gt),O.test(i)?Gt++:(i=o,0===It&&Ht(Q)),i===o&&(i=null),c=[],s=e.charAt(Gt),_.test(s)?Gt++:(s=o,0===It&&Ht(z)),s!==o)for(;s!==o;)c.push(s),s=e.charAt(Gt),_.test(s)?Gt++:(s=o,0===It&&Ht(z));else c=o;c!==o?l=a=[a,i,c]:(Gt=l,l=o)}else Gt=l,l=o;l===o&&(l=null),Jt=t,t=Et(n,u,l)}else Gt=t,t=o;return It--,t===o&&(r=o,0===It&&Ht(K)),t}())===o&&(t=Zt())===o&&(t=function(){var t,r;return It++,t=Gt,e.substr(Gt,4)===S?(r=S,Gt+=4):(r=o,0===It&&Ht(ct)),r!==o&&(Jt=t,r=$t()),It--,(t=r)===o&&(r=o,0===It&&Ht(it)),t}())===o&&(t=function(){var t,r;return It++,t=Gt,e.substr(Gt,5)===P?(r=P,Gt+=5):(r=o,0===It&&Ht(ft)),r!==o&&(Jt=t,r=Tt()),It--,(t=r)===o&&(r=o,0===It&&Ht(st)),t}())===o&&(t=function(){var t,r;return It++,t=Gt,e.substr(Gt,4)===k?(r=k,Gt+=4):(r=o,0===It&&Ht(ht)),r!==o&&(Jt=t,r=qt()),It--,(t=r)===o&&(r=o,0===It&&Ht(pt)),t}()),t}function Xt(){var t,r,n,u,l,a,i;return t=Gt,(r=Zt())!==o?(n=Gt,u=Gt,(l=te())===o&&(l=null),58===e.charCodeAt(Gt)?(a=f,Gt++):(a=o,0===It&&Ht(U)),a!==o?((i=te())===o&&(i=null),u=l=[l,a,i]):(Gt=u,u=o),(n=u!==o?e.substring(n,Gt):u)!==o&&(u=Wt())!==o?(Jt=t,t=Ct(r,n,u)):(Gt=t,t=o)):(Gt=t,t=o),t}function Zt(){var t,r,n,u,l,a,i,c,s,f,p,h,g;if(It++,t=Gt,34===e.charCodeAt(Gt)?(r=v,Gt++):(r=o,0===It&&Ht(W)),r!==o){for(n=[],u=e.charAt(Gt),R.test(u)?Gt++:(u=o,0===It&&Ht(X)),u===o&&(u=Gt,92===e.charCodeAt(Gt)?(l=b,Gt++):(l=o,0===It&&Ht(Z)),l!==o?(a=e.charAt(Gt),$.test(a)?Gt++:(a=o,0===It&&Ht(tt)),a===o&&(a=Gt,98===e.charCodeAt(Gt)?(i=A,Gt++):(i=o,0===It&&Ht(et)),i!==o&&(Jt=a,i=St()),(a=i)===o&&(a=Gt,102===e.charCodeAt(Gt)?(i=m,Gt++):(i=o,0===It&&Ht(rt)),i!==o&&(Jt=a,i=Pt()),(a=i)===o&&(a=Gt,110===e.charCodeAt(Gt)?(i=C,Gt++):(i=o,0===It&&Ht(nt)),i!==o&&(Jt=a,i=kt()),(a=i)===o&&(a=Gt,114===e.charCodeAt(Gt)?(i=x,Gt++):(i=o,0===It&&Ht(ot)),i!==o&&(Jt=a,i=jt()),(a=i)===o&&(a=Gt,116===e.charCodeAt(Gt)?(i=w,Gt++):(i=o,0===It&&Ht(ut)),i!==o&&(Jt=a,i=_t()),(a=i)===o&&(a=Gt,117===e.charCodeAt(Gt)?(i=E,Gt++):(i=o,0===It&&Ht(lt)),i!==o?(c=Gt,s=Gt,f=e.charAt(Gt),T.test(f)?Gt++:(f=o,0===It&&Ht(at)),f!==o?(p=e.charAt(Gt),T.test(p)?Gt++:(p=o,0===It&&Ht(at)),p!==o?(h=e.charAt(Gt),T.test(h)?Gt++:(h=o,0===It&&Ht(at)),h!==o?(g=e.charAt(Gt),T.test(g)?Gt++:(g=o,0===It&&Ht(at)),g!==o?s=f=[f,p,h,g]:(Gt=s,s=o)):(Gt=s,s=o)):(Gt=s,s=o)):(Gt=s,s=o),(c=s!==o?e.substring(c,Gt):s)!==o?(Jt=a,a=Ft(c)):(Gt=a,a=o)):(Gt=a,a=o))))))),a!==o?(Jt=u,u=Ot(a)):(Gt=u,u=o)):(Gt=u,u=o));u!==o;)n.push(u),u=e.charAt(Gt),R.test(u)?Gt++:(u=o,0===It&&Ht(X)),u===o&&(u=Gt,92===e.charCodeAt(Gt)?(l=b,Gt++):(l=o,0===It&&Ht(Z)),l!==o?(a=e.charAt(Gt),$.test(a)?Gt++:(a=o,0===It&&Ht(tt)),a===o&&(a=Gt,98===e.charCodeAt(Gt)?(i=A,Gt++):(i=o,0===It&&Ht(et)),i!==o&&(Jt=a,i=St()),(a=i)===o&&(a=Gt,102===e.charCodeAt(Gt)?(i=m,Gt++):(i=o,0===It&&Ht(rt)),i!==o&&(Jt=a,i=Pt()),(a=i)===o&&(a=Gt,110===e.charCodeAt(Gt)?(i=C,Gt++):(i=o,0===It&&Ht(nt)),i!==o&&(Jt=a,i=kt()),(a=i)===o&&(a=Gt,114===e.charCodeAt(Gt)?(i=x,Gt++):(i=o,0===It&&Ht(ot)),i!==o&&(Jt=a,i=jt()),(a=i)===o&&(a=Gt,116===e.charCodeAt(Gt)?(i=w,Gt++):(i=o,0===It&&Ht(ut)),i!==o&&(Jt=a,i=_t()),(a=i)===o&&(a=Gt,117===e.charCodeAt(Gt)?(i=E,Gt++):(i=o,0===It&&Ht(lt)),i!==o?(c=Gt,s=Gt,f=e.charAt(Gt),T.test(f)?Gt++:(f=o,0===It&&Ht(at)),f!==o?(p=e.charAt(Gt),T.test(p)?Gt++:(p=o,0===It&&Ht(at)),p!==o?(h=e.charAt(Gt),T.test(h)?Gt++:(h=o,0===It&&Ht(at)),h!==o?(g=e.charAt(Gt),T.test(g)?Gt++:(g=o,0===It&&Ht(at)),g!==o?s=f=[f,p,h,g]:(Gt=s,s=o)):(Gt=s,s=o)):(Gt=s,s=o)):(Gt=s,s=o),(c=s!==o?e.substring(c,Gt):s)!==o?(Jt=a,a=Ft(c)):(Gt=a,a=o)):(Gt=a,a=o))))))),a!==o?(Jt=u,u=Ot(a)):(Gt=u,u=o)):(Gt=u,u=o));34===e.charCodeAt(Gt)?(u=v,Gt++):(u=o,0===It&&Ht(W)),u!==o?(Jt=t,t=Rt(n)):(Gt=t,t=o)}else Gt=t,t=o;return It--,t===o&&(r=o,0===It&&Ht(V)),t}function te(){var t,r;if(It++,t=[],r=e.charAt(Gt),q.test(r)?Gt++:(r=o,0===It&&Ht(dt)),r!==o)for(;r!==o;)t.push(r),r=e.charAt(Gt),q.test(r)?Gt++:(r=o,0===It&&Ht(dt));else t=o;return It--,t===o&&(r=o,0===It&&Ht(gt)),t}var ee=r.util.makeAST(function(){return Bt(Jt,Gt)},r);if(n=a(),r.peg$library)return{peg$result:n,peg$currPos:Gt,peg$FAILED:o,peg$maxFailExpected:Mt,peg$maxFailPos:Ut};if(n!==o&&Gt===e.length)return n;throw n!==o&&Gt<e.length&&Ht({type:"end"}),Qt(Mt,Ut<e.length?e.charAt(Ut):null,Ut<e.length?Bt(Ut,Ut+1):Bt(Ut,Ut))}}}(),JsonAsty=function(){function t(){_classCallCheck(this,t)}return _createClass(t,null,[{key:"parse",value:function(t){if("string"!=typeof t)throw new Error("invalid JSON argument (expected type string)");var e=new ASTY,r=PEGUtil.parse(PEGparser,t,{startRule:"json",makeAST:function(t,r,n,o){return e.create.apply(e,o).pos(t,r,n)}});if(null!==r.error)throw new Error("parse: JSON parsing failure:\n"+PEGUtil.errorMessage(r.error,!0).replace(/^/gm,"ERROR: ")+"\n");return r.ast}},{key:"dump",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(e=Object.assign({},{colors:!1},e)).colors?t.dump(1/0,function(t,e){switch(t){case"tree":e=chalk.grey(e);break;case"type":e=chalk.blue(e);break;case"value":e=chalk.yellow(e);break;case"position":e=chalk.grey(e)}return e}):t.dump(1/0)}},{key:"unparse",value:function(t){if("object"!==_typeof(t))throw new Error("generate: invalid AST argument (expected type object)");var e="";return t.walk(function(t,r,n,o){if("downward"===o){var u=t.get("prolog");void 0!==u&&(e+=u);var l=t.get("body");if(void 0!==l)e+=l;else{var a=t.get("value");void 0!==a&&(e+=JSON.stringify(a))}}else if("upward"===o){var i=t.get("epilog");void 0!==i&&(e+=i)}},"both"),e}}]),t}();module.exports=JsonAsty;
|
|
52
|
+
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_toPropertyKey(n.key),n)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}var ASTY=_dereq_("asty-astq"),PEGUtil=_dereq_("pegjs-util"),chalk=_dereq_("chalk"),PEGparser=function(){function t(e,r,n,o){var u=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(u,t.prototype),u.expected=r,u.found=n,u.location=o,u.name="SyntaxError",u}function e(t,e,r){return r=r||" ",t.length>e?t:(e-=t.length,t+(r+=r.repeat(e)).slice(0,e))}return function(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}(t,Error),t.prototype.format=function(t){var r="Error: "+this.message;if(this.location){var n,o=null;for(n=0;n<t.length;n++)if(t[n].source===this.location.source){o=t[n].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,l=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(u):u,a=this.location.source+":"+l.line+":"+l.column;if(o){var i=this.location.end,c=e("",l.line.toString().length," "),s=o[u.line-1],f=(u.line===i.line?i.column:s.length+1)-u.column||1;r+="\n --\x3e "+a+"\n"+c+" |\n"+l.line+" | "+s+"\n"+c+" | "+e("",u.column-1," ")+e("",f,"^")}else r+="\n at "+a}return r},t.buildMessage=function(t,e){var r={literal:function(t){return'"'+o(t.text)+'"'},class:function(t){var e=t.parts.map(function(t){return Array.isArray(t)?u(t[0])+"-"+u(t[1]):u(t)});return"["+(t.inverted?"^":"")+e.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function o(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+n(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+n(t)})}function u(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+n(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+n(t)})}function l(t){return r[t.type](t)}return"Expected "+function(t){var e,r,n=t.map(l);if(n.sort(),n.length>0){for(e=1,r=1;e<n.length;e++)n[e-1]!==n[e]&&(n[r]=n[e],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(t)+" but "+function(t){return t?'"'+o(t)+'"':"end of input"}(e)+" found."},{StartRules:["json"],SyntaxError:t,parse:function(e,r){var n,o={},u=(r=void 0!==r?r:{}).grammarSource,l={json:Vt},a=Vt,i="{",c=",",s="}",f=":",p="[",h="]",g="-",d="0",y=".",v='"',b="\\",A="b",m="f",C="n",x="r",w="t",E="u",S="null",P="false",k="true",j=/^[1-9]/,_=/^[0-9]/,F=/^[eE]/,O=/^[+\-]/,R=/^[^\0-\x1F"\\]/,$=/^["\/\\]/,T=/^[0-9a-f]/i,q=/^[ \t\n\r]/,G=Yt("{",!1),J=Yt(",",!1),N=Yt("}",!1),U=Yt(":",!1),M=Yt("[",!1),I=Yt("]",!1),K=Lt("number literal value"),Y=Yt("-",!1),D=Yt("0",!1),L=Dt([["1","9"]],!1,!1),z=Dt([["0","9"]],!1,!1),B=Yt(".",!1),H=Dt(["e","E"],!1,!1),Q=Dt(["+","-"],!1,!1),V=Lt("quoted string literal value"),W=Yt('"',!1),X=Dt([["\0",""],'"',"\\"],!0,!1),Z=Yt("\\",!1),tt=Dt(['"',"/","\\"],!1,!1),et=Yt("b",!1),rt=Yt("f",!1),nt=Yt("n",!1),ot=Yt("r",!1),ut=Yt("t",!1),lt=Yt("u",!1),at=Dt([["0","9"],["a","f"]],!1,!0),it=Lt("object null literal value"),ct=Yt("null",!1),st=Lt("boolean false literal value"),ft=Yt("false",!1),pt=Lt("boolean true literal value"),ht=Yt("true",!1),gt=Lt("whitespace"),dt=Dt([" ","\t","\n","\r"],!1,!1),yt=Lt("end of file"),vt={type:"any"},bt=function(t,e,r){return t&&e.set("prolog",t+(e.get("prolog")||"")),r&&e.set("epilog",(e.get("epilog")||"")+r),e},At=function(t,e,r){return r.reduce((t,e)=>{const r=t[t.length-1].get("epilog")||"";return t[t.length-1].set({epilog:r+e[0]}),t.concat([e[1]])},[e])},mt=function(t,e,r){return ee("object").set({prolog:t}).set({epilog:r}).add(e)},Ct=function(t,e,r){return ee("member").add(t.set({epilog:e}),r)},xt=function(t,e,r){return r.reduce((t,e)=>{const r=t[t.length-1].get("epilog")||"";return t[t.length-1].set({epilog:r+e[0]}),t.concat([e[1]])},[e])},wt=function(t,e,r){return ee("array").set({prolog:t}).set({epilog:r}).add(e)},Et=function(t,e,r){return ee("number").set({body:Kt(),value:parseFloat(Kt())})},St=function(){return"\b"},Pt=function(){return"\f"},kt=function(){return"\n"},jt=function(){return"\r"},_t=function(){return"\t"},Ft=function(t){return String.fromCharCode(parseInt(t,16))},Ot=function(t){return t},Rt=function(t){return ee("string").set({body:Kt(),value:t.join("")})},$t=function(){return ee("null").set({body:Kt(),value:null})},Tt=function(){return ee("boolean").set({body:Kt(),value:!1})},qt=function(){return ee("boolean").set({body:Kt(),value:!0})},Gt=0|r.peg$currPos,Jt=Gt,Nt=[{line:1,column:1}],Ut=Gt,Mt=r.peg$maxFailExpected||[],It=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');a=l[r.startRule]}function Kt(){return e.substring(Jt,Gt)}function Yt(t,e){return{type:"literal",text:t,ignoreCase:e}}function Dt(t,e,r){return{type:"class",parts:t,inverted:e,ignoreCase:r}}function Lt(t){return{type:"other",description:t}}function zt(t){var r,n=Nt[t];if(n)return n;if(t>=Nt.length)r=Nt.length-1;else for(r=t;!Nt[--r];);for(n={line:(n=Nt[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return Nt[t]=n,n}function Bt(t,e,r){var n=zt(t),o=zt(e),l={source:u,start:{offset:t,line:n.line,column:n.column},end:{offset:e,line:o.line,column:o.column}};return r&&u&&"function"==typeof u.offset&&(l.start=u.offset(l.start),l.end=u.offset(l.end)),l}function Ht(t){Gt<Ut||(Gt>Ut&&(Ut=Gt,Mt=[]),Mt.push(t))}function Qt(e,r,n){return new t(t.buildMessage(e,r),e,r,n)}function Vt(){var t,r,n,u;return t=Gt,(r=te())===o&&(r=null),(n=Wt())!==o?((u=te())===o&&(u=null),function(){var t,r;return It++,t=Gt,It++,e.length>Gt?(r=e.charAt(Gt),Gt++):(r=o,0===It&&Ht(vt)),It--,r===o?t=void 0:(Gt=t,t=o),It--,t===o&&(r=o,0===It&&Ht(yt)),t}()!==o?(Jt=t,t=bt(r,n,u)):(Gt=t,t=o)):(Gt=t,t=o),t}function Wt(){var t;return(t=function(){var t,r,n,u,l,a,f,p,h,g,d;if(t=Gt,r=Gt,n=Gt,(u=te())===o&&(u=null),123===e.charCodeAt(Gt)?(l=i,Gt++):(l=o,0===It&&Ht(G)),l!==o?((a=te())===o&&(a=null),n=u=[u,l,a]):(Gt=n,n=o),(r=n!==o?e.substring(r,Gt):n)!==o){if(n=Gt,(u=Xt())!==o){for(l=[],a=Gt,f=Gt,p=Gt,(h=te())===o&&(h=null),44===e.charCodeAt(Gt)?(g=c,Gt++):(g=o,0===It&&Ht(J)),g!==o?((d=te())===o&&(d=null),p=h=[h,g,d]):(Gt=p,p=o),(f=p!==o?e.substring(f,Gt):p)!==o&&(p=Xt())!==o?a=f=[f,p]:(Gt=a,a=o);a!==o;)l.push(a),a=Gt,f=Gt,p=Gt,(h=te())===o&&(h=null),44===e.charCodeAt(Gt)?(g=c,Gt++):(g=o,0===It&&Ht(J)),g!==o?((d=te())===o&&(d=null),p=h=[h,g,d]):(Gt=p,p=o),(f=p!==o?e.substring(f,Gt):p)!==o&&(p=Xt())!==o?a=f=[f,p]:(Gt=a,a=o);Jt=n,n=At(r,u,l)}else Gt=n,n=o;n===o&&(n=null),u=Gt,l=Gt,(a=te())===o&&(a=null),125===e.charCodeAt(Gt)?(f=s,Gt++):(f=o,0===It&&Ht(N)),f!==o?((p=te())===o&&(p=null),l=a=[a,f,p]):(Gt=l,l=o),(u=l!==o?e.substring(u,Gt):l)!==o?(Jt=t,t=mt(r,n,u)):(Gt=t,t=o)}else Gt=t,t=o;return t}())===o&&(t=function(){var t,r,n,u,l,a,i,s,f,g,d;if(t=Gt,r=Gt,n=Gt,(u=te())===o&&(u=null),91===e.charCodeAt(Gt)?(l=p,Gt++):(l=o,0===It&&Ht(M)),l!==o?((a=te())===o&&(a=null),n=u=[u,l,a]):(Gt=n,n=o),(r=n!==o?e.substring(r,Gt):n)!==o){if(n=Gt,(u=Wt())!==o){for(l=[],a=Gt,i=Gt,s=Gt,(f=te())===o&&(f=null),44===e.charCodeAt(Gt)?(g=c,Gt++):(g=o,0===It&&Ht(J)),g!==o?((d=te())===o&&(d=null),s=f=[f,g,d]):(Gt=s,s=o),(i=s!==o?e.substring(i,Gt):s)!==o&&(s=Wt())!==o?a=i=[i,s]:(Gt=a,a=o);a!==o;)l.push(a),a=Gt,i=Gt,s=Gt,(f=te())===o&&(f=null),44===e.charCodeAt(Gt)?(g=c,Gt++):(g=o,0===It&&Ht(J)),g!==o?((d=te())===o&&(d=null),s=f=[f,g,d]):(Gt=s,s=o),(i=s!==o?e.substring(i,Gt):s)!==o&&(s=Wt())!==o?a=i=[i,s]:(Gt=a,a=o);Jt=n,n=xt(r,u,l)}else Gt=n,n=o;n===o&&(n=null),u=Gt,l=Gt,(a=te())===o&&(a=null),93===e.charCodeAt(Gt)?(i=h,Gt++):(i=o,0===It&&Ht(I)),i!==o?((s=te())===o&&(s=null),l=a=[a,i,s]):(Gt=l,l=o),(u=l!==o?e.substring(u,Gt):l)!==o?(Jt=t,t=wt(r,n,u)):(Gt=t,t=o)}else Gt=t,t=o;return t}())===o&&(t=function(){var t,r,n,u,l,a,i,c,s;if(It++,t=Gt,45===e.charCodeAt(Gt)?(r=g,Gt++):(r=o,0===It&&Ht(Y)),r===o&&(r=null),48===e.charCodeAt(Gt)?(n=d,Gt++):(n=o,0===It&&Ht(D)),n===o)if(n=Gt,u=e.charAt(Gt),j.test(u)?Gt++:(u=o,0===It&&Ht(L)),u!==o){for(l=[],a=e.charAt(Gt),_.test(a)?Gt++:(a=o,0===It&&Ht(z));a!==o;)l.push(a),a=e.charAt(Gt),_.test(a)?Gt++:(a=o,0===It&&Ht(z));n=u=[u,l]}else Gt=n,n=o;if(n!==o){if(u=Gt,46===e.charCodeAt(Gt)?(l=y,Gt++):(l=o,0===It&&Ht(B)),l!==o){if(a=[],i=e.charAt(Gt),_.test(i)?Gt++:(i=o,0===It&&Ht(z)),i!==o)for(;i!==o;)a.push(i),i=e.charAt(Gt),_.test(i)?Gt++:(i=o,0===It&&Ht(z));else a=o;a!==o?u=l=[l,a]:(Gt=u,u=o)}else Gt=u,u=o;if(u===o&&(u=null),l=Gt,a=e.charAt(Gt),F.test(a)?Gt++:(a=o,0===It&&Ht(H)),a!==o){if(i=e.charAt(Gt),O.test(i)?Gt++:(i=o,0===It&&Ht(Q)),i===o&&(i=null),c=[],s=e.charAt(Gt),_.test(s)?Gt++:(s=o,0===It&&Ht(z)),s!==o)for(;s!==o;)c.push(s),s=e.charAt(Gt),_.test(s)?Gt++:(s=o,0===It&&Ht(z));else c=o;c!==o?l=a=[a,i,c]:(Gt=l,l=o)}else Gt=l,l=o;l===o&&(l=null),Jt=t,t=Et(n,u,l)}else Gt=t,t=o;return It--,t===o&&(r=o,0===It&&Ht(K)),t}())===o&&(t=Zt())===o&&(t=function(){var t,r;return It++,t=Gt,e.substr(Gt,4)===S?(r=S,Gt+=4):(r=o,0===It&&Ht(ct)),r!==o&&(Jt=t,r=$t()),It--,(t=r)===o&&(r=o,0===It&&Ht(it)),t}())===o&&(t=function(){var t,r;return It++,t=Gt,e.substr(Gt,5)===P?(r=P,Gt+=5):(r=o,0===It&&Ht(ft)),r!==o&&(Jt=t,r=Tt()),It--,(t=r)===o&&(r=o,0===It&&Ht(st)),t}())===o&&(t=function(){var t,r;return It++,t=Gt,e.substr(Gt,4)===k?(r=k,Gt+=4):(r=o,0===It&&Ht(ht)),r!==o&&(Jt=t,r=qt()),It--,(t=r)===o&&(r=o,0===It&&Ht(pt)),t}()),t}function Xt(){var t,r,n,u,l,a,i;return t=Gt,(r=Zt())!==o?(n=Gt,u=Gt,(l=te())===o&&(l=null),58===e.charCodeAt(Gt)?(a=f,Gt++):(a=o,0===It&&Ht(U)),a!==o?((i=te())===o&&(i=null),u=l=[l,a,i]):(Gt=u,u=o),(n=u!==o?e.substring(n,Gt):u)!==o&&(u=Wt())!==o?(Jt=t,t=Ct(r,n,u)):(Gt=t,t=o)):(Gt=t,t=o),t}function Zt(){var t,r,n,u,l,a,i,c,s,f,p,h,g;if(It++,t=Gt,34===e.charCodeAt(Gt)?(r=v,Gt++):(r=o,0===It&&Ht(W)),r!==o){for(n=[],u=e.charAt(Gt),R.test(u)?Gt++:(u=o,0===It&&Ht(X)),u===o&&(u=Gt,92===e.charCodeAt(Gt)?(l=b,Gt++):(l=o,0===It&&Ht(Z)),l!==o?(a=e.charAt(Gt),$.test(a)?Gt++:(a=o,0===It&&Ht(tt)),a===o&&(a=Gt,98===e.charCodeAt(Gt)?(i=A,Gt++):(i=o,0===It&&Ht(et)),i!==o&&(Jt=a,i=St()),(a=i)===o&&(a=Gt,102===e.charCodeAt(Gt)?(i=m,Gt++):(i=o,0===It&&Ht(rt)),i!==o&&(Jt=a,i=Pt()),(a=i)===o&&(a=Gt,110===e.charCodeAt(Gt)?(i=C,Gt++):(i=o,0===It&&Ht(nt)),i!==o&&(Jt=a,i=kt()),(a=i)===o&&(a=Gt,114===e.charCodeAt(Gt)?(i=x,Gt++):(i=o,0===It&&Ht(ot)),i!==o&&(Jt=a,i=jt()),(a=i)===o&&(a=Gt,116===e.charCodeAt(Gt)?(i=w,Gt++):(i=o,0===It&&Ht(ut)),i!==o&&(Jt=a,i=_t()),(a=i)===o&&(a=Gt,117===e.charCodeAt(Gt)?(i=E,Gt++):(i=o,0===It&&Ht(lt)),i!==o?(c=Gt,s=Gt,f=e.charAt(Gt),T.test(f)?Gt++:(f=o,0===It&&Ht(at)),f!==o?(p=e.charAt(Gt),T.test(p)?Gt++:(p=o,0===It&&Ht(at)),p!==o?(h=e.charAt(Gt),T.test(h)?Gt++:(h=o,0===It&&Ht(at)),h!==o?(g=e.charAt(Gt),T.test(g)?Gt++:(g=o,0===It&&Ht(at)),g!==o?s=f=[f,p,h,g]:(Gt=s,s=o)):(Gt=s,s=o)):(Gt=s,s=o)):(Gt=s,s=o),(c=s!==o?e.substring(c,Gt):s)!==o?(Jt=a,a=Ft(c)):(Gt=a,a=o)):(Gt=a,a=o))))))),a!==o?(Jt=u,u=Ot(a)):(Gt=u,u=o)):(Gt=u,u=o));u!==o;)n.push(u),u=e.charAt(Gt),R.test(u)?Gt++:(u=o,0===It&&Ht(X)),u===o&&(u=Gt,92===e.charCodeAt(Gt)?(l=b,Gt++):(l=o,0===It&&Ht(Z)),l!==o?(a=e.charAt(Gt),$.test(a)?Gt++:(a=o,0===It&&Ht(tt)),a===o&&(a=Gt,98===e.charCodeAt(Gt)?(i=A,Gt++):(i=o,0===It&&Ht(et)),i!==o&&(Jt=a,i=St()),(a=i)===o&&(a=Gt,102===e.charCodeAt(Gt)?(i=m,Gt++):(i=o,0===It&&Ht(rt)),i!==o&&(Jt=a,i=Pt()),(a=i)===o&&(a=Gt,110===e.charCodeAt(Gt)?(i=C,Gt++):(i=o,0===It&&Ht(nt)),i!==o&&(Jt=a,i=kt()),(a=i)===o&&(a=Gt,114===e.charCodeAt(Gt)?(i=x,Gt++):(i=o,0===It&&Ht(ot)),i!==o&&(Jt=a,i=jt()),(a=i)===o&&(a=Gt,116===e.charCodeAt(Gt)?(i=w,Gt++):(i=o,0===It&&Ht(ut)),i!==o&&(Jt=a,i=_t()),(a=i)===o&&(a=Gt,117===e.charCodeAt(Gt)?(i=E,Gt++):(i=o,0===It&&Ht(lt)),i!==o?(c=Gt,s=Gt,f=e.charAt(Gt),T.test(f)?Gt++:(f=o,0===It&&Ht(at)),f!==o?(p=e.charAt(Gt),T.test(p)?Gt++:(p=o,0===It&&Ht(at)),p!==o?(h=e.charAt(Gt),T.test(h)?Gt++:(h=o,0===It&&Ht(at)),h!==o?(g=e.charAt(Gt),T.test(g)?Gt++:(g=o,0===It&&Ht(at)),g!==o?s=f=[f,p,h,g]:(Gt=s,s=o)):(Gt=s,s=o)):(Gt=s,s=o)):(Gt=s,s=o),(c=s!==o?e.substring(c,Gt):s)!==o?(Jt=a,a=Ft(c)):(Gt=a,a=o)):(Gt=a,a=o))))))),a!==o?(Jt=u,u=Ot(a)):(Gt=u,u=o)):(Gt=u,u=o));34===e.charCodeAt(Gt)?(u=v,Gt++):(u=o,0===It&&Ht(W)),u!==o?(Jt=t,t=Rt(n)):(Gt=t,t=o)}else Gt=t,t=o;return It--,t===o&&(r=o,0===It&&Ht(V)),t}function te(){var t,r;if(It++,t=[],r=e.charAt(Gt),q.test(r)?Gt++:(r=o,0===It&&Ht(dt)),r!==o)for(;r!==o;)t.push(r),r=e.charAt(Gt),q.test(r)?Gt++:(r=o,0===It&&Ht(dt));else t=o;return It--,t===o&&(r=o,0===It&&Ht(gt)),t}var ee=r.util.makeAST(function(){return Bt(Jt,Gt)},r);if(n=a(),r.peg$library)return{peg$result:n,peg$currPos:Gt,peg$FAILED:o,peg$maxFailExpected:Mt,peg$maxFailPos:Ut};if(n!==o&&Gt===e.length)return n;throw n!==o&&Gt<e.length&&Ht({type:"end"}),Qt(Mt,Ut<e.length?e.charAt(Ut):null,Ut<e.length?Bt(Ut,Ut+1):Bt(Ut,Ut))}}}(),JsonAsty=function(){return _createClass(function t(){_classCallCheck(this,t)},null,[{key:"parse",value:function(t){if("string"!=typeof t)throw new Error("invalid JSON argument (expected type string)");var e=new ASTY,r=PEGUtil.parse(PEGparser,t,{startRule:"json",makeAST:function(t,r,n,o){return e.create.apply(e,o).pos(t,r,n)}});if(null!==r.error)throw new Error("parse: JSON parsing failure:\n"+PEGUtil.errorMessage(r.error,!0).replace(/^/gm,"ERROR: ")+"\n");return r.ast}},{key:"dump",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(e=Object.assign({},{colors:!1},e)).colors?t.dump(1/0,function(t,e){switch(t){case"tree":e=chalk.grey(e);break;case"type":e=chalk.blue(e);break;case"value":e=chalk.yellow(e);break;case"position":e=chalk.grey(e)}return e}):t.dump(1/0)}},{key:"unparse",value:function(t){if("object"!==_typeof(t))throw new Error("generate: invalid AST argument (expected type object)");var e="";return t.walk(function(t,r,n,o){if("downward"===o){var u=t.get("prolog");void 0!==u&&(e+=u);var l=t.get("body");if(void 0!==l)e+=l;else{var a=t.get("value");void 0!==a&&(e+=JSON.stringify(a))}}else if("upward"===o){var i=t.get("epilog");void 0!==i&&(e+=i)}},"both"),e}}])}();module.exports=JsonAsty;
|
|
53
53
|
},{"asty-astq":2,"chalk":3,"pegjs-util":10}]},{},[12])(12)
|
|
54
54
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-asty",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Lossless JSON-to-AST Parser and AST-to-JSON Generator",
|
|
5
5
|
"keywords": [ "json", "ast", "parse", "generate" ],
|
|
6
6
|
"browser": "lib/json-asty.browser.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"pegjs-util": "2.0.1",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
27
|
"yargs": "17.7.2",
|
|
28
|
-
"cli-io": "0.9.
|
|
28
|
+
"cli-io": "0.9.12"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"grunt": "1.6.1",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"browserify-derequire": "1.1.1",
|
|
44
44
|
"eslint": "8.57.0",
|
|
45
45
|
"eslint-config-standard": "17.1.0",
|
|
46
|
-
"eslint-plugin-promise": "6.
|
|
46
|
+
"eslint-plugin-promise": "6.2.0",
|
|
47
47
|
"eslint-plugin-import": "2.29.1",
|
|
48
48
|
"eslint-plugin-node": "11.1.0",
|
|
49
|
-
"@babel/core": "7.24.
|
|
50
|
-
"@babel/preset-env": "7.24.
|
|
51
|
-
"@babel/plugin-transform-runtime": "7.24.
|
|
52
|
-
"mocha": "10.
|
|
49
|
+
"@babel/core": "7.24.7",
|
|
50
|
+
"@babel/preset-env": "7.24.7",
|
|
51
|
+
"@babel/plugin-transform-runtime": "7.24.7",
|
|
52
|
+
"mocha": "10.5.0",
|
|
53
53
|
"chai": "4.4.1"
|
|
54
54
|
},
|
|
55
55
|
"upd": [ "!chalk" ],
|