UNPKG

operator-overloading-nz-fork

Version:
245 lines (239 loc) 203 kB
!function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(i)return i(a,!0);throw new Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,n){(function(t,n,r,o,i,a,s,l,u){"use strict"; //The AST Walker And Transformer function c(e,t,n){switch(e.type){case"VariableDeclaration":e.declarations.forEach(function(e,t){c(e.init,t,n)});break;case"BinaryExpression":case"LogicalExpression":e.operator&&m[e.operator]?(e.type="CallExpression",e.callee={type:"MemberExpression",computed:!1,object:e.right,property:{type:"Identifier",name:m[e.operator]}},c(e.left,t,n),c(e.right,t,n),e.arguments=[e.left]):(c(e.left,t,n),c(e.right,t,n));break;case"ExpressionStatement":c(e.expression,t,n);break;case"CallExpression":e.arguments.forEach(function(e,t){c(e,t,n)});break;case"AssignmentExpression":if(e.operator&&m[e.operator]){var r=e.right;e.right={type:"BinaryExpression",operator:e.operator.replace(/=/,"").trim(),left:e.left,right:r},e.operator="=",c(e.left,t,n),c(e.right,t,n)}else c(e.right,t,n);break;case"UnaryExpression":e.operator&&m[e.operator]?(e.type="CallExpression",e.callee={type:"MemberExpression",computed:!1,object:e.argument,property:{type:"Identifier",name:"+"===e.operator||"-"===e.operator?m["u"+e.operator]:m[e.operator]}},c(e.argument,t,n),e.arguments=[]):c(e.argument,t,n);break;case"UpdateExpression":e.operator&&m[e.operator]&&(e.type="CallExpression",e.callee={type:"MemberExpression",computed:!1,object:e.argument,property:{type:"Identifier",name:m[e.operator]}},c(e.argument,t,n),e.arguments=[]);break; //We don't ned to transform following nodes! Phew! case"Literal":case"Identifier":case"BlockStatement":case"FunctionExpression":}}/* jshint ignore:start */ function f(e,t,n){Object.defineProperty(e.prototype,t,{enumerable:!1,writable:!0,configurable:!1,value:n})}var p=e("esprima"),d=e("escodegen"),m={"+":"__plus","==":"__doubleEqual","===":"__tripleEqual","||":"__logicalOR","&&":"__logicalAND","|":"__bitwiseOR","^":"__bitwiseXOR","&":"__bitwiseAND","!=":"__notEqual","!==":"__notDoubleEqual","<":"__lessThan",">":"__greaterThan","<=":"__lessThanEqual",">=":"__greaterThanEqual","in":"__in","instanceof":"__instanceOf","<<":"__bitwiseLSHIFT",">>":"__bitwiseRSHIFT",">>>":"__zeroFillRSHIFT","-":"__minus","*":"__multiply","%":"__modulus","/":"__divide","u-":"__unaryNegation","u+":"__unaryAddition","~":"__bitwiseNOT","++":"__increment","--":"__decrement","!":"__unaryNOT","+=":"__addAssign","-=":"__minusAssign","*=":"__multiplyAssign","/=":"__divideAssign","%=":"__modulusAssign","<<=":"__leftShiftAssign",">>=":"__rightShiftAssign",">>>=":"__zeroFillRightShiftAssign","&=":"__andAssign","|=":"__orAssign","^=":"__xorAssign"}; //Do the magic Function.prototype.enableOverloading=function(){ //Generate AST var e=p.parse("var fn = "+this); //Check for AST if(!e)throw new Error("Invalid code block! Cannot overload. AST Generation Error."); //Fetch arguments var t=e.body[0].declarations[0].init.params.reduce(function(e,t){return e.push(t.name),e},[]),n=e.body[0].declarations[0].init.body,r={type:"Program",body:n.body}; //Transform r.body.forEach(function(e,t){c(e,t,r)}), //Build new function args t.push(d.generate(r,{comment:!0,format:{indent:{style:" "}}}));var o=Function.apply(this,t);return console.log(JSON.stringify(r,null,4)),console.log(o.toString()),o}; //Load defaults var h=[Object,Number,String,Function,RegExp];h.forEach(function(e){f(e,m["+"],function(e){return e+this}),f(e,m["=="],function(e){return e==this}),f(e,m["==="],function(e){return e===this}),f(e,m["||"],function(e){return e||this}),f(e,m["&&"],function(e){return e&&this}),f(e,m["&"],function(e){return e&this}),f(e,m["|"],function(e){return e|this}),f(e,m["^"],function(e){return e^this}),f(e,m["!="],function(e){return e!=this}),f(e,m["!=="],function(e){return e!==this}),f(e,m["<"],function(e){return this>e}),f(e,m[">"],function(e){return e>this}),f(e,m[">>"],function(e){return e>>this}),f(e,m["<<"],function(e){return e<<this}),f(e,m[">>>"],function(e){return e>>>this}),f(e,m["<="],function(e){return this>=e}),f(e,m[">="],function(e){return e>=this}),f(e,m["in"],function(e){return e in this}),f(e,m["instanceof"],function(e){return e instanceof this}),f(e,m["-"],function(e){return e-this}),f(e,m["*"],function(e){return e*this}),f(e,m["%"],function(e){return e%this}),f(e,m["/"],function(e){return e/this}),f(e,m["u-"],function(){return-this}),f(e,m["u+"],function(){return+this}),f(e,m["~"],function(){return~this}),f(e,m["++"],function(){var e=this;return++e,e}),f(e,m["--"],function(){var e=this;return--e,e}),f(e,m["!"],function(){return!this}),f(e,m["+="],function(e){return e+=this}),f(e,m["-="],function(e){return e-=this}),f(e,m["*="],function(e){return e*=this}),f(e,m["/="],function(e){return e/=this}),f(e,m["%="],function(e){return e%=this}),f(e,m["<<="],function(e){return e<<=this}),f(e,m[">>="],function(e){return e>>=this}),f(e,m[">>>="],function(e){return e>>>=this}),f(e,m["&="],function(e){return e&=this}),f(e,m["|="],function(e){return e|=this}),f(e,m["^="],function(e){return e^=this})})}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_f4a727e3.js","/")},{"1YiZ5S":24,buffer:20,escodegen:2,esprima:19}],2:[function(e,t,n){(function(t,r,o,i,a,s,l,u,c){/* Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com> Copyright (C) 2012-2013 Michael Ficarra <escodegen.copyright@michael.ficarra.me> Copyright (C) 2012-2013 Mathias Bynens <mathias@qiwi.be> Copyright (C) 2013 Irakli Gozalishvili <rfobic@gmail.com> Copyright (C) 2012 Robert Gust-Bardon <donate@robert.gust-bardon.org> Copyright (C) 2012 John Freeman <jfreeman08@gmail.com> Copyright (C) 2011-2012 Ariya Hidayat <ariya.hidayat@gmail.com> Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl> Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com> Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*global exports:true, require:true, global:true*/ !function(){"use strict"; // Generation is done by generateExpression. function t(e){switch(e.type){case V.AssignmentExpression:case V.ArrayExpression:case V.ArrayPattern:case V.BinaryExpression:case V.CallExpression:case V.ConditionalExpression:case V.ClassExpression:case V.ExportBatchSpecifier:case V.ExportSpecifier:case V.FunctionExpression:case V.Identifier:case V.ImportSpecifier:case V.Literal:case V.LogicalExpression:case V.MemberExpression:case V.MethodDefinition:case V.NewExpression:case V.ObjectExpression:case V.ObjectPattern:case V.Property:case V.SequenceExpression:case V.ThisExpression:case V.UnaryExpression:case V.UpdateExpression:case V.YieldExpression:return!0}return!1} // Generation is done by generateStatement. function o(e){switch(e.type){case V.BlockStatement:case V.BreakStatement:case V.CatchClause:case V.ContinueStatement:case V.ClassDeclaration:case V.ClassBody:case V.DirectiveStatement:case V.DoWhileStatement:case V.DebuggerStatement:case V.EmptyStatement:case V.ExpressionStatement:case V.ForStatement:case V.ForInStatement:case V.ForOfStatement:case V.FunctionDeclaration:case V.IfStatement:case V.LabeledStatement:case V.ModuleDeclaration:case V.Program:case V.ReturnStatement:case V.SwitchStatement:case V.SwitchCase:case V.ThrowStatement:case V.TryStatement:case V.VariableDeclaration:case V.VariableDeclarator:case V.WhileStatement:case V.WithStatement:return!0}return!1}function i(){ // default options return{indent:null,base:null,parse:null,comment:!1,format:{indent:{style:" ",base:0,adjustMultilineComment:!1},newline:"\n",space:" ",json:!1,renumber:!1,hexadecimal:!1,quotes:"single",escapeless:!1,compact:!1,parentheses:!0,semicolons:!0,safeConcatenation:!1},moz:{comprehensionExpressionStartsWithAssignment:!1,starlessGenerator:!1},sourceMap:null,sourceMapRoot:null,sourceMapWithCode:!1,directive:!1,raw:!0,verbatim:null}}function a(e,t){var n="";for(t|=0;t>0;t>>>=1,e+=e)1&t&&(n+=e);return n}function s(e){return/[\r\n]/g.test(e)}function l(e){var t=e.length;return t&&X.code.isLineTerminator(e.charCodeAt(t-1))}function u(e,t){function n(e){return"object"==typeof e&&e instanceof Object&&!(e instanceof RegExp)}var r,o;for(r in t)t.hasOwnProperty(r)&&(o=t[r],n(o)?n(e[r])?u(e[r],o):e[r]=u({},o):e[r]=o);return e}function c(e){var t,n,r,o,i;if(e!==e)throw new Error("Numeric literal whose value is NaN");if(0>e||0===e&&0>1/e)throw new Error("Numeric literal whose value is negative");if(e===1/0)return ne?"null":re?"1e400":"1e+400";if(t=""+e,!re||t.length<3)return t;for(n=t.indexOf("."),ne||48!==t.charCodeAt(0)||1!==n||(n=0,t=t.slice(1)),r=t,t=t.replace("e+","e"),o=0,(i=r.indexOf("e"))>0&&(o=+r.slice(i+1),r=r.slice(0,i)),n>=0&&(o-=r.length-n-1,r=+(r.slice(0,n)+r.slice(n+1))+""),i=0;48===r.charCodeAt(r.length+i-1);)--i;return 0!==i&&(o-=i,r=r.slice(0,i)),0!==o&&(r+="e"+o),(r.length<t.length||oe&&e>1e12&&Math.floor(e)===e&&(r="0x"+e.toString(16)).length<t.length)&&+r===e&&(t=r),t} // Generate valid RegExp expression. // This function is based on https://github.com/Constellation/iv Engine function f(e,t){ // not handling '\' and handling \u2028 or \u2029 to unicode escape sequence // not handling '\' and handling \u2028 or \u2029 to unicode escape sequence return 8232===(-2&e)?(t?"u":"\\u")+(8232===e?"2028":"2029"):10===e||13===e?(t?"":"\\")+(10===e?"n":"r"):String.fromCharCode(e)}function p(e){var t,n,r,o,i,a,s,l;if(n=e.toString(),e.source){if( // extract flag from toString result t=n.match(/\/([^/]*)$/),!t)return n;for(r=t[1],n="",s=!1,l=!1,o=0,i=e.source.length;i>o;++o)a=e.source.charCodeAt(o),l?( // if new RegExp("\\\n') is provided, create /\n/ n+=f(a,l), // prevent like /\\[/]/ l=!1):(s?93===a&&(// ] s=!1):47===a?// / n+="\\":91===a&&(// [ s=!0),n+=f(a,l),l=92===a);return"/"+n+"/"+r}return n}function d(e,t){var n,r="\\";switch(e){case 8:r+="b";break;case 12:r+="f";break;case 9:r+="t";break;default:n=e.toString(16).toUpperCase(),r+=ne||e>255?"u"+"0000".slice(n.length)+n:0!==e||X.code.isDecimalDigit(t)?11===e?"x0B":"x"+"00".slice(n.length)+n:"0"}return r}function m(e){var t="\\";switch(e){case 92:t+="\\";break;case 10:t+="n";break;case 13:t+="r";break;case 8232:t+="u2028";break;case 8233:t+="u2029";break;default:throw new Error("Incorrectly classified character")}return t}function h(e){var t,n,r,o;for(o="double"===ie?'"':"'",t=0,n=e.length;n>t;++t){if(r=e.charCodeAt(t),39===r){o='"';break}if(34===r){o="'";break}92===r&&++t}return o+e+o}function g(e){var t,n,r,o,i,a="",s=0,l=0;for(t=0,n=e.length;n>t;++t){if(r=e.charCodeAt(t),39===r)++s;else if(34===r)++l;else if(47===r&&ne)a+="\\";else{if(X.code.isLineTerminator(r)||92===r){a+=m(r);continue}if(ne&&32>r||!(ne||ae||r>=32&&126>=r)){a+=d(r,e.charCodeAt(t+1));continue}}a+=String.fromCharCode(r)}if(o=!("double"===ie||"auto"===ie&&s>l),i=o?"'":'"',!(o?s:l))return i+a+i;for(e=a,a=i,t=0,n=e.length;n>t;++t)r=e.charCodeAt(t),(39===r&&o||34===r&&!o)&&(a+="\\"),a+=String.fromCharCode(r);return a+i}/** * flatten an array to a string, where the array can contain * either strings or nested arrays */ function y(e){var t,n,r,o="";for(t=0,n=e.length;n>t;++t)r=e[t],o+=Q(r)?y(r):r;return o}/** * convert generated to a SourceNode when source maps are enabled. */ function w(e,t){if(!he) // with no source maps, generated is either an // array or a string. if an array, flatten it. // if a string, just return it // with no source maps, generated is either an // array or a string. if an array, flatten it. // if a string, just return it return Q(e)?y(e):e;if(null==t){if(e instanceof $)return e;t={}}return null==t.loc?new $(null,null,he,e,t.name||null):new $(t.loc.start.line,t.loc.start.column,he===!0?t.loc.source||null:he,e,t.name||null)}function b(){return le?le:" "}function S(e,t){var n,r,o,i;return n=w(e).toString(),0===n.length?[t]:(r=w(t).toString(),0===r.length?[e]:(o=n.charCodeAt(n.length-1),i=r.charCodeAt(0),(43===o||45===o)&&o===i||X.code.isIdentifierPart(o)&&X.code.isIdentifierPart(i)||47===o&&105===i?[e,b(),t]:X.code.isWhiteSpace(o)||X.code.isLineTerminator(o)||X.code.isWhiteSpace(i)||X.code.isLineTerminator(i)?[e,t]:[e,le,t]))}function v(e){return[ee,e]}function E(e){var t,n;return t=ee,ee+=te,n=e.call(this,ee),ee=t,n}function C(e){var t;for(t=e.length-1;t>=0&&!X.code.isLineTerminator(e.charCodeAt(t));--t);return e.length-1-t}function x(e,t){var n,r,o,i,a,s,l,u; // first line doesn't have indentation for(n=e.split(/\r\n|[\r\n]/),s=Number.MAX_VALUE,r=1,o=n.length;o>r;++r){for(i=n[r],a=0;a<i.length&&X.code.isWhiteSpace(i.charCodeAt(a));)++a;s>a&&(s=a)}for("undefined"!=typeof t?( // pattern like // { // var t = 20; /* // * this is comment // */ // } l=ee,"*"===n[1][s]&&(t+=" "),ee=t):(1&s&& // /* // * // */ // If spaces are odd number, above pattern is considered. // We waste 1 space. --s,l=ee),r=1,o=n.length;o>r;++r)u=w(v(n[r].slice(s))),n[r]=he?u.join(""):u;return ee=l,n.join("\n")}function _(e,t){return"Line"===e.type?l(e.value)?"//"+e.value:"//"+e.value+"\n":de.format.indent.adjustMultilineComment&&/[\n\r]/.test(e.value)?x("/*"+e.value+"*/",t):"/*"+e.value+"*/"}function k(e,t){var n,r,o,i,s,u,c;if(e.leadingComments&&e.leadingComments.length>0){for(i=t,o=e.leadingComments[0],t=[],fe&&e.type===V.Program&&0===e.body.length&&t.push("\n"),t.push(_(o)),l(w(t).toString())||t.push("\n"),n=1,r=e.leadingComments.length;r>n;++n)o=e.leadingComments[n],c=[_(o)],l(w(c).toString())||c.push("\n"),t.push(v(c));t.push(v(i))}if(e.trailingComments)for(s=!l(w(t).toString()),u=a(" ",C(w([ee,t,te]).toString())),n=0,r=e.trailingComments.length;r>n;++n)o=e.trailingComments[n],s?( // We assume target like following script // // var t = 20; /** // * This is comment of t // */ // first case t=0===n?[t,te]:[t,u],t.push(_(o,u))):t=[t,v(_(o))],n===r-1||l(w(t).toString())||(t=[t,"\n"]);return t}function I(e,t,n){return n>t?["(",e,")"]:e}function A(e,t,n){var r,o;return o=!de.comment||!e.leadingComments,e.type===V.BlockStatement&&o?[le,G(e,{functionBody:n})]:e.type===V.EmptyStatement&&o?";":(E(function(){r=[se,v(G(e,{semicolonOptional:t,functionBody:n}))]}),r)}function L(e,t){var n=l(w(t).toString());return e.type!==V.BlockStatement||de.comment&&e.leadingComments||n?n?[t,ee]:[t,se,ee]:[t,le]}function B(e){var t,n,r;for(r=e.split(/\r\n|\n/),t=1,n=r.length;n>t;t++)r[t]=se+ee+r[t];return r}function D(e,t){var n,r,o; // verbatim is object return n=e[de.verbatim],"string"==typeof n?r=I(B(n),H.Sequence,t.precedence):(r=B(n.content),o=null!=n.precedence?n.precedence:H.Sequence,r=I(r,o,t.precedence)),w(r,e)}function O(e){return w(e.name,e)}function T(e,t){var n;return n=e.type===V.Identifier?O(e):W(e,{precedence:t.precedence,allowIn:t.allowIn,allowCall:!0})}function P(e){var t,n,r,o;if(o=!1,e.type!==V.ArrowFunctionExpression||e.rest||e.defaults&&0!==e.defaults.length||1!==e.params.length||e.params[0].type!==V.Identifier){for(r=["("],e.defaults&&(o=!0),t=0,n=e.params.length;n>t;++t) // Handle default values. r.push(o&&e.defaults[t]?q(e.params[t],e.defaults[t],"=",{precedence:H.Assignment,allowIn:!0,allowCall:!0}):T(e.params[t],{precedence:H.Assignment,allowIn:!0,allowCall:!0})),n>t+1&&r.push(","+le);e.rest&&(e.params.length&&r.push(","+le),r.push("..."),r.push(O(e.rest,{precedence:H.Assignment,allowIn:!0,allowCall:!0}))),r.push(")")}else // arg => { } case r=[O(e.params[0])];return r}function M(e){var t,n;return t=P(e),e.type===V.ArrowFunctionExpression&&(t.push(le),t.push("=>")),e.expression?(t.push(le),n=W(e.body,{precedence:H.Assignment,allowIn:!0,allowCall:!0}),"{"===n.toString().charAt(0)&&(n=["(",n,")"]),t.push(n)):t.push(A(e.body,!1,!0)),t}function R(e,t,n){var r=["for"+le+"("];return E(function(){t.left.type===V.VariableDeclaration?E(function(){r.push(t.left.kind+b()),r.push(G(t.left.declarations[0],{allowIn:!1}))}):r.push(W(t.left,{precedence:H.Call,allowIn:!0,allowCall:!0})),r=S(r,e),r=[S(r,W(t.right,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),")"]}),r.push(A(t.body,n)),r}function N(e,t,n){function r(){for(s=e.declarations[0],de.comment&&s.leadingComments?(o.push("\n"),o.push(v(G(s,{allowIn:n})))):(o.push(b()),o.push(G(s,{allowIn:n}))),i=1,a=e.declarations.length;a>i;++i)s=e.declarations[i],de.comment&&s.leadingComments?(o.push(","+se),o.push(v(G(s,{allowIn:n})))):(o.push(","+le),o.push(G(s,{allowIn:n})))}var o,i,a,s;return o=[e.kind],e.declarations.length>1?E(r):r(),o.push(t),o}function F(e){var t=["{",se];return E(function(n){var r,o;for(r=0,o=e.body.length;o>r;++r)t.push(n),t.push(W(e.body[r],{precedence:H.Sequence,allowIn:!0,allowCall:!0,type:V.Property})),o>r+1&&t.push(se)}),l(w(t).toString())||t.push(se),t.push(ee),t.push("}"),t}function U(e){var t;if(e.hasOwnProperty("raw")&&me&&de.raw)try{if(t=me(e.raw).body[0].expression,t.type===V.Literal&&t.value===e.value)return e.raw}catch(n){}return null===e.value?"null":"string"==typeof e.value?g(e.value):"number"==typeof e.value?c(e.value):"boolean"==typeof e.value?e.value?"true":"false":p(e.value)}function j(e,t,n){var r=[];return t&&r.push("["),r.push(W(e,n)),t&&r.push("]"),r}function q(e,t,n,r){var o,i;return i=r.precedence,o=r.allowIn||H.Assignment<i,I([W(e,{precedence:H.Call,allowIn:o,allowCall:!0}),le+n+le,W(t,{precedence:H.Assignment,allowIn:o,allowCall:!0})],H.Assignment,i)}function W(e,t){var n,r,o,i,a,u,c,f,p,d,m,h,g,y,v,C;if(r=t.precedence,h=t.allowIn,g=t.allowCall,o=e.type||t.type,de.verbatim&&e.hasOwnProperty(de.verbatim))return D(e,t);switch(o){case V.SequenceExpression:for(n=[],h|=H.Sequence<r,a=0,u=e.expressions.length;u>a;++a)n.push(W(e.expressions[a],{precedence:H.Assignment,allowIn:h,allowCall:!0})),u>a+1&&n.push(","+le);n=I(n,H.Sequence,r);break;case V.AssignmentExpression:n=q(e.left,e.right,e.operator,t);break;case V.ArrowFunctionExpression:h|=H.ArrowFunction<r,n=I(M(e),H.ArrowFunction,r);break;case V.ConditionalExpression:h|=H.Conditional<r,n=I([W(e.test,{precedence:H.LogicalOR,allowIn:h,allowCall:!0}),le+"?"+le,W(e.consequent,{precedence:H.Assignment,allowIn:h,allowCall:!0}),le+":"+le,W(e.alternate,{precedence:H.Assignment,allowIn:h,allowCall:!0})],H.Conditional,r);break;case V.LogicalExpression:case V.BinaryExpression:i=K[e.operator],h|=r>i,c=W(e.left,{precedence:i,allowIn:h,allowCall:!0}),d=c.toString(),n=47===d.charCodeAt(d.length-1)&&X.code.isIdentifierPart(e.operator.charCodeAt(0))?[c,b(),e.operator]:S(c,e.operator),c=W(e.right,{precedence:i+1,allowIn:h,allowCall:!0}),"/"===e.operator&&"/"===c.toString().charAt(0)||"<"===e.operator.slice(-1)&&"!--"===c.toString().slice(0,3)?( // If '/' concats with '/' or `<` concats with `!--`, it is interpreted as comment start n.push(b()),n.push(c)):n=S(n,c),n="in"!==e.operator||h?I(n,i,r):["(",n,")"];break;case V.CallExpression:for(n=[W(e.callee,{precedence:H.Call,allowIn:!0,allowCall:!0,allowUnparenthesizedNew:!1})],n.push("("),a=0,u=e.arguments.length;u>a;++a)n.push(W(e.arguments[a],{precedence:H.Assignment,allowIn:!0,allowCall:!0})),u>a+1&&n.push(","+le);n.push(")"),n=g?I(n,H.Call,r):["(",n,")"];break;case V.NewExpression:if(u=e.arguments.length,y=void 0===t.allowUnparenthesizedNew||t.allowUnparenthesizedNew,n=S("new",W(e.callee,{precedence:H.New,allowIn:!0,allowCall:!1,allowUnparenthesizedNew:y&&!ue&&0===u})),!y||ue||u>0){for(n.push("("),a=0;u>a;++a)n.push(W(e.arguments[a],{precedence:H.Assignment,allowIn:!0,allowCall:!0})),u>a+1&&n.push(","+le);n.push(")")}n=I(n,H.New,r);break;case V.MemberExpression:n=[W(e.object,{precedence:H.Call,allowIn:!0,allowCall:g,allowUnparenthesizedNew:!1})],e.computed?(n.push("["),n.push(W(e.property,{precedence:H.Sequence,allowIn:!0,allowCall:g})),n.push("]")):(e.object.type===V.Literal&&"number"==typeof e.object.value&&(c=w(n).toString(), // When the following conditions are all true, // 1. No floating point // 2. Don't have exponents // 3. The last character is a decimal digit // 4. Not hexadecimal OR octal number literal // we should add a floating point. c.indexOf(".")<0&&!/[eExX]/.test(c)&&X.code.isDecimalDigit(c.charCodeAt(c.length-1))&&!(c.length>=2&&48===c.charCodeAt(0))&&n.push(".")),n.push("."),n.push(O(e.property))),n=I(n,H.Member,r);break;case V.UnaryExpression:c=W(e.argument,{precedence:H.Unary,allowIn:!0,allowCall:!0}),""===le?n=S(e.operator,c):(n=[e.operator],e.operator.length>2? // delete, void, typeof // get `typeof []`, not `typeof[]` n=S(n,c):( // Prevent inserting spaces between operator and argument if it is unnecessary // like, `!cond` d=w(n).toString(),p=d.charCodeAt(d.length-1),m=c.toString().charCodeAt(0),(43===p||45===p)&&p===m||X.code.isIdentifierPart(p)&&X.code.isIdentifierPart(m)?(n.push(b()),n.push(c)):n.push(c))),n=I(n,H.Unary,r);break;case V.YieldExpression:n=e.delegate?"yield*":"yield",e.argument&&(n=S(n,W(e.argument,{precedence:H.Yield,allowIn:!0,allowCall:!0}))),n=I(n,H.Yield,r);break;case V.UpdateExpression:n=e.prefix?I([e.operator,W(e.argument,{precedence:H.Unary,allowIn:!0,allowCall:!0})],H.Unary,r):I([W(e.argument,{precedence:H.Postfix,allowIn:!0,allowCall:!0}),e.operator],H.Postfix,r);break;case V.FunctionExpression:C=e.generator&&!de.moz.starlessGenerator,n=C?"function*":"function",n=e.id?[n,C?le:b(),O(e.id),M(e)]:[n+le,M(e)];break;case V.ExportBatchSpecifier:n="*";break;case V.ArrayPattern:case V.ArrayExpression:if(!e.elements.length){n="[]";break}f=e.elements.length>1,n=["[",f?se:""],E(function(t){for(a=0,u=e.elements.length;u>a;++a)e.elements[a]?(n.push(f?t:""),n.push(W(e.elements[a],{precedence:H.Assignment,allowIn:!0,allowCall:!0}))):(f&&n.push(t),a+1===u&&n.push(",")),u>a+1&&n.push(","+(f?se:le))}),f&&!l(w(n).toString())&&n.push(se),n.push(f?ee:""),n.push("]");break;case V.ClassExpression:n=["class"],e.id&&(n=S(n,W(e.id,{allowIn:!0,allowCall:!0}))),e.superClass&&(c=S("extends",W(e.superClass,{precedence:H.Assignment,allowIn:!0,allowCall:!0})),n=S(n,c)),n.push(le),n.push(G(e.body,{semicolonOptional:!0,directiveContext:!1}));break;case V.MethodDefinition:n=e["static"]?["static"+le]:[],"get"===e.kind||"set"===e.kind?n=S(n,[S(e.kind,j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),M(e.value)]):(c=[j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),M(e.value)],e.value.generator?(n.push("*"),n.push(c)):n=S(n,c));break;case V.Property:"get"===e.kind||"set"===e.kind?n=[e.kind,b(),j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),M(e.value)]:e.shorthand?n=j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0}):e.method?(n=[],e.value.generator&&n.push("*"),n.push(j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),n.push(M(e.value))):n=[j(e.key,e.computed,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),":"+le,W(e.value,{precedence:H.Assignment,allowIn:!0,allowCall:!0})];break;case V.ObjectExpression:if(!e.properties.length){n="{}";break}if(f=e.properties.length>1,E(function(){c=W(e.properties[0],{precedence:H.Sequence,allowIn:!0,allowCall:!0,type:V.Property})}),!f&&!s(w(c).toString())){n=["{",le,c,le,"}"];break}E(function(t){if(n=["{",se,t,c],f)for(n.push(","+se),a=1,u=e.properties.length;u>a;++a)n.push(t),n.push(W(e.properties[a],{precedence:H.Sequence,allowIn:!0,allowCall:!0,type:V.Property})),u>a+1&&n.push(","+se)}),l(w(n).toString())||n.push(se),n.push(ee),n.push("}");break;case V.ObjectPattern:if(!e.properties.length){n="{}";break}if(f=!1,1===e.properties.length)v=e.properties[0],v.value.type!==V.Identifier&&(f=!0);else for(a=0,u=e.properties.length;u>a;++a)if(v=e.properties[a],!v.shorthand){f=!0;break}n=["{",f?se:""],E(function(t){for(a=0,u=e.properties.length;u>a;++a)n.push(f?t:""),n.push(W(e.properties[a],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),u>a+1&&n.push(","+(f?se:le))}),f&&!l(w(n).toString())&&n.push(se),n.push(f?ee:""),n.push("}");break;case V.ThisExpression:n="this";break;case V.Identifier:n=O(e);break;case V.ImportSpecifier:case V.ExportSpecifier:n=[e.id.name],e.name&&n.push(b()+"as"+b()+e.name.name);break;case V.Literal:n=U(e);break;case V.GeneratorExpression:case V.ComprehensionExpression: // GeneratorExpression should be parenthesized with (...), ComprehensionExpression with [...] // Due to https://bugzilla.mozilla.org/show_bug.cgi?id=883468 position of expr.body can differ in Spidermonkey and ES6 n=o===V.GeneratorExpression?["("]:["["],de.moz.comprehensionExpressionStartsWithAssignment&&(c=W(e.body,{precedence:H.Assignment,allowIn:!0,allowCall:!0}),n.push(c)),e.blocks&&E(function(){for(a=0,u=e.blocks.length;u>a;++a)c=W(e.blocks[a],{precedence:H.Sequence,allowIn:!0,allowCall:!0}),a>0||de.moz.comprehensionExpressionStartsWithAssignment?n=S(n,c):n.push(c)}),e.filter&&(n=S(n,"if"+le),c=W(e.filter,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),n=S(n,["(",c,")"])),de.moz.comprehensionExpressionStartsWithAssignment||(c=W(e.body,{precedence:H.Assignment,allowIn:!0,allowCall:!0}),n=S(n,c)),n.push(o===V.GeneratorExpression?")":"]");break;case V.ComprehensionBlock:c=e.left.type===V.VariableDeclaration?[e.left.kind,b(),G(e.left.declarations[0],{allowIn:!1})]:W(e.left,{precedence:H.Call,allowIn:!0,allowCall:!0}),c=S(c,e.of?"of":"in"),c=S(c,W(e.right,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),n=["for"+le+"(",c,")"];break;case V.SpreadElement:n=["...",W(e.argument,{precedence:H.Assignment,allowIn:!0,allowCall:!0})];break;case V.TaggedTemplateExpression:n=[W(e.tag,{precedence:H.Call,allowIn:!0,allowCall:g,allowUnparenthesizedNew:!1}),W(e.quasi,{precedence:H.Primary})],n=I(n,H.TaggedTemplate,r);break;case V.TemplateElement: // Don't use "cooked". Since tagged template can use raw template // representation. So if we do so, it breaks the script semantics. n=e.value.raw;break;case V.TemplateLiteral:for(n=["`"],a=0,u=e.quasis.length;u>a;++a)n.push(W(e.quasis[a],{precedence:H.Primary,allowIn:!0,allowCall:!0})),u>a+1&&(n.push("${"+le),n.push(W(e.expressions[a],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),n.push(le+"}"));n.push("`");break;default:throw new Error("Unknown expression type: "+e.type)}return de.comment&&(n=k(e,n)),w(n,e)} // ES6: 15.2.1 valid import declarations: // - import ImportClause FromClause ; // - import ModuleSpecifier ; function Y(e,t){var n,r; // If no ImportClause is present, // this should be `import ModuleSpecifier` so skip `from` // ModuleSpecifier is StringLiteral. // If no ImportClause is present, // this should be `import ModuleSpecifier` so skip `from` // ModuleSpecifier is StringLiteral. // import ImportClause FromClause ; // ImportedBinding // NamedImports // import { ... } from "..."; // import { // ..., // ..., // } from "..."; return 0===e.specifiers.length?["import",le,U(e.source),t]:(n=["import"],r=0,e.specifiers[0]["default"]&&(n=S(n,[e.specifiers[0].id.name]),++r),e.specifiers[r]&&(0!==r&&n.push(","),n.push(le+"{"),e.specifiers.length-r===1?(n.push(le),n.push(W(e.specifiers[r],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),n.push(le+"}"+le)):(E(function(t){var o,i;for(n.push(se),o=r,i=e.specifiers.length;i>o;++o)n.push(t),n.push(W(e.specifiers[o],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),i>o+1&&n.push(","+se)}),l(w(n).toString())||n.push(se),n.push(ee+"}"+le))),n=S(n,["from"+le,U(e.source),t]))}function G(e,t){var n,r,o,i,a,s,u,c,f,p;switch(i=!0,c=";",a=!1,s=!1,t&&(i=void 0===t.allowIn||t.allowIn,ce||t.semicolonOptional!==!0||(c=""),a=t.functionBody,s=t.directiveContext),e.type){case V.BlockStatement:o=["{",se],E(function(){for(n=0,r=e.body.length;r>n;++n)u=v(G(e.body[n],{semicolonOptional:n===r-1,directiveContext:a})),o.push(u),l(w(u).toString())||o.push(se)}),o.push(v("}"));break;case V.BreakStatement:o=e.label?"break "+e.label.name+c:"break"+c;break;case V.ContinueStatement:o=e.label?"continue "+e.label.name+c:"continue"+c;break;case V.ClassBody:o=F(e);break;case V.ClassDeclaration:o=["class "+e.id.name],e.superClass&&(u=S("extends",W(e.superClass,{precedence:H.Assignment,allowIn:!0,allowCall:!0})),o=S(o,u)),o.push(le),o.push(G(e.body,{semicolonOptional:!0,directiveContext:!1}));break;case V.DirectiveStatement:o=de.raw&&e.raw?e.raw+c:h(e.directive)+c;break;case V.DoWhileStatement: // Because `do 42 while (cond)` is Syntax Error. We need semicolon. o=S("do",A(e.body)),o=L(e.body,o),o=S(o,["while"+le+"(",W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"+c]);break;case V.CatchClause:E(function(){var t;o=["catch"+le+"(",W(e.param,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"],e.guard&&(t=W(e.guard,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),o.splice(2,0," if ",t))}),o.push(A(e.body));break;case V.DebuggerStatement:o="debugger"+c;break;case V.EmptyStatement:o=";";break;case V.ExportDeclaration: // export default AssignmentExpression[In] ; if(o=["export"],e["default"]){o=S(o,"default"),o=S(o,W(e.declaration,{precedence:H.Assignment,allowIn:!0,allowCall:!0})+c);break} // export * FromClause ; // export ExportClause[NoReference] FromClause ; // export ExportClause ; if(e.specifiers){0===e.specifiers.length?o=S(o,"{"+le+"}"):e.specifiers[0].type===V.ExportBatchSpecifier?o=S(o,W(e.specifiers[0],{precedence:H.Sequence,allowIn:!0,allowCall:!0})):(o=S(o,"{"),E(function(t){var n,r;for(o.push(se),n=0,r=e.specifiers.length;r>n;++n)o.push(t),o.push(W(e.specifiers[n],{precedence:H.Sequence,allowIn:!0,allowCall:!0})),r>n+1&&o.push(","+se)}),l(w(o).toString())||o.push(se),o.push(ee+"}")),e.source?o=S(o,["from"+le,U(e.source),c]):o.push(c);break} // export VariableStatement // export Declaration[Default] e.declaration&&(o=S(o,G(e.declaration,{semicolonOptional:""===c})));break;case V.ExpressionStatement:o=[W(e.expression,{precedence:H.Sequence,allowIn:!0,allowCall:!0})], // 12.4 '{', 'function', 'class' is not allowed in this position. // wrap expression with parentheses u=w(o).toString(),"{"===u.charAt(0)||// ObjectExpression "class"===u.slice(0,5)&&" {".indexOf(u.charAt(5))>=0||// class "function"===u.slice(0,8)&&"* (".indexOf(u.charAt(8))>=0||// function or generator pe&&s&&e.expression.type===V.Literal&&"string"==typeof e.expression.value?o=["(",o,")"+c]:o.push(c);break;case V.ImportDeclaration:o=Y(e,c);break;case V.VariableDeclarator:o=e.init?[W(e.id,{precedence:H.Assignment,allowIn:i,allowCall:!0}),le,"=",le,W(e.init,{precedence:H.Assignment,allowIn:i,allowCall:!0})]:T(e.id,{precedence:H.Assignment,allowIn:i});break;case V.VariableDeclaration: // VariableDeclarator is typed as Statement, // but joined with comma (not LineTerminator). // So if comment is attached to target node, we should specialize. o=N(e,c,i);break;case V.ThrowStatement:o=[S("throw",W(e.argument,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),c];break;case V.TryStatement:if(o=["try",A(e.block)],o=L(e.block,o),e.handlers) // old interface for(n=0,r=e.handlers.length;r>n;++n)o=S(o,G(e.handlers[n])),(e.finalizer||n+1!==r)&&(o=L(e.handlers[n].body,o));else{for(p=e.guardedHandlers||[],n=0,r=p.length;r>n;++n)o=S(o,G(p[n])),(e.finalizer||n+1!==r)&&(o=L(p[n].body,o)); // new interface if(e.handler)if(Q(e.handler))for(n=0,r=e.handler.length;r>n;++n)o=S(o,G(e.handler[n])),(e.finalizer||n+1!==r)&&(o=L(e.handler[n].body,o));else o=S(o,G(e.handler)),e.finalizer&&(o=L(e.handler.body,o))}e.finalizer&&(o=S(o,["finally",A(e.finalizer)]));break;case V.SwitchStatement:if(E(function(){o=["switch"+le+"(",W(e.discriminant,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"+le+"{"+se]}),e.cases)for(n=0,r=e.cases.length;r>n;++n)u=v(G(e.cases[n],{semicolonOptional:n===r-1})),o.push(u),l(w(u).toString())||o.push(se);o.push(v("}"));break;case V.SwitchCase:E(function(){for(o=e.test?[S("case",W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),":"]:["default:"],n=0,r=e.consequent.length,r&&e.consequent[0].type===V.BlockStatement&&(u=A(e.consequent[0]),o.push(u),n=1),n===r||l(w(o).toString())||o.push(se);r>n;++n)u=v(G(e.consequent[n],{semicolonOptional:n===r-1&&""===c})),o.push(u),n+1===r||l(w(u).toString())||o.push(se)});break;case V.IfStatement:E(function(){o=["if"+le+"(",W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"]}),e.alternate?(o.push(A(e.consequent)),o=L(e.consequent,o),o=e.alternate.type===V.IfStatement?S(o,["else ",G(e.alternate,{semicolonOptional:""===c})]):S(o,S("else",A(e.alternate,""===c)))):o.push(A(e.consequent,""===c));break;case V.ForStatement:E(function(){o=["for"+le+"("],e.init?e.init.type===V.VariableDeclaration?o.push(G(e.init,{allowIn:!1})):(o.push(W(e.init,{precedence:H.Sequence,allowIn:!1,allowCall:!0})),o.push(";")):o.push(";"),e.test?(o.push(le),o.push(W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),o.push(";")):o.push(";"),e.update?(o.push(le),o.push(W(e.update,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),o.push(")")):o.push(")")}),o.push(A(e.body,""===c));break;case V.ForInStatement:o=R("in",e,""===c);break;case V.ForOfStatement:o=R("of",e,""===c);break;case V.LabeledStatement:o=[e.label.name+":",A(e.body,""===c)];break;case V.ModuleDeclaration:o=["module",b(),e.id.name,b(),"from",le,U(e.source),c];break;case V.Program:for(r=e.body.length,o=[fe&&r>0?"\n":""],n=0;r>n;++n)u=v(G(e.body[n],{semicolonOptional:!fe&&n===r-1,directiveContext:!0})),o.push(u),r>n+1&&!l(w(u).toString())&&o.push(se);break;case V.FunctionDeclaration:f=e.generator&&!de.moz.starlessGenerator,o=[f?"function*":"function",f?le:b(),O(e.id),M(e)];break;case V.ReturnStatement:o=e.argument?[S("return",W(e.argument,{precedence:H.Sequence,allowIn:!0,allowCall:!0})),c]:["return"+c];break;case V.WhileStatement:E(function(){o=["while"+le+"(",W(e.test,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"]}),o.push(A(e.body,""===c));break;case V.WithStatement:E(function(){o=["with"+le+"(",W(e.object,{precedence:H.Sequence,allowIn:!0,allowCall:!0}),")"]}),o.push(A(e.body,""===c));break;default:throw new Error("Unknown statement type: "+e.type)} // Attach comments return de.comment&&(o=k(e,o)),u=w(o).toString(),e.type!==V.Program||fe||""!==se||"\n"!==u.charAt(u.length-1)||(o=he?w(o).replaceRight(/\s+$/,""):u.replace(/\s+$/,"")),w(o,e)}function Z(e){if(o(e))return G(e);if(t(e))return W(e,{precedence:H.Sequence,allowIn:!0,allowCall:!0});throw new Error("Unknown node type: "+e.type)}function z(t,o){var s,l,c=i(); // Obsolete options // // `options.indent` // `options.base` // // Instead of them, we can use `option.format.indent`. return null!=o?("string"==typeof o.indent&&(c.format.indent.style=o.indent),"number"==typeof o.base&&(c.format.indent.base=o.base),o=u(c,o),te=o.format.indent.style,ee="string"==typeof o.base?o.base:a(te,o.format.indent.base)):(o=c,te=o.format.indent.style,ee=a(te,o.format.indent.base)),ne=o.format.json,re=o.format.renumber,oe=ne?!1:o.format.hexadecimal,ie=ne?"double":o.format.quotes,ae=o.format.escapeless,se=o.format.newline,le=o.format.space,o.format.compact&&(se=le=te=ee=""),ue=o.format.parentheses,ce=o.format.semicolons,fe=o.format.safeConcatenation,pe=o.directive,me=ne?null:o.parse,he=o.sourceMap,de=o,he&&($=n.browser?r.sourceMap.SourceNode:e("source-map").SourceNode),s=Z(t),he?(l=s.toStringWithSourceMap({file:o.file,sourceRoot:o.sourceMapRoot}),o.sourceContent&&l.map.setSourceContent(o.sourceMap,o.sourceContent),o.sourceMapWithCode?l:l.map.toString()):(l={code:s.toString(),map:null},o.sourceMapWithCode?l:l.code)}var V,H,K,$,J,X,Q,ee,te,ne,re,oe,ie,ae,se,le,ue,ce,fe,pe,de,me,he,ge,ye;J=e("estraverse"),X=e("esutils"),V={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExportBatchSpecifier:"ExportBatchSpecifier",ExportDeclaration:"ExportDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportSpecifier:"ImportSpecifier",ImportDeclaration:"ImportDeclaration",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ModuleDeclaration:"ModuleDeclaration",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},H={Sequence:0,Yield:1,Assignment:1,Conditional:2,ArrowFunction:2,LogicalOR:3,LogicalAND:4,BitwiseOR:5,BitwiseXOR:6,BitwiseAND:7,Equality:8,Relational:9,BitwiseSHIFT:10,Additive:11,Multiplicative:12,Unary:13,Postfix:14,Call:15,New:16,TaggedTemplate:17,Member:18,Primary:19},K={"||":H.LogicalOR,"&&":H.LogicalAND,"|":H.BitwiseOR,"^":H.BitwiseXOR,"&":H.BitwiseAND,"==":H.Equality,"!=":H.Equality,"===":H.Equality,"!==":H.Equality,is:H.Equality,isnt:H.Equality,"<":H.Relational,">":H.Relational,"<=":H.Relational,">=":H.Relational,"in":H.Relational,"instanceof":H.Relational,"<<":H.BitwiseSHIFT,">>":H.BitwiseSHIFT,">>>":H.BitwiseSHIFT,"+":H.Additive,"-":H.Additive,"*":H.Multiplicative,"%":H.Multiplicative,"/":H.Multiplicative},Q=Array.isArray,Q||(Q=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),ge={indent:{style:"",base:0},renumber:!0,hexadecimal:!0,quotes:"auto",escapeless:!0,compact:!0,parentheses:!1,semicolons:!1},ye=i().format,n.version=e("./package.json").version,n.generate=z,n.attachComments=J.attachComments,n.Precedence=u({},H),n.browser=!1,n.FORMAT_MINIFY=ge,n.FORMAT_DEFAULTS=ye}()}).call(this,e("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/../node_modules/escodegen/escodegen.js","/../node_modules/escodegen")},{"./package.json":18,"1YiZ5S":24,buffer:20,estraverse:3,esutils:7,"source-map":8}],3:[function(e,t,n){(function(e,t,r,o,i,a,s,l,u){/* Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com> Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*jslint vars:false, bitwise:true*/ /*jshint indent:4*/ /*global exports:true, define:true*/ !function(e,t){"use strict"; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, // and plain browser loading, "function"==typeof define&&define.amd?define(["exports"],t):t("undefined"!=typeof n?n:e.estraverse={})}(this,function(e){"use strict";function t(){}function n(e){var t,r,o={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],o[t]="object"==typeof r&&null!==r?n(r):r);return o}function r(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n} // based on LLVM libc++ upper_bound / lower_bound // MIT License function o(e,t){var n,r,o,i;for(r=e.length,o=0;r;)n=r>>>1,i=o+n,t(e[i])?r=n:(o=i+1,r-=n+1);return o}function i(e,t){var n,r,o,i;for(r=e.length,o=0;r;)n=r>>>1,i=o+n,t(e[i])?(o=i+1,r-=n+1):r=n;return o}function a(e,t){return v(t).forEach(function(n){e[n]=t[n]}),e}function s(e,t){this.parent=e,this.key=t}function l(e,t,n,r){this.node=e,this.path=t,this.wrap=n,this.ref=r}function u(){}function c(e){return null==e?!1:"object"==typeof e&&"string"==typeof e.type}function f(e,t){return(e===g.ObjectExpression||e===g.ObjectPattern)&&"properties"===t}function p(e,t){var n=new u;return n.traverse(e,t)}function d(e,t){var n=new u;return n.replace(e,t)}function m(e,t){var n;return n=o(t,function(t){return t.range[0]>e.range[0]}),e.extendedRange=[e.range[0],e.range[1]],n!==t.length&&(e.extendedRange[1]=t[n].range[0]),n-=1,n>=0&&(e.extendedRange[0]=t[n].range[1]),e}function h(e,t,r){ // At first, we should calculate extended comment ranges. var o,i,a,s,l=[];if(!e.range)throw new Error("attachComments needs range information"); // tokens array is empty, we attach comments to tree as 'leadingComments' if(!r.length){if(t.length){for(a=0,i=t.length;i>a;a+=1)o=n(t[a]),o.extendedRange=[0,e.range[0]],l.push(o);e.leadingComments=l}return e}for(a=0,i=t.length;i>a;a+=1)l.push(m(n(t[a]),r)); // This is based on John Freeman's implementation. return s=0,p(e,{enter:function(e){for(var t;s<l.length&&(t=l[s],!(t.extendedRange[1]>e.range[0]));)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),l.splice(s,1)):s+=1; // already out of owned node // already out of owned node return s===l.length?w.Break:l[s].extendedRange[0]>e.range[1]?w.Skip:void 0}}),s=0,p(e,{leave:function(e){for(var t;s<l.length&&(t=l[s],!(e.range[1]<t.extendedRange[0]));)e.range[1]===t.extendedRange[0]?(e.trailingComments||(e.trailingComments=[]),e.trailingComments.push(t),l.splice(s,1)):s+=1; // already out of owned node // already out of owned node return s===l.length?w.Break:l[s].extendedRange[0]>e.range[1]?w.Skip:void 0}}),e}var g,y,w,b,S,v,E,C,x;y=Array.isArray,y||(y=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),t(r),t(i),S=Object.create||function(){function e(){}return function(t){return e.prototype=t,new e}}(),v=Object.keys||function(e){var t,n=[];for(t in e)n.push(t);return n},g={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",// CAUTION: It's deferred to ES7. ComprehensionExpression:"ComprehensionExpression",// CAUTION: It's deferred to ES7. ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportBatchSpecifier:"ExportBatchSpecifier",ExportDeclaration:"ExportDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",// CAUTION: It's deferred to ES7. Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},b={AssignmentExpression:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","defaults","rest","body"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","body","superClass"],ClassExpression:["id","body","superClass"],ComprehensionBlock:["left","right"],// CAUTION: It's deferred to ES7. ComprehensionExpression:["blocks","filter","body"],// CAUTION: It's deferred to ES7. ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportBatchSpecifier:[],ExportDeclaration:["declaration","specifiers","source"],ExportSpecifier:["id","name"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","defaults","rest","body"],FunctionExpression:["id","params","defaults","rest","body"],GeneratorExpression:["blocks","filter","body"],// CAUTION: It's deferred to ES7. Identifier:[],IfStatement:["test","consequent","alternate"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["id"],ImportNamespaceSpecifier:["id"],ImportSpecifier:["id","name"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handlers","handler","guardedHandlers","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]}, // unique id E={},C={},x={},w={Break:E,Skip:C,Remove:x},s.prototype.replace=function(e){this.parent[this.key]=e},s.prototype.remove=function(){return y(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)}, // API: // return property path array from root to curr