New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js2coffee

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js2coffee - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

.idea/.name

5

HISTORY.md
# History
v0.2.1 - October 14, 2013
--------------------
- Replace option parser with nopt
- add CLI option for indent [issue #143](https://github.com/rstacruz/js2coffee/issues/143)
v0.2.0 - September 26, 2013

@@ -4,0 +9,0 @@ --------------------

2

out/lib/browser.js
"undefined"==typeof module&&(this.Narcissus=new Object);var Narcissus={options:{version:185},hostGlobal:this};Narcissus.definitions=function(){function t(t,e,n,r,i){Object.defineProperty(t,e,{get:n,configurable:!r,enumerable:!i})}function e(t,e,n,r,i,o){Object.defineProperty(t,e,{value:n,writable:!i,configurable:!r,enumerable:!o})}function n(t){return"function"==typeof t&&t.toString().match(/\[native code\]/)}function r(t,e){for(;t;){if({}.hasOwnProperty.call(t,e))return Object.getOwnPropertyDescriptor(t,e);t=Object.getPrototypeOf(t)}}function i(t){var e={};for(var n in Object.getOwnPropertyNames(t))e[n]=Object.getOwnPropertyDescriptor(t,n);return e}function o(t){return{getOwnPropertyDescriptor:function(e){var n=Object.getOwnPropertyDescriptor(t,e);return n.configurable=!0,n},getPropertyDescriptor:function(e){var n=r(t,e);return n.configurable=!0,n},getOwnPropertyNames:function(){return Object.getOwnPropertyNames(t)},defineProperty:function(e,n){Object.defineProperty(t,e,n)},"delete":function(e){return delete t[e]},fix:function(){return Object.isFrozen(t)?i(t):void 0},has:function(e){return e in t},hasOwn:function(e){return{}.hasOwnProperty.call(t,e)},get:function(e,n){return t[n]},set:function(e,n,r){return t[n]=r,!0},enumerate:function(){var e=[];for(N in t)e.push(N);return e},keys:function(){return Object.keys(t)}}}function s(){return void 0}function a(){this.table=Object.create(null,{}),this.size=0}function u(t){this.elts=t||null}for(var c=["END","\n",";",",","=","?",":","CONDITIONAL","||","&&","|","^","&","==","!=","===","!==","<","<=",">=",">","<<",">>",">>>","+","-","*","/","%","!","~","UNARY_PLUS","UNARY_MINUS","++","--",".","[","]","{","}","(",")","SCRIPT","BLOCK","LABEL","FOR_IN","CALL","NEW_WITH_ARGS","INDEX","ARRAY_INIT","OBJECT_INIT","PROPERTY_INIT","GETTER","SETTER","GROUP","LIST","LET_BLOCK","ARRAY_COMP","GENERATOR","COMP_TAIL","IDENTIFIER","NUMBER","STRING","REGEXP","break","case","catch","const","continue","debugger","default","delete","do","else","false","finally","for","function","if","in","instanceof","let","new","null","return","switch","this","throw","true","try","typeof","var","void","yield","while","with"],h=["break","const","continue","debugger","do","for","if","return","switch","throw","try","var","yield","while","with"],l={"\n":"NEWLINE",";":"SEMICOLON",",":"COMMA","?":"HOOK",":":"COLON","||":"OR","&&":"AND","|":"BITWISE_OR","^":"BITWISE_XOR","&":"BITWISE_AND","===":"STRICT_EQ","==":"EQ","=":"ASSIGN","!==":"STRICT_NE","!=":"NE","<<":"LSH","<=":"LE","<":"LT",">>>":"URSH",">>":"RSH",">=":"GE",">":"GT","++":"INCREMENT","--":"DECREMENT","+":"PLUS","-":"MINUS","*":"MUL","/":"DIV","%":"MOD","!":"NOT","~":"BITWISE_NOT",".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_CURLY","}":"RIGHT_CURLY","(":"LEFT_PAREN",")":"RIGHT_PAREN"},p={__proto__:null},d={},f="const ",E=0,y=c.length;y>E;E++){E>0&&(f+=", ");var N,m=c[E];/^[a-z]/.test(m)?(N=m.toUpperCase(),p[m]=E):N=/^\W/.test(m)?l[m]:m,f+=N+" = "+E,d[N]=E,c[m]=E}f+=";";var g={__proto__:null};for(E=0,y=h.length;y>E;E++)g[p[h[E]]]=!0;var I=["|","^","&","<<",">>",">>>","+","-","*","/","%"];for(E=0,y=I.length;y>E;E++)m=I[E],I[m]=c[m];var T={}.hasOwnProperty;return a.prototype={has:function(t){return T.call(this.table,t)},set:function(t,e){T.call(this.table,t)||this.size++,this.table[t]=e},get:function(t){return this.table[t]},getDef:function(t,e){return T.call(this.table,t)||(this.size++,this.table[t]=e()),this.table[t]},forEach:function(t){var e=this.table;for(var n in e)t.call(this,n,e[n])},toString:function(){return"[object StringMap]"}},u.prototype={push:function(t){return new u({top:t,rest:this.elts})},top:function(){if(!this.elts)throw new Error("empty stack");return this.elts.top},isEmpty:function(){return null===this.top},find:function(t){for(var e=this.elts;e;e=e.rest)if(t(e.top))return e.top;return null},has:function(t){return Boolean(this.find(function(e){return e===t}))},forEach:function(t){for(var e=this.elts;e;e=e.rest)t(e.top)}},{tokens:c,opTypeNames:l,keywords:p,isStatementStartCode:g,tokenIds:d,consts:f,assignOps:I,defineGetter:t,defineProperty:e,isNativeCode:n,makePassthruHandler:o,noPropFound:s,StringMap:a,Stack:u}}(),Narcissus.lexer=function(){function Tokenizer(t,e,n){this.cursor=0,this.source=String(t),this.tokens=[],this.tokenIndex=0,this.lookahead=0,this.scanNewlines=!1,this.unexpectedEOF=!1,this.filename=e||"",this.lineno=n||1,this.comments=[]}var definitions=Narcissus.definitions;eval(definitions.consts);var opTokens={};for(var op in definitions.opTypeNames)if("\n"!==op&&"."!==op)for(var node=opTokens,i=0;i<op.length;i++){var ch=op[i];ch in node||(node[ch]={}),node=node[ch],node.op=op}return Tokenizer.prototype={get done(){return this.peek(!0)===END},get token(){return this.tokens[this.tokenIndex]},match:function(t,e){return this.get(e)===t||this.unget()},mustMatch:function(t){if(!this.match(t))throw this.newSyntaxError("Missing "+definitions.tokens[t].toLowerCase());return this.token},peek:function(t){var e,n;return this.lookahead?(n=this.tokens[3&this.tokenIndex+this.lookahead],e=this.scanNewlines&&n.lineno!==this.lineno?NEWLINE:n.type):(e=this.get(t),this.unget()),e},peekOnSameLine:function(t){this.scanNewlines=!0;var e=this.peek(t);return this.scanNewlines=!1,e},skip:function(){for(var t,e,n,r=this.source,i=0;;){var o=r[this.cursor++],s=r[this.cursor];if("\n"!==o||this.scanNewlines){if("/"===o&&"*"===s)for(t=this.cursor,e=this.lineno,this.cursor++;;){if(o=r[this.cursor++],void 0===o)throw this.newSyntaxError("Unterminated comment");if("*"===o){if(s=r[this.cursor],"/"===s){this.cursor++,n={type:"BLOCK_COMMENT",nlcount:i,start:t-1,end:this.cursor,lineno:e,endlineno:this.lineno,value:r.substring(t+1,this.cursor-2)},this.comments.push(n),i=0;break}}else"\n"===o&&this.lineno++}else if("/"===o&&"/"===s)for(t=this.cursor,this.cursor++;;){if(o=r[this.cursor++],void 0===o)return n={type:"LINE_COMMENT",start:t,end:this.cursor,lineno:this.lineno,nlcount:i,value:r.substring(t+1,this.cursor-1)},this.comments.push(n),void 0;if("\n"===o){n={type:"LINE_COMMENT",start:t,end:this.cursor,lineno:this.lineno,nlcount:i,value:r.substring(t+1,this.cursor-1)},this.comments.push(n),i=0,this.lineno++;break}}else if(" "!==o&&" "!==o)return this.cursor--,void 0}else this.lineno++,i++}},lexExponent:function(){var t=this.source,e=t[this.cursor];if("e"===e||"E"===e){if(this.cursor++,ch=t[this.cursor++],("+"===ch||"-"===ch)&&(ch=t[this.cursor++]),"0">ch||ch>"9")throw this.newSyntaxError("Missing exponent");do ch=t[this.cursor++];while(ch>="0"&&"9">=ch);return this.cursor--,!0}return!1},lexZeroNumber:function(t){var e=this.token,n=this.source;if(e.type=NUMBER,t=n[this.cursor++],"."===t){do t=n[this.cursor++];while(t>="0"&&"9">=t);this.cursor--,this.lexExponent(),e.value=parseFloat(e.start,this.cursor)}else if("x"===t||"X"===t){do t=n[this.cursor++];while(t>="0"&&"9">=t||t>="a"&&"f">=t||t>="A"&&"F">=t);this.cursor--,e.value=parseInt(n.substring(e.start,this.cursor))}else if(t>="0"&&"7">=t){do t=n[this.cursor++];while(t>="0"&&"7">=t);this.cursor--,e.value=parseInt(n.substring(e.start,this.cursor))}else this.cursor--,this.lexExponent(),e.value=0},lexNumber:function(t){var e=this.token,n=this.source;e.type=NUMBER;var r=!1;do t=n[this.cursor++],"."!==t||r||(r=!0,t=n[this.cursor++]);while(t>="0"&&"9">=t);this.cursor--;var i=this.lexExponent();r=r||i;var o=n.substring(e.start,this.cursor);e.value=r?parseFloat(o):parseInt(o)},lexDot:function(t){var e=this.token,n=this.source,r=n[this.cursor];if(r>="0"&&"9">=r){do t=n[this.cursor++];while(t>="0"&&"9">=t);this.cursor--,this.lexExponent(),e.type=NUMBER,e.value=parseFloat(e.start,this.cursor)}else e.type=DOT,e.assignOp=null,e.value="."},lexString:function(ch){var token=this.token,input=this.source;token.type=STRING;for(var hasEscapes=!1,delim=ch;(ch=input[this.cursor++])!==delim;){if(this.cursor>=input.length)throw this.newSyntaxError("Unterminated string literal");if("\\"===ch&&(hasEscapes=!0,++this.cursor==input.length))throw this.newSyntaxError("Unterminated string literal")}token.value=hasEscapes?eval(input.substring(token.start,this.cursor)):input.substring(token.start+1,this.cursor-1)},lexRegExp:function(ch){var token=this.token,input=this.source;token.type=REGEXP;do if(ch=input[this.cursor++],"\\"===ch)this.cursor++;else if("["===ch){do{if(void 0===ch)throw this.newSyntaxError("Unterminated character class");"\\"===ch&&this.cursor++,ch=input[this.cursor++]}while("]"!==ch)}else if(void 0===ch)throw this.newSyntaxError("Unterminated regex");while("/"!==ch);do ch=input[this.cursor++];while(ch>="a"&&"z">=ch);this.cursor--,token.value=eval(input.substring(token.start,this.cursor))},lexOp:function(t){var e=this.token,n=this.source,r=opTokens[t],i=n[this.cursor];i in r&&(r=r[i],this.cursor++,i=n[this.cursor],i in r&&(r=r[i],this.cursor++,i=n[this.cursor]));var o=r.op;definitions.assignOps[o]&&"="===n[this.cursor]?(this.cursor++,e.type=ASSIGN,e.assignOp=definitions.tokenIds[definitions.opTypeNames[o]],o+="="):(e.type=definitions.tokenIds[definitions.opTypeNames[o]],e.assignOp=null),e.value=o},lexIdent:function(t){var e=this.token,n=this.source;do t=n[this.cursor++];while(t>="a"&&"z">=t||t>="A"&&"Z">=t||t>="0"&&"9">=t||"$"===t||"_"===t);this.cursor--;var r=n.substring(e.start,this.cursor);e.type=definitions.keywords[r]||IDENTIFIER,e.value=r},get:function(t){for(var e;this.lookahead;)if(--this.lookahead,this.tokenIndex=3&this.tokenIndex+1,e=this.tokens[this.tokenIndex],e.type!==NEWLINE||this.scanNewlines)return e.type;this.skip(),this.tokenIndex=3&this.tokenIndex+1,e=this.tokens[this.tokenIndex],e||(this.tokens[this.tokenIndex]=e={});var n=this.source;if(this.cursor===n.length)return e.type=END;e.start=this.cursor,e.lineno=this.lineno;var r=n[this.cursor++];if(r>="a"&&"z">=r||r>="A"&&"Z">=r||"$"===r||"_"===r)this.lexIdent(r);else if(t&&"/"===r)this.lexRegExp(r);else if(r in opTokens)this.lexOp(r);else if("."===r)this.lexDot(r);else if(r>="1"&&"9">=r)this.lexNumber(r);else if("0"===r)this.lexZeroNumber(r);else if('"'===r||"'"===r)this.lexString(r);else{if(!this.scanNewlines||"\n"!==r)throw this.newSyntaxError("Illegal token");e.type=NEWLINE,e.value="\n",this.lineno++}return e.end=this.cursor,e.type},unget:function(){if(4===++this.lookahead)throw"PANIC: too much lookahead!";this.tokenIndex=3&this.tokenIndex-1},newSyntaxError:function(t){var e=new SyntaxError(t,this.filename,this.lineno);return e.source=this.source,e.cursor=this.lookahead?this.tokens[3&this.tokenIndex+this.lookahead].start:this.cursor,e}},{Tokenizer:Tokenizer}}(),Narcissus.parser=function(){function pushDestructuringVarDecls(t,e){for(var n in t){var r=t[n];r.type===IDENTIFIER?e.varDecls.push(r):pushDestructuringVarDecls(r,e)}}function StaticContext(t,e,n,r,i){this.parentScript=t,this.parentBlock=e,this.inFunction=n,this.inForLoopInit=r,this.nesting=i,this.allLabels=new Stack,this.currentLabels=new Stack,this.labeledTargets=new Stack,this.defaultTarget=null,Narcissus.options.ecma3OnlyMode&&(this.ecma3OnlyMode=!0),Narcissus.options.parenFreeMode&&(this.parenFreeMode=!0)}function Script(t,e){var n=new Node(t,scriptInit()),r=new StaticContext(n,n,e,!1,NESTING_TOP);return Statements(t,r,n),n}function Node(t,e){var n=t.token;n?(this.type=n.type,this.value=n.value,this.lineno=n.lineno,this.start=n.start,this.end=n.end):this.lineno=t.lineno,this.tokenizer=t,this.children=[];for(var r in e)this[r]=e[r]}function tokenString(t){var e=definitions.tokens[t];return/^\W/.test(e)?definitions.opTypeNames[e]:e.toUpperCase()}function blockInit(){return{type:BLOCK,varDecls:[]}}function scriptInit(){return{type:SCRIPT,funDecls:[],varDecls:[],modDecls:[],impDecls:[],expDecls:[],loadDeps:[],hasEmptyReturn:!1,hasReturnWithValue:!1,isGenerator:!1}}function MaybeLeftParen(t,e){return e.parenFreeMode?t.match(LEFT_PAREN)?LEFT_PAREN:END:t.mustMatch(LEFT_PAREN).type}function MaybeRightParen(t,e){e===LEFT_PAREN&&t.mustMatch(RIGHT_PAREN)}function Statements(t,e,n){try{for(;!t.done&&t.peek(!0)!==RIGHT_CURLY;)n.push(Statement(t,e))}catch(r){throw t.done&&(t.unexpectedEOF=!0),r}}function Block(t,e){t.mustMatch(LEFT_CURLY);var n=new Node(t,blockInit());return Statements(t,e.update({parentBlock:n}).pushTarget(n),n),t.mustMatch(RIGHT_CURLY),n}function Statement(t,e){var n,r,i,o,s,a,u,c,h=t.get(!0);switch(h){case FUNCTION:return FunctionDefinition(t,e,!0,e.nesting!==NESTING_TOP?STATEMENT_FORM:DECLARED_FORM);case LEFT_CURLY:return r=new Node(t,blockInit()),Statements(t,e.update({parentBlock:r}).pushTarget(r).nest(NESTING_SHALLOW),r),t.mustMatch(RIGHT_CURLY),r;case IF:return r=new Node(t),r.condition=HeadExpression(t,e),u=e.pushTarget(r).nest(NESTING_DEEP),r.thenPart=Statement(t,u),r.elsePart=t.match(ELSE)?Statement(t,u):null,r;case SWITCH:for(r=new Node(t,{cases:[],defaultIndex:-1}),r.discriminant=HeadExpression(t,e),u=e.pushTarget(r).nest(NESTING_DEEP),t.mustMatch(LEFT_CURLY);(h=t.get())!==RIGHT_CURLY;){switch(h){case DEFAULT:if(r.defaultIndex>=0)throw t.newSyntaxError("More than one switch default");case CASE:i=new Node(t),h===DEFAULT?r.defaultIndex=r.cases.length:i.caseLabel=Expression(t,u,COLON);break;default:throw t.newSyntaxError("Invalid switch case")}for(t.mustMatch(COLON),i.statements=new Node(t,blockInit());(h=t.peek(!0))!==CASE&&h!==DEFAULT&&h!==RIGHT_CURLY;)i.statements.push(Statement(t,u));r.cases.push(i)}return r;case FOR:if(r=new Node(t,LOOP_INIT),t.match(IDENTIFIER)&&("each"===t.token.value?r.isEach=!0:t.unget()),e.parenFreeMode||t.mustMatch(LEFT_PAREN),u=e.pushTarget(r).nest(NESTING_DEEP),c=e.update({inForLoopInit:!0}),(h=t.peek())!==SEMICOLON&&(h===VAR||h===CONST?(t.get(),i=Variables(t,c)):h===LET?(t.get(),t.peek()===LEFT_PAREN?i=LetBlock(t,c,!1):(c.parentBlock=r,r.varDecls=[],i=Variables(t,c))):i=Expression(t,c)),i&&t.match(IN))if(r.type=FOR_IN,r.object=Expression(t,c),i.type===VAR||i.type===LET){if(s=i.children,1!==s.length&&1!==i.destructurings.length)throw new SyntaxError("Invalid for..in left-hand side",t.filename,i.lineno);r.iterator=i.destructurings.length>0?i.destructurings[0]:s[0],r.varDecl=i}else(i.type===ARRAY_INIT||i.type===OBJECT_INIT)&&(i.destructuredNames=checkDestructuring(t,c,i)),r.iterator=i;else{if(r.setup=i,t.mustMatch(SEMICOLON),r.isEach)throw t.newSyntaxError("Invalid for each..in loop");r.condition=t.peek()===SEMICOLON?null:Expression(t,c),t.mustMatch(SEMICOLON),a=t.peek(),r.update=(e.parenFreeMode?a===LEFT_CURLY||definitions.isStatementStartCode[a]:a===RIGHT_PAREN)?null:Expression(t,c)}return e.parenFreeMode||t.mustMatch(RIGHT_PAREN),r.body=Statement(t,u),r;case WHILE:return r=new Node(t,{isLoop:!0}),r.condition=HeadExpression(t,e),r.body=Statement(t,e.pushTarget(r).nest(NESTING_DEEP)),r;case DO:if(r=new Node(t,{isLoop:!0}),r.body=Statement(t,e.pushTarget(r).nest(NESTING_DEEP)),t.mustMatch(WHILE),r.condition=HeadExpression(t,e),!e.ecmaStrictMode)return t.match(SEMICOLON),r;break;case BREAK:case CONTINUE:if(r=new Node(t),u=e.pushTarget(r),t.peekOnSameLine()===IDENTIFIER&&(t.get(),r.label=t.token.value),r.target=r.label?u.labeledTargets.find(function(t){return t.labels.has(r.label)}):u.defaultTarget,!r.target)throw t.newSyntaxError("Invalid "+(h===BREAK?"break":"continue"));if(!r.target.isLoop&&h===CONTINUE)throw t.newSyntaxError("Invalid continue");break;case TRY:for(r=new Node(t,{catchClauses:[]}),r.tryBlock=Block(t,e);t.match(CATCH);){switch(i=new Node(t),o=MaybeLeftParen(t,e),t.get()){case LEFT_BRACKET:case LEFT_CURLY:t.unget(),i.varName=DestructuringExpression(t,e,!0);break;case IDENTIFIER:i.varName=t.token.value;break;default:throw t.newSyntaxError("missing identifier in catch")}if(t.match(IF)){if(e.ecma3OnlyMode)throw t.newSyntaxError("Illegal catch guard");if(r.catchClauses.length&&!r.catchClauses.top().guard)throw t.newSyntaxError("Guarded catch after unguarded");i.guard=Expression(t,e)}MaybeRightParen(t,o),i.block=Block(t,e),r.catchClauses.push(i)}if(t.match(FINALLY)&&(r.finallyBlock=Block(t,e)),!r.catchClauses.length&&!r.finallyBlock)throw t.newSyntaxError("Invalid try statement");return r;case CATCH:case FINALLY:throw t.newSyntaxError(definitions.tokens[h]+" without preceding try");case THROW:r=new Node(t),r.exception=Expression(t,e);break;case RETURN:r=ReturnOrYield(t,e);break;case WITH:return r=new Node(t),r.object=HeadExpression(t,e),r.body=Statement(t,e.pushTarget(r).nest(NESTING_DEEP)),r;case VAR:case CONST:r=Variables(t,e);break;case LET:r=t.peek()===LEFT_PAREN?LetBlock(t,e,!0):Variables(t,e);break;case DEBUGGER:r=new Node(t);break;case NEWLINE:case SEMICOLON:return r=new Node(t,{type:SEMICOLON}),r.expression=null,r;default:if(h===IDENTIFIER&&(h=t.peek(),h===COLON)){if(n=t.token.value,e.allLabels.has(n))throw t.newSyntaxError("Duplicate label");return t.get(),r=new Node(t,{type:LABEL,label:n}),r.statement=Statement(t,e.pushLabel(n).nest(NESTING_SHALLOW)),r.target=r.statement.type===LABEL?r.statement.target:r.statement,r}r=new Node(t,{type:SEMICOLON}),t.unget(),r.expression=Expression(t,e),r.end=r.expression.end}return MagicalSemicolon(t),r}function MagicalSemicolon(t){var e;if(t.lineno===t.token.lineno&&(e=t.peekOnSameLine(),e!==END&&e!==NEWLINE&&e!==SEMICOLON&&e!==RIGHT_CURLY))throw t.newSyntaxError("missing ; before statement");t.match(SEMICOLON)}function ReturnOrYield(t,e){var n,r,i=t.token.type,o=e.parentScript;if(i===RETURN){if(!e.inFunction)throw t.newSyntaxError("Return not in function")}else{if(!e.inFunction)throw t.newSyntaxError("Yield not in function");o.isGenerator=!0}if(n=new Node(t,{value:void 0}),r=t.peek(!0),r!==END&&r!==NEWLINE&&r!==SEMICOLON&&r!==RIGHT_CURLY&&(i!==YIELD||r!==i&&r!==RIGHT_BRACKET&&r!==RIGHT_PAREN&&r!==COLON&&r!==COMMA)?i===RETURN?(n.value=Expression(t,e),o.hasReturnWithValue=!0):n.value=AssignExpression(t,e):i===RETURN&&(o.hasEmptyReturn=!0),o.hasReturnWithValue&&o.isGenerator)throw t.newSyntaxError("Generator returns a value");return n}function FunctionDefinition(t,e,n,r){var i,o=new Node(t,{params:[]});if(o.type!==FUNCTION&&(o.type="get"===o.value?GETTER:SETTER),t.match(IDENTIFIER))o.name=t.token.value;else if(n)throw t.newSyntaxError("missing function identifier");var s=new StaticContext(null,null,!0,!1,NESTING_TOP);if(t.mustMatch(LEFT_PAREN),!t.match(RIGHT_PAREN)){do switch(t.get()){case LEFT_BRACKET:case LEFT_CURLY:t.unget(),o.params.push(DestructuringExpression(t,s));break;case IDENTIFIER:o.params.push(t.token.value);break;default:throw t.newSyntaxError("missing formal parameter")}while(t.match(COMMA));t.mustMatch(RIGHT_PAREN)}if(i=t.get(),i!==LEFT_CURLY&&t.unget(),i!==LEFT_CURLY){if(o.body=AssignExpression(t,s),o.body.isGenerator)throw t.newSyntaxError("Generator returns a value")}else o.body=Script(t,!0);return i===LEFT_CURLY&&t.mustMatch(RIGHT_CURLY),o.end=t.token.end,o.functionForm=r,r===DECLARED_FORM&&e.parentScript.funDecls.push(o),o}function Variables(t,e,n){var r,i,o,s;switch(s=t.token.type){case VAR:case CONST:o=e.parentScript;break;case LET:o=e.parentBlock;break;case LEFT_PAREN:s=LET,o=n}r=new Node(t,{type:s,destructurings:[]});do if(s=t.get(),s!==LEFT_BRACKET&&s!==LEFT_CURLY){if(s!==IDENTIFIER)throw t.newSyntaxError("missing variable name");if(i=new Node(t,{type:IDENTIFIER,name:t.token.value,readOnly:r.type===CONST}),r.push(i),o.varDecls.push(i),t.match(ASSIGN)){if(t.token.assignOp)throw t.newSyntaxError("Invalid variable initialization");i.initializer=AssignExpression(t,e)}}else{t.unget();var a=DestructuringExpression(t,e,!0);if(i=new Node(t,{type:IDENTIFIER,name:a,readOnly:r.type===CONST}),r.push(i),pushDestructuringVarDecls(i.name.destructuredNames,o),r.destructurings.push({exp:a,decl:i}),e.inForLoopInit&&t.peek()===IN)continue;if(t.mustMatch(ASSIGN),t.token.assignOp)throw t.newSyntaxError("Invalid variable initialization");i.initializer=AssignExpression(t,e)}while(t.match(COMMA));return r}function LetBlock(t,e,n){var r,i;return r=new Node(t,{type:LET_BLOCK,varDecls:[]}),t.mustMatch(LEFT_PAREN),r.variables=Variables(t,e,r),t.mustMatch(RIGHT_PAREN),n&&t.peek()!==LEFT_CURLY&&(i=new Node(t,{type:SEMICOLON,expression:r}),n=!1),n?r.block=Block(t,e):r.expression=AssignExpression(t,e),r}function checkDestructuring(t,e,n,r){if(n.type===ARRAY_COMP)throw t.newSyntaxError("Invalid array comprehension left-hand side");if(n.type===ARRAY_INIT||n.type===OBJECT_INIT){for(var i,o,s,a,u={},c=n.children,h=0,l=c.length;l>h;h++)if(i=c[h])if(i.type===PROPERTY_INIT?(a=i.children,s=a[1],o=a[0].value):n.type===OBJECT_INIT?(s=i,o=i.value):(s=i,o=h),s.type===ARRAY_INIT||s.type===OBJECT_INIT)u[o]=checkDestructuring(t,e,s,r);else{if(r&&s.type!==IDENTIFIER)throw t.newSyntaxError("missing name in pattern");u[o]=s}return u}}function DestructuringExpression(t,e,n){var r=PrimaryExpression(t,e);return r.destructuredNames=checkDestructuring(t,e,r,n),r}function GeneratorExpression(t,e,n){return new Node(t,{type:GENERATOR,expression:n,tail:ComprehensionTail(t,e)})}function ComprehensionTail(t,e){var n,r,i,o,s;n=new Node(t,{type:COMP_TAIL});do{switch(r=new Node(t,{type:FOR_IN,isLoop:!0}),t.match(IDENTIFIER)&&("each"===t.token.value?r.isEach=!0:t.unget()),s=MaybeLeftParen(t,e),t.get()){case LEFT_BRACKET:case LEFT_CURLY:t.unget(),r.iterator=DestructuringExpression(t,e);break;case IDENTIFIER:r.iterator=o=new Node(t,{type:IDENTIFIER}),o.name=o.value,r.varDecl=i=new Node(t,{type:VAR}),i.push(o),e.parentScript.varDecls.push(o);break;default:throw t.newSyntaxError("missing identifier")}t.mustMatch(IN),r.object=Expression(t,e),MaybeRightParen(t,s),n.push(r)}while(t.match(FOR));return t.match(IF)&&(n.guard=HeadExpression(t,e)),n}function HeadExpression(t,e){var n=MaybeLeftParen(t,e),r=ParenExpression(t,e);if(MaybeRightParen(t,n),n===END&&!r.parenthesized){var i=t.peek();if(i!==LEFT_CURLY&&!definitions.isStatementStartCode[i])throw t.newSyntaxError("Unparenthesized head followed by unbraced body")}return r}function ParenExpression(t,e){var n=Expression(t,e.update({inForLoopInit:e.inForLoopInit&&t.token.type===LEFT_PAREN}));if(t.match(FOR)){if(n.type===YIELD&&!n.parenthesized)throw t.newSyntaxError("Yield expression must be parenthesized");if(n.type===COMMA&&!n.parenthesized)throw t.newSyntaxError("Generator expression must be parenthesized");n=GeneratorExpression(t,e,n)}return n}function Expression(t,e){var n,r;if(n=AssignExpression(t,e),t.match(COMMA)){r=new Node(t,{type:COMMA}),r.push(n),n=r;do{if(r=n.children[n.children.length-1],r.type===YIELD&&!r.parenthesized)throw t.newSyntaxError("Yield expression must be parenthesized");n.push(AssignExpression(t,e))}while(t.match(COMMA))}return n}function AssignExpression(t,e){var n,r;if(t.match(YIELD,!0))return ReturnOrYield(t,e);if(n=new Node(t,{type:ASSIGN}),r=ConditionalExpression(t,e),!t.match(ASSIGN))return r;switch(r.type){case OBJECT_INIT:case ARRAY_INIT:r.destructuredNames=checkDestructuring(t,e,r);case IDENTIFIER:case DOT:case INDEX:case CALL:break;default:throw t.newSyntaxError("Bad left-hand side of assignment")}return n.assignOp=t.token.assignOp,n.push(r),n.push(AssignExpression(t,e)),n}function ConditionalExpression(t,e){var n,r;if(n=OrExpression(t,e),t.match(HOOK)){if(r=n,n=new Node(t,{type:HOOK}),n.push(r),n.push(AssignExpression(t,e.update({inForLoopInit:!1}))),!t.match(COLON))throw t.newSyntaxError("missing : after ?");n.push(AssignExpression(t,e))}return n}function OrExpression(t,e){var n,r;for(n=AndExpression(t,e);t.match(OR);)r=new Node(t),r.push(n),r.push(AndExpression(t,e)),n=r;return n}function AndExpression(t,e){var n,r;for(n=BitwiseOrExpression(t,e);t.match(AND);)r=new Node(t),r.push(n),r.push(BitwiseOrExpression(t,e)),n=r;return n}function BitwiseOrExpression(t,e){var n,r;for(n=BitwiseXorExpression(t,e);t.match(BITWISE_OR);)r=new Node(t),r.push(n),r.push(BitwiseXorExpression(t,e)),n=r;return n}function BitwiseXorExpression(t,e){var n,r;for(n=BitwiseAndExpression(t,e);t.match(BITWISE_XOR);)r=new Node(t),r.push(n),r.push(BitwiseAndExpression(t,e)),n=r;return n}function BitwiseAndExpression(t,e){var n,r;for(n=EqualityExpression(t,e);t.match(BITWISE_AND);)r=new Node(t),r.push(n),r.push(EqualityExpression(t,e)),n=r;return n}function EqualityExpression(t,e){var n,r;for(n=RelationalExpression(t,e);t.match(EQ)||t.match(NE)||t.match(STRICT_EQ)||t.match(STRICT_NE);)r=new Node(t),r.push(n),r.push(RelationalExpression(t,e)),n=r;return n}function RelationalExpression(t,e){var n,r,i=e.update({inForLoopInit:!1});for(n=ShiftExpression(t,i);t.match(LT)||t.match(LE)||t.match(GE)||t.match(GT)||!e.inForLoopInit&&t.match(IN)||t.match(INSTANCEOF);)r=new Node(t),r.push(n),r.push(ShiftExpression(t,i)),n=r;return n}function ShiftExpression(t,e){var n,r;for(n=AddExpression(t,e);t.match(LSH)||t.match(RSH)||t.match(URSH);)r=new Node(t),r.push(n),r.push(AddExpression(t,e)),n=r;return n}function AddExpression(t,e){var n,r;for(n=MultiplyExpression(t,e);t.match(PLUS)||t.match(MINUS);)r=new Node(t),r.push(n),r.push(MultiplyExpression(t,e)),n=r;return n}function MultiplyExpression(t,e){var n,r;for(n=UnaryExpression(t,e);t.match(MUL)||t.match(DIV)||t.match(MOD);)r=new Node(t),r.push(n),r.push(UnaryExpression(t,e)),n=r;return n}function UnaryExpression(t,e){var n,r,i;switch(i=t.get(!0)){case DELETE:case VOID:case TYPEOF:case NOT:case BITWISE_NOT:case PLUS:case MINUS:n=i===PLUS?new Node(t,{type:UNARY_PLUS}):i===MINUS?new Node(t,{type:UNARY_MINUS}):new Node(t),n.push(UnaryExpression(t,e));break;case INCREMENT:case DECREMENT:n=new Node(t),n.push(MemberExpression(t,e,!0));break;default:t.unget(),n=MemberExpression(t,e,!0),t.tokens[3&t.tokenIndex+t.lookahead-1].lineno===t.lineno&&(t.match(INCREMENT)||t.match(DECREMENT))&&(r=new Node(t,{postfix:!0}),r.push(n),n=r)}return n}function MemberExpression(t,e,n){var r,i,o;for(t.match(NEW)?(r=new Node(t),r.push(MemberExpression(t,e,!1)),t.match(LEFT_PAREN)&&(r.type=NEW_WITH_ARGS,r.push(ArgumentList(t,e)))):r=PrimaryExpression(t,e);(o=t.get())!==END;){switch(o){case DOT:i=new Node(t),i.push(r),t.mustMatch(IDENTIFIER),i.push(new Node(t));break;case LEFT_BRACKET:i=new Node(t,{type:INDEX}),i.push(r),i.push(Expression(t,e)),t.mustMatch(RIGHT_BRACKET);break;case LEFT_PAREN:if(n){i=new Node(t,{type:CALL}),i.push(r),i.push(ArgumentList(t,e));break}default:return t.unget(),r}r=i}return r}function ArgumentList(t,e){var n,r;if(n=new Node(t,{type:LIST}),t.match(RIGHT_PAREN,!0))return n;do{if(r=AssignExpression(t,e),r.type===YIELD&&!r.parenthesized&&t.peek()===COMMA)throw t.newSyntaxError("Yield expression must be parenthesized");if(t.match(FOR)&&(r=GeneratorExpression(t,e,r),n.children.length>1||t.peek(!0)===COMMA))throw t.newSyntaxError("Generator expression must be parenthesized");n.push(r)}while(t.match(COMMA));return t.mustMatch(RIGHT_PAREN),n}function PrimaryExpression(t,e){var n,r,i=t.get(!0);switch(i){case FUNCTION:n=FunctionDefinition(t,e,!1,EXPRESSED_FORM);break;case LEFT_BRACKET:for(n=new Node(t,{type:ARRAY_INIT});(i=t.peek(!0))!==RIGHT_BRACKET;)if(i!==COMMA){if(n.push(AssignExpression(t,e)),i!==COMMA&&!t.match(COMMA))break}else t.get(),n.push(null);1===n.children.length&&t.match(FOR)&&(r=new Node(t,{type:ARRAY_COMP,expression:n.children[0],tail:ComprehensionTail(t,e)}),n=r),t.mustMatch(RIGHT_BRACKET);break;case LEFT_CURLY:var o;n=new Node(t,{type:OBJECT_INIT});t:if(!t.match(RIGHT_CURLY)){do if(i=t.get(),"get"!==t.token.value&&"set"!==t.token.value||t.peek()!==IDENTIFIER){switch(i){case IDENTIFIER:case NUMBER:case STRING:o=new Node(t,{type:IDENTIFIER});break;case RIGHT_CURLY:if(e.ecma3OnlyMode)throw t.newSyntaxError("Illegal trailing ,");break t;default:if(t.token.value in definitions.keywords){o=new Node(t,{type:IDENTIFIER});break}throw t.newSyntaxError("Invalid property name")}if(t.match(COLON))r=new Node(t,{type:PROPERTY_INIT}),r.push(o),r.push(AssignExpression(t,e)),n.push(r);else{if(t.peek()!==COMMA&&t.peek()!==RIGHT_CURLY)throw t.newSyntaxError("missing : after property");n.push(o)}}else{if(e.ecma3OnlyMode)throw t.newSyntaxError("Illegal property accessor");n.push(FunctionDefinition(t,e,!0,EXPRESSED_FORM))}while(t.match(COMMA));t.mustMatch(RIGHT_CURLY)}break;case LEFT_PAREN:n=ParenExpression(t,e),t.mustMatch(RIGHT_PAREN),n.parenthesized=!0;break;case LET:n=LetBlock(t,e,!1);break;case NULL:case THIS:case TRUE:case FALSE:case IDENTIFIER:case NUMBER:case STRING:case REGEXP:n=new Node(t);break;default:throw t.newSyntaxError("missing operand")}return n}function parse(t,e,n){var r=new lexer.Tokenizer(t,e,n),i=Script(r,!1);if(!r.done)throw r.newSyntaxError("Syntax error");return i}function parseStdin(t,e){for(;;)try{var n=new lexer.Tokenizer(t,"stdin",e.value),r=Script(n,!1);return e.value=n.lineno,r}catch(i){if(!n.unexpectedEOF)throw i;var o=readline();if(!o)throw i;t+="\n"+o}}var lexer=Narcissus.lexer,definitions=Narcissus.definitions;const StringMap=definitions.StringMap,Stack=definitions.Stack;eval(definitions.consts);const NESTING_TOP=0,NESTING_SHALLOW=1,NESTING_DEEP=2;StaticContext.prototype={ecma3OnlyMode:!1,parenFreeMode:!1,update:function(t){var e={};for(var n in t)e[n]={value:t[n],writable:!0,enumerable:!0,configurable:!0};return Object.create(this,e)},pushLabel:function(t){return this.update({currentLabels:this.currentLabels.push(t),allLabels:this.allLabels.push(t)})},pushTarget:function(t){var e=t.isLoop||t.type===SWITCH;return this.currentLabels.isEmpty()?e?this.update({defaultTarget:t}):this:(t.labels=new StringMap,this.currentLabels.forEach(function(e){t.labels.set(e,!0)}),this.update({currentLabels:new Stack,labeledTargets:this.labeledTargets.push(t),defaultTarget:e?t:this.defaultTarget}))},nest:function(t){var e=Math.max(this.nesting,t);return e!==this.nesting?this.update({nesting:e}):this}},definitions.defineProperty(Array.prototype,"top",function(){return this.length&&this[this.length-1]},!1,!1,!0);var Np=Node.prototype={};Np.constructor=Node,Np.toSource=Object.prototype.toSource,Np.push=function(t){return null!==t&&(t.start<this.start&&(this.start=t.start),this.end<t.end&&(this.end=t.end)),this.children.push(t)},Node.indentLevel=0,Np.toString=function(){var t=[];for(var e in this)this.hasOwnProperty(e)&&"type"!==e&&"target"!==e&&t.push({id:e,value:this[e]});t.sort(function(t,e){return t.id<e.id?-1:1});const n=" ";var r=++Node.indentLevel,i="{\n"+n.repeat(r)+"type: "+tokenString(this.type);for(e=0;e<t.length;e++)i+=",\n"+n.repeat(r)+t[e].id+": "+t[e].value;return r=--Node.indentLevel,i+="\n"+n.repeat(r)+"}"},Np.getSource=function(){return this.tokenizer.source.slice(this.start,this.end)};const LOOP_INIT={isLoop:!0};definitions.defineGetter(Np,"filename",function(){return this.tokenizer.filename}),definitions.defineGetter(Np,"length",function(){throw new Error("Node.prototype.length is gone; use n.children.length instead")}),definitions.defineProperty(String.prototype,"repeat",function(t){for(var e="",n=this+e;--t>=0;)e+=n;return e},!1,!1,!0);const DECLARED_FORM=0,EXPRESSED_FORM=1,STATEMENT_FORM=2;return{parse:parse,parseStdin:parseStdin,Node:Node,DECLARED_FORM:DECLARED_FORM,EXPRESSED_FORM:EXPRESSED_FORM,STATEMENT_FORM:STATEMENT_FORM,Tokenizer:lexer.Tokenizer,FunctionDefinition:FunctionDefinition}}();var exports={definitions:Narcissus.definitions,lexer:Narcissus.lexer,parser:Narcissus.parser};"undefined"!=typeof module&&(module.exports=exports),function(){var t,e,n,r,i,o,s,a,u=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},c=[].slice;i=require("./narcissus_packed"),a=require("underscore"),s=i.definitions.tokens,o=i.parser,t=o.Node,t.prototype.left=function(){return this.children[0]},t.prototype.right=function(){return this.children[1]},t.prototype.last=function(){return this.children[this.children.length-1]},t.prototype.walk=function(t,e,n,r){return null==n&&(n=null),null==r&&(r=null),n&&e(n,this,r),t.last&&null!=this.last()&&this.last().walk(t,e,this),null!=this.thenPart&&this.thenPart.walk(t,e,this,"thenPart"),null!=this.elsePart&&this.elsePart.walk(t,e,this,"elsePart"),this.cases?a.each(this.cases,function(n){return n.statements.walk(t,e,n,"cases")}):void 0},t.prototype.clone=function(e){var n;for(n in this)"tokenizer"!==n&&"length"!==n&&"filename"!==n&&null==e[n]&&(e[n]=this[n]);return new t(this.tokenizer,e)},t.prototype.toHash=function(t){var e,n,r;
null==t&&(t=[]),e={},r=function(e){return e?e.toHash?u.call(t,e)>=0?"--recursive "+e.id+"--":(e.id=t.push(e),e.toHash(t)):e:null},e.type=this.typeName(),e.src=this.src();for(n in this)"filename"!==n&&"length"!==n&&"type"!==n&&"start"!==n&&"end"!==n&&"tokenizer"!==n&&"function"!=typeof this[n]&&this[n]&&(e[n]=this[n].constructor===Array?a.map(this[n],function(t){return r(t)}):r(this[n]));return e},t.prototype.inspect=function(){return JSON.stringify(this.toHash(),null," ")},t.prototype.src=function(){return this.tokenizer.source.substr(this.start,this.end-this.start)},t.prototype.typeName=function(){return n[this.type]},t.prototype.isA=function(){var t,e;return t=1<=arguments.length?c.call(arguments,0):[],e=n[this.type],u.call(t,e)>=0},n=function(){var t,e,n;t={},n=0;for(e in s)"number"==typeof s[e]&&(t[s[e]]=e.toLowerCase(),n=s[e]);return t[++n]="call_statement",t[++n]="existence_check",t}(),e=function(){var t,e;t={};for(e in n)t[n[e]]=e;return t}(),this.NodeExt=r={Types:n,Typenames:e,Node:t},"undefined"!=typeof module&&null!==module&&(module.exports=r)}.call(this),function(){var t,e,n,r,i,o,s,a,u,c,h,l,p,d,f,E,y,N,m=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};e=require("coffee-script"),null==e.RESERVED&&(e.RESERVED=require("coffee-script/lib/coffee-script/lexer.js").RESERVED),t=function(){function t(){this.code=""}return t.INDENT=" ",t.prototype.add=function(t){return this.code+=t.toString(),this},t.prototype.scope=function(e,n){var r;return null==n&&(n=1),r=p(t.INDENT,n),this.code=h(this.code)+"\n",this.code+=r+h(e).replace(/\n/g,"\n"+r)+"\n",this},t.prototype.toString=function(){return this.code},t}(),c=function(t){var e;return e=t.toString(),"("===e.substr(0,1)&&")"===e.substr(-1,1)?e:"("+e+")"},p=function(t,e){var n;return function(){var r,i;for(i=[],n=r=0;e>=0?e>r:r>e;n=e>=0?++r:--r)i.push(t);return i}().join("")},a=function(t){return(""+t).replace(/^\s*/g,"")},h=function(t){return(""+t).replace(/\s*$/g,"")},n=function(t){return(""+t).replace(/^\s*\n|\s*$/g,"")},d=function(t){return(""+t).replace(/^\s*|\s*$/g,"")},s=function(t){return-1===d(t).indexOf("\n")},y=function(t){var e,n;for(t=""+t;;){if(e=t.match(/^/gm),n=t.match(/^ /gm),!e||!n||e.length!==n.length)return t;t=t.replace(/^ /gm,"")}},f=function(t){return t.isA("true")||t.isA("number")&&0!==parseFloat(t.src())},l=function(t){return JSON.stringify(""+t)},u=function(t){return t.constructor===String?console.log(JSON.stringify(t)):console.log(t),""},r=function(){var t,n,r,i;for(r=e.RESERVED,i=[],t=0,n=r.length;n>t;t++)N=r[t],"undefined"!==N&&i.push(N);return i}(),E=function(t){var e;return e=""+t,m.call(r,e)>=0?""+t+"_":""+t},o=function(t,e){return t+e.replace(/\n/g,"\n"+t)},this.Js2coffeeHelpers=i={Code:t,p:u,strEscape:l,unreserve:E,unshift:y,isSingleLine:s,trim:d,blockTrim:n,ltrim:a,rtrim:h,strRepeat:p,paren:c,truthy:f,indentLines:o},"undefined"!=typeof module&&null!==module&&(module.exports=i)}.call(this),function(){var t,e,n,r,i,o,s,a,u,c,h,l,p,d,f,E,y,N,m,g,I,T,v,b,w,R,S=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},x=[].slice,_={}.hasOwnProperty;b=require("underscore"),E=require("./narcissus_packed").parser,w=require("./node_ext"),o=w.Types,i=w.Typenames,n=w.Node,R=require("./helpers"),e=R.Code,d=R.p,N=R.strEscape,T=R.unreserve,v=R.unshift,l=R.isSingleLine,g=R.trim,a=R.blockTrim,p=R.ltrim,y=R.rtrim,m=R.strRepeat,f=R.paren,I=R.truthy,h=R.indentLines,u=function(e,n){var r,i,o,s,a,u,c,l,d,f,N,m,I,T,v,w;if(null==n&&(n={}),e=e.replace(/\r/g,""),e+="\n",r=new t(n),N=E.parse(e),l=g(r.build(N)),n.no_comments)return function(){var t,e,n,r;for(n=l.split("\n"),r=[],t=0,e=n.length;e>t;t++)u=n[t],r.push(y(u));return r}().join("\n");for(s=n.show_src_lineno,f=[],w=l.split("\n"),T=0,v=w.length;v>T;T++)a=w[T],m=[],I=a.replace(/\uFEFE([0-9]+).*?\uFEFE/g,function(t,e){return m.push(parseInt(e)),""}),m=b.sortBy(b.uniq(m),function(t){return t}),I=y(I),o=I.match(/^\s*/),m.length>0&&(c=b.last(m),d=r.commentsNotDoneTo(c),d&&f.push(h(o,d))),I?(s&&(I=I+"#"+m.join(",")+"# "),f.push(y(I+" "+p(r.lineComments(m))))):f.push("");return i=r.commentsNotDoneTo(1e10),i&&f.push(i),f.join("\n")},t=function(){function t(t){this.options=null!=t?t:{},this.transformer=new r}return t.prototype.l=function(t){return this.options.no_comments?"":t&&t.lineno?"﻾"+t.lineno+"﻾":""},t.prototype.makeComment=function(t){var e,n;if("BLOCK_COMMENT"===t.type)if(e=t.value.split("\n"),e.length>0&&e[0].length>0&&"*"===e[0][0]){for(e=function(){var t,r,i;for(i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push(n.replace(/^[\s\*]*/,""));return i}(),e=function(){var t,r,i;for(i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push(n.replace(/[\s]*$/,""));return i}();e.length>0&&0===e[0].length;)e.shift();for(;e.length>0&&0===e[e.length-1].length;)e.pop();e.unshift("###"),e.push("###")}else e=function(){var t,r,i;for(i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push("#"+n);return i}();else e=["#"+t.value];return t.nlcount>0&&e.unshift(""),e.join("\n")},t.prototype.commentsNotDoneTo=function(t){var e,n;for(n=[];;){if(0===this.comments.length)break;e=this.comments[0];{if(!(e.lineno<t))break;n.push(this.makeComment(e)),this.comments.shift()}}return n.join("\n")},t.prototype.lineComments=function(t){var e,n;return n=function(){var n,r,i,o,s;for(i=this.comments,s=[],n=0,r=i.length;r>n;n++)e=i[n],o=e.lineno,S.call(t,o)>=0&&s.push(e);return s}.call(this),this.comments=b.difference(this.comments,n),function(){var t,r,i;for(i=[],t=0,r=n.length;r>t;t++)e=n[t],i.push(this.makeComment(e));return i}.call(this).join("\n")},t.prototype.build=function(){var t,e,n,r,i;return t=1<=arguments.length?x.call(arguments,0):[],r=t[0],null==this.comments&&(this.comments=b.sortBy(r.tokenizer.comments,function(t){return t.start})),this.transform(r),n="other",void 0!==r&&r.typeName&&(n=r.typeName()),e=this[n]||this.other,i=e.apply(this,t),r.parenthesized?f(i):i},t.prototype.transform=function(){var t;return t=1<=arguments.length?x.call(arguments,0):[],this.transformer.transform.apply(this.transformer,t)},t.prototype.body=function(t,e){var n;return null==e&&(e={}),n=this.build(t,e),n=a(n),n=v(n),n.length>0?n:""},t.prototype.script=function(t,n){var r,i=this;return null==n&&(n={}),r=new e,b.each(t.functions,function(t){return r.add(i.build(t))}),b.each(t.nonfunctions,function(t){return r.add(i.build(t))}),r.toString()},t.prototype.property_identifier=function(t){var e;return e=t.value.toString(),e.match(/^([_\$a-z][_\$a-z0-9]*)$/i)||e.match(/^[0-9]+$/i)?this.l(t)+e:this.l(t)+N(e)},t.prototype.identifier=function(t){return"undefined"===t.value?this.l(t)+"`undefined`":t.property_accessor?this.l(t)+t.value.toString():this.l(t)+T(t.value.toString())},t.prototype.number=function(t){return this.l(t)+(""+t.src())},t.prototype.id=function(t){return t.property_accessor?this.l(t)+t:this.l(t)+T(t)},t.prototype.id_param=function(t){var e;return"undefined"===(e=t.toString())?this.l(t)+(""+t+"_"):this.l(t)+this.id(t)},t.prototype["return"]=function(t){return null==t.value?this.l(t)+"return\n":this.l(t)+("return "+this.build(t.value)+"\n")},t.prototype[";"]=function(t){var e;return null==t.expression?"":"object_init"===t.expression.typeName()?(e=this.object_init(t.expression),t.parenthesized?e:""+v(a(e))+"\n"):this.build(t.expression)+"\n"},t.prototype["new"]=function(t){return this.l(t)+("new "+this.build(t.left()))},t.prototype.new_with_args=function(t){return this.l(t)+("new "+this.build(t.left())+"("+this.build(t.right())+")")},t.prototype.unary_plus=function(t){return"+"+this.build(t.left())},t.prototype.unary_minus=function(t){return"-"+this.build(t.left())},t.prototype["this"]=function(t){return this.l(t)+"this"},t.prototype["null"]=function(t){return this.l(t)+"null"},t.prototype["true"]=function(t){return this.l(t)+"true"},t.prototype["false"]=function(t){return this.l(t)+"false"},t.prototype["void"]=function(t){return this.l(t)+"undefined"},t.prototype["debugger"]=function(t){return this.l(t)+"debugger\n"},t.prototype["break"]=function(t){return this.l(t)+"break\n"},t.prototype["continue"]=function(t){return this.l(t)+"continue\n"},t.prototype["~"]=function(t){return"~"+this.build(t.left())},t.prototype["typeof"]=function(t){return this.l(t)+("typeof "+this.build(t.left()))},t.prototype.index=function(t){var e;return e=this.build(t.right()),b.any(t.children,function(t){return"object_init"===t.typeName()&&t.children.length>1})&&(e="{"+e+"}"),this.l(t)+(""+this.build(t.left())+"["+e+"]")},t.prototype["throw"]=function(t){return this.l(t)+("throw "+this.build(t.exception))},t.prototype["!"]=function(t){var e,n;for(n=t.left(),e=1;n.isA("!")&&(n=n.left());)++e;return 1&e&&n.isA("==","!=","===","!==","in","instanceof")?(n.negated=!n.negated,this.build(n)):this.l(t)+(""+(1&e?"not ":"!!")+this.build(n))},t.prototype["in"]=function(t){return this.binary_operator(t,"of")},t.prototype["+"]=function(t){return this.binary_operator(t,"+")},t.prototype["-"]=function(t){return this.binary_operator(t,"-")},t.prototype["*"]=function(t){return this.binary_operator(t,"*")},t.prototype["/"]=function(t){return this.binary_operator(t,"/")},t.prototype["%"]=function(t){return this.binary_operator(t,"%")},t.prototype[">"]=function(t){return this.binary_operator(t,">")},t.prototype["<"]=function(t){return this.binary_operator(t,"<")},t.prototype["&"]=function(t){return this.binary_operator(t,"&")},t.prototype["|"]=function(t){return this.binary_operator(t,"|")},t.prototype["^"]=function(t){return this.binary_operator(t,"^")},t.prototype["&&"]=function(t){return this.binary_operator(t,"and")},t.prototype["||"]=function(t){return this.binary_operator(t,"or")},t.prototype["<<"]=function(t){return this.binary_operator(t,"<<")},t.prototype["<="]=function(t){return this.binary_operator(t,"<=")},t.prototype[">>"]=function(t){return this.binary_operator(t,">>")},t.prototype[">="]=function(t){return this.binary_operator(t,">=")},t.prototype["==="]=function(t){return this.binary_operator(t,"is")},t.prototype["!=="]=function(t){return this.binary_operator(t,"isnt")},t.prototype[">>>"]=function(t){return this.binary_operator(t,">>>")},t.prototype["instanceof"]=function(t){return this.binary_operator(t,"instanceof")},t.prototype["=="]=function(t){return this.binary_operator(t,"is")},t.prototype["!="]=function(t){return this.binary_operator(t,"isnt")},t.prototype.binary_operator=function(){var t,e,n;t={is:"isnt","in":"not in",of:"not of","instanceof":"not instanceof"};for(e in t)_.call(t,e)&&(n=t[e],t[n]=e);return function(e,n){return e.negated&&(n=t[n]),this.l(e)+(""+this.build(e.left())+" "+n+" "+this.build(e.right()))}}(),t.prototype["--"]=function(t){return this.increment_decrement(t,"--")},t.prototype["++"]=function(t){return this.increment_decrement(t,"++")},t.prototype.increment_decrement=function(t,e){return t.postfix?this.l(t)+(""+this.build(t.left())+e):this.l(t)+(""+e+this.build(t.left()))},t.prototype["="]=function(t){var e;return e=null!=t.assignOp?o[t.assignOp]+"=":"=",this.l(t)+(""+this.build(t.left())+" "+e+" "+this.build(t.right()))},t.prototype[","]=function(t){var e,n=this;return e=b.map(t.children,function(t){return n.l(t)+n.build(t)+"\n"}),e.join("")},t.prototype.regexp=function(t){var e,n,r,i;return r=t.value.toString().match(/^\/(.*)\/([a-z]?)/),i=r[1],n=r[2],e=i[0]," "===e||"="===e?n.length>0?this.l(t)+("RegExp("+N(i)+', "'+n+'")'):this.l(t)+("RegExp("+N(i)+")"):this.l(t)+("/"+i+"/"+n)},t.prototype.string=function(t){return this.l(t)+N(t.value)},t.prototype.call=function(t){return 0===t.right().children.length?""+this.build(t.left())+"()"+this.l(t):""+this.build(t.left())+"("+this.build(t.right())+")"+this.l(t)},t.prototype.call_statement=function(t){var e;return e=this.build(t.left()),t.left().isA("function")&&(e=f(e)),0===t.right().children.length?""+e+"()"+this.l(t):""+e+" "+this.build(t.right())+this.l(t)},t.prototype.list=function(t,n){var r,i=this;return null==n&&(n={}),r=b.map(t.children,function(r){var o,s;return t.children.length>1&&(r.is_list_element=!0),n.array===!0&&t.children.length>0?(s=i[r.typeName()](r),o=new e(i,r),o.scope(s),o=g(o+e.INDENT),"object_init"===r.typeName()&&(o="{\n"+e.INDENT+e.INDENT+o+"\n"+e.INDENT+"}"),o):i.build(r)}),n.array===!0&&t.children.length>0?this.l(t)+("\n"+e.INDENT+r.join("\n"+e.INDENT)):this.l(t)+r.join(", ")},t.prototype["delete"]=function(t){var e,n=this;return e=b.map(t.children,function(t){return n.build(t)}),e=e.join(", "),this.l(t)+("delete "+e+"\n")},t.prototype["."]=function(t){var e,n,r;return e=this.build(t.left()),r=t.right(),r.property_accessor=!0,n=this.build(r),t.isThis&&t.isPrototype?this.l(t)+"@::":t.isThis?this.l(t)+("@"+n):t.isPrototype?this.l(t)+(""+e+"::"):t.left().isPrototype?this.l(t)+(""+e+n):this.l(t)+(""+e+"."+n)},t.prototype["try"]=function(t){var n,r=this;return n=new e,n.add("try"),n.scope(this.body(t.tryBlock)),b.each(t.catchClauses,function(t){return n.add(r.build(t))}),null!=t.finallyBlock&&(n.add("finally"),n.scope(this.body(t.finallyBlock))),this.l(t)+n},t.prototype["catch"]=function(t){var n,r;return n=this.body(t.block),0===g(n).length?"":(r=new e,null!=t.varName?r.add("catch "+t.varName):r.add("catch"),r.scope(this.body(t.block)),this.l(t)+r)},t.prototype["?"]=function(t){return this.l(t)+("(if "+this.build(t.left())+" then "+this.build(t.children[1])+" else "+this.build(t.children[2])+")")},t.prototype["for"]=function(t){var n;return n=new e,null!=t.setup&&n.add(""+this.build(t.setup)+"\n"),null!=t.condition?n.add("while "+this.build(t.condition)+"\n"):n.add("loop"),n.scope(this.body(t.body)),null!=t.update&&n.scope(this.body(t.update)),this.l(t)+n},t.prototype.for_in=function(t){var n;return n=new e,n.add("for "+this.build(t.iterator)+" of "+this.build(t.object)),n.scope(this.body(t.body)),this.l(t)+n},t.prototype["while"]=function(t){var n,r,i,o;return r=new e,i=t.positive?"while":"until",n=this.body(t.body),o=I(t.condition)?"loop":""+i+" "+this.build(t.condition),l(n)&&"loop"!==o?r.add(""+g(n)+e.INDENT+o+"\n"):(r.add(o),r.scope(n)),this.l(t)+r},t.prototype["do"]=function(t){var n;return n=new e,n.add("loop"),n.scope(this.body(t.body)),null!=t.condition&&n.scope("break unless "+this.build(t.condition)),this.l(t)+n},t.prototype["if"]=function(t){var n,r,i;return r=new e,i=t.positive?"if":"unless",n=this.body(t.thenPart),t.condition.parenthesized=!1,t.thenPart.isA("block")&&0===t.thenPart.children.length&&null==t.elsePart?(console.log(t.thenPart),r.add(""+this.build(t.condition)+"\n")):l(n)&&null==t.elsePart?r.add(""+g(n)+e.INDENT+i+" "+this.build(t.condition)+"\n"):(r.add(""+i+" "+this.build(t.condition)),r.scope(this.body(t.thenPart)),null!=t.elsePart&&("if"===t.elsePart.typeName()?r.add("else "+this.build(t.elsePart).toString()):(r.add(this.l(t.elsePart)+"else\n"),r.scope(this.body(t.elsePart))))),this.l(t)+r},t.prototype["switch"]=function(t){var n,r,i=this;return n=new e,n.add("switch "+this.build(t.discriminant)+"\n"),r=!1,b.each(t.cases,function(t){var e;return"default"===t.value?n.scope(i.l(t)+"else"):r===!0?n.add(i.l(t)+(", "+i.build(t.caseLabel)+"\n")):n.add(i.l(t)+(" when "+i.build(t.caseLabel))),0===i.body(t.statements).length?r=!0:(r=!1,n.add("\n"),n.scope(i.body(t.statements),2)),e=!1}),this.l(t)+n},t.prototype.existence_check=function(t){return this.l(t)+(""+this.build(t.left())+"?")},t.prototype.array_init=function(t){var e;return e={array:!0},0===t.children.length?this.l(t)+"[]":t.children.length>1?this.l(t)+("["+this.list(t,e)+"\n]"):this.l(t)+("["+this.list(t)+"]")},t.prototype.property_init=function(t){var e,n;return e=t.left(),n=t.right(),n.is_property_value=!0,""+this.property_identifier(e)+": "+this.build(n)},t.prototype.object_init=function(t,n){var r,i,o=this;return null==n&&(n={}),0===t.children.length?this.l(t)+"{}":1!==t.children.length||t.is_property_value||t.is_list_element?(i=b.map(t.children,function(t){return o.build(t)}),r=new e(this,t),r.scope(i.join("\n")),null!=n.brackets&&(r="{"+r+"}"),r):this.build(t.children[0])},t.prototype["function"]=function(t){var n,r,i,o=this;return r=new e,i=b.map(t.params,function(t){return t.constructor===String?o.id_param(t):o.build(t)}),t.name&&r.add(""+t.name+" = "),t.params.length>0?r.add("("+i.join(", ")+") ->"):r.add("->"),n=this.body(t.body),g(n).length>0?r.scope(n):r.add("\n"),this.l(t)+r},t.prototype["var"]=function(t){var e,n=this;return e=b.map(t.children,function(t){return""+T(t.value)+" = "+(null!=t.initializer?n.build(t.initializer):"undefined")}),this.l(t)+b.compact(e).join("\n")+"\n"},t.prototype.other=function(t){return this.unsupported(t,""+t.typeName()+" is not supported yet")},t.prototype.getter=function(t){return this.unsupported(t,"getter syntax is not supported; use __defineGetter__")},t.prototype.setter=function(t){return this.unsupported(t,"setter syntax is not supported; use __defineSetter__")},t.prototype.label=function(t){return this.unsupported(t,"labels are not supported by CoffeeScript")},t.prototype["const"]=function(t){return this.unsupported(t,"consts are not supported by CoffeeScript")},t.prototype.block=function(){var t;return t=1<=arguments.length?x.call(arguments,0):[],this.script.apply(this,t)},t.prototype.unsupported=function(t,e){throw new s("Unsupported: "+e,t)},t}(),r=function(){function t(){}return t.prototype.transform=function(){var t,e,n,r;return t=1<=arguments.length?x.call(arguments,0):[],n=t[0],null==n.transformed?(r=n.typeName(),e=this[r],e?(e.apply(this,t),n.transformed=!0):void 0):void 0},t.prototype.script=function(t){var e;return t.functions=[],t.nonfunctions=[],b.each(t.children,function(e){return e.isA("function")?t.functions.push(e):t.nonfunctions.push(e)}),e=null,b.each(t.nonfunctions,function(t){var n;return null!=t.expression?(n=t.expression,t.parenthesized=(null!=e?e.isA("object_init"):void 0)&&n.isA("object_init")?!0:!1,e=n):void 0})},t.prototype["."]=function(t){return t.isThis=t.left().isA("this"),t.isPrototype=t.right().isA("identifier")&&"prototype"===t.right().value},t.prototype[";"]=function(t){return null!=t.expression&&(t.expression.parenthesized=!1,t.expression.isA("call"))?(t.expression.type=i.call_statement,this.call_statement(t)):void 0},t.prototype["function"]=function(t){return t.body.walk({last:!0},function(t,e,n){var r;return e.isA("return")&&e.value&&(r=n?t[n]:t.children[t.children.length-1])?(r.type=i[";"],r.expression=r.value):void 0})},t.prototype["switch"]=function(t){return b.each(t.cases,function(t){var e,n,r;return e=t.statements,n=e.children,(null!=(r=e.last())?r.isA("break"):void 0)?delete n[n.length-1]:void 0})},t.prototype.call_statement=function(t){return t.children[1]?b.each(t.children[1].children,function(e,n){return e.isA("function")&&n!==t.children[1].children.length-1?e.parenthesized=!0:void 0}):void 0},t.prototype["return"]=function(t){return t.value&&t.value.isA("object_init")&&t.value.children.length>1?t.value.parenthesized=!0:void 0},t.prototype.block=function(t){return this.script(t)},t.prototype["if"]=function(t){var e;return 0===t.thenPart.children.length&&(null!=(e=t.elsePart)?e.children.length:void 0)>0&&(t.positive=!1,t.thenPart=t.elsePart,delete t.elsePart),this.inversible(t)},t.prototype["while"]=function(t){return 0===t.body.children.length&&t.body.children.push(t.clone({type:i["continue"],value:"continue",children:[]})),this.inversible(t)},t.prototype.inversible=function(t){var e;return this.transform(t.condition),e=null!=t.positive?t.positive:!0,t.condition.isA("!=")?(t.condition.type=i["=="],t.positive=!e):t.condition.isA("!")?(t.condition=t.condition.left(),t.positive=!e):t.positive=e},t.prototype["=="]=function(t){return t.right().isA("null","void")?(t.type=i["!"],t.children=[t.clone({type:i.existence_check,children:[t.left()]})]):void 0},t.prototype["!="]=function(t){return t.right().isA("null","void")?(t.type=i.existence_check,t.children=[t.left()]):void 0},t}(),s=function(){function t(t,e){this.message=t,this.cursor=e.start,this.line=e.lineno,this.source=e.tokenizer.source}return t.prototype.toString=function(){return this.message},t}(),this.Js2coffee=c={VERSION:"0.1.3",build:u,UnsupportedError:s},"undefined"!=typeof module&&null!==module&&(module.exports=c)}.call(this);
null==t&&(t=[]),e={},r=function(e){return e?e.toHash?u.call(t,e)>=0?"--recursive "+e.id+"--":(e.id=t.push(e),e.toHash(t)):e:null},e.type=this.typeName(),e.src=this.src();for(n in this)"filename"!==n&&"length"!==n&&"type"!==n&&"start"!==n&&"end"!==n&&"tokenizer"!==n&&"function"!=typeof this[n]&&this[n]&&(e[n]=this[n].constructor===Array?a.map(this[n],function(t){return r(t)}):r(this[n]));return e},t.prototype.inspect=function(){return JSON.stringify(this.toHash(),null," ")},t.prototype.src=function(){return this.tokenizer.source.substr(this.start,this.end-this.start)},t.prototype.typeName=function(){return n[this.type]},t.prototype.isA=function(){var t,e;return t=1<=arguments.length?c.call(arguments,0):[],e=n[this.type],u.call(t,e)>=0},n=function(){var t,e,n;t={},n=0;for(e in s)"number"==typeof s[e]&&(t[s[e]]=e.toLowerCase(),n=s[e]);return t[++n]="call_statement",t[++n]="existence_check",t}(),e=function(){var t,e;t={};for(e in n)t[n[e]]=e;return t}(),this.NodeExt=r={Types:n,Typenames:e,Node:t},"undefined"!=typeof module&&null!==module&&(module.exports=r)}.call(this),function(){var t,e,n,r,i,o,s,a,u,c,h,l,p,d,f,E,y,N,m=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};e=require("coffee-script"),null==e.RESERVED&&(e.RESERVED=require("coffee-script/lib/coffee-script/lexer.js").RESERVED),t=function(){function t(){this.code=""}return t.INDENT=" ",t.prototype.add=function(t){return this.code+=t.toString(),this},t.prototype.scope=function(e,n){var r;return null==n&&(n=1),r=p(t.INDENT,n),this.code=h(this.code)+"\n",this.code+=r+h(e).replace(/\n/g,"\n"+r)+"\n",this},t.prototype.toString=function(){return this.code},t}(),c=function(t){var e;return e=t.toString(),"("===e.substr(0,1)&&")"===e.substr(-1,1)?e:"("+e+")"},p=function(t,e){var n;return function(){var r,i;for(i=[],n=r=0;e>=0?e>r:r>e;n=e>=0?++r:--r)i.push(t);return i}().join("")},a=function(t){return(""+t).replace(/^\s*/g,"")},h=function(t){return(""+t).replace(/\s*$/g,"")},n=function(t){return(""+t).replace(/^\s*\n|\s*$/g,"")},d=function(t){return(""+t).replace(/^\s*|\s*$/g,"")},s=function(t){return-1===d(t).indexOf("\n")},y=function(t){var e,n;for(t=""+t;;){if(e=t.match(/^/gm),n=t.match(/^ /gm),!e||!n||e.length!==n.length)return t;t=t.replace(/^ /gm,"")}},f=function(t){return t.isA("true")||t.isA("number")&&0!==parseFloat(t.src())},l=function(t){return JSON.stringify(""+t)},u=function(t){return t.constructor===String?console.log(JSON.stringify(t)):console.log(t),""},r=function(){var t,n,r,i;for(r=e.RESERVED,i=[],t=0,n=r.length;n>t;t++)N=r[t],"undefined"!==N&&i.push(N);return i}(),E=function(t){var e;return e=""+t,m.call(r,e)>=0?""+t+"_":""+t},o=function(t,e){return t+e.replace(/\n/g,"\n"+t)},this.Js2coffeeHelpers=i={Code:t,p:u,strEscape:l,unreserve:E,unshift:y,isSingleLine:s,trim:d,blockTrim:n,ltrim:a,rtrim:h,strRepeat:p,paren:c,truthy:f,indentLines:o},"undefined"!=typeof module&&null!==module&&(module.exports=i)}.call(this),function(){var t,e,n,r,i,o,s,a,u,c,h,l,p,d,f,E,y,N,m,g,I,T,v,b,w,R,S=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},x=[].slice,_={}.hasOwnProperty;b=require("underscore"),E=require("./narcissus_packed").parser,w=require("./node_ext"),o=w.Types,i=w.Typenames,n=w.Node,R=require("./helpers"),e=R.Code,d=R.p,N=R.strEscape,T=R.unreserve,v=R.unshift,l=R.isSingleLine,g=R.trim,a=R.blockTrim,p=R.ltrim,y=R.rtrim,m=R.strRepeat,f=R.paren,I=R.truthy,h=R.indentLines,u=function(n,r){var i,o,s,a,u,c,l,d,f,N,m,I,T,v,w,R;if(null==r&&(r={}),n=n.replace(/\r/g,""),n+="\n",null!=r.indent&&(e.INDENT=r.indent),i=new t(r),m=E.parse(n),d=g(i.build(m)),r.no_comments)return function(){var t,e,n,r;for(n=d.split("\n"),r=[],t=0,e=n.length;e>t;t++)c=n[t],r.push(y(c));return r}().join("\n");for(a=r.show_src_lineno,N=[],R=d.split("\n"),v=0,w=R.length;w>v;v++)u=R[v],I=[],T=u.replace(/\uFEFE([0-9]+).*?\uFEFE/g,function(t,e){return I.push(parseInt(e)),""}),I=b.sortBy(b.uniq(I),function(t){return t}),T=y(T),s=T.match(/^\s*/),I.length>0&&(l=b.last(I),f=i.commentsNotDoneTo(l),f&&N.push(h(s,f))),T?(a&&(T=T+"#"+I.join(",")+"# "),N.push(y(T+" "+p(i.lineComments(I))))):N.push("");return o=i.commentsNotDoneTo(1e10),o&&N.push(o),N.join("\n")},t=function(){function t(t){this.options=null!=t?t:{},this.transformer=new r}return t.prototype.l=function(t){return this.options.no_comments?"":t&&t.lineno?"﻾"+t.lineno+"﻾":""},t.prototype.makeComment=function(t){var e,n;if("BLOCK_COMMENT"===t.type)if(e=t.value.split("\n"),e.length>0&&e[0].length>0&&"*"===e[0][0]){for(e=function(){var t,r,i;for(i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push(n.replace(/^[\s\*]*/,""));return i}(),e=function(){var t,r,i;for(i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push(n.replace(/[\s]*$/,""));return i}();e.length>0&&0===e[0].length;)e.shift();for(;e.length>0&&0===e[e.length-1].length;)e.pop();e.unshift("###"),e.push("###")}else e=function(){var t,r,i;for(i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push("#"+n);return i}();else e=["#"+t.value];return t.nlcount>0&&e.unshift(""),e.join("\n")},t.prototype.commentsNotDoneTo=function(t){var e,n;for(n=[];;){if(0===this.comments.length)break;e=this.comments[0];{if(!(e.lineno<t))break;n.push(this.makeComment(e)),this.comments.shift()}}return n.join("\n")},t.prototype.lineComments=function(t){var e,n;return n=function(){var n,r,i,o,s;for(i=this.comments,s=[],n=0,r=i.length;r>n;n++)e=i[n],o=e.lineno,S.call(t,o)>=0&&s.push(e);return s}.call(this),this.comments=b.difference(this.comments,n),function(){var t,r,i;for(i=[],t=0,r=n.length;r>t;t++)e=n[t],i.push(this.makeComment(e));return i}.call(this).join("\n")},t.prototype.build=function(){var t,e,n,r,i;return t=1<=arguments.length?x.call(arguments,0):[],r=t[0],null==this.comments&&(this.comments=b.sortBy(r.tokenizer.comments,function(t){return t.start})),this.transform(r),n="other",void 0!==r&&r.typeName&&(n=r.typeName()),e=this[n]||this.other,i=e.apply(this,t),r.parenthesized?f(i):i},t.prototype.transform=function(){var t;return t=1<=arguments.length?x.call(arguments,0):[],this.transformer.transform.apply(this.transformer,t)},t.prototype.body=function(t,e){var n;return null==e&&(e={}),n=this.build(t,e),n=a(n),n=v(n),n.length>0?n:""},t.prototype.script=function(t,n){var r,i=this;return null==n&&(n={}),r=new e,b.each(t.functions,function(t){return r.add(i.build(t))}),b.each(t.nonfunctions,function(t){return r.add(i.build(t))}),r.toString()},t.prototype.property_identifier=function(t){var e;return e=t.value.toString(),e.match(/^([_\$a-z][_\$a-z0-9]*)$/i)||e.match(/^[0-9]+$/i)?this.l(t)+e:this.l(t)+N(e)},t.prototype.identifier=function(t){return"undefined"===t.value?this.l(t)+"`undefined`":t.property_accessor?this.l(t)+t.value.toString():this.l(t)+T(t.value.toString())},t.prototype.number=function(t){return this.l(t)+(""+t.src())},t.prototype.id=function(t){return t.property_accessor?this.l(t)+t:this.l(t)+T(t)},t.prototype.id_param=function(t){var e;return"undefined"===(e=t.toString())?this.l(t)+(""+t+"_"):this.l(t)+this.id(t)},t.prototype["return"]=function(t){return null==t.value?this.l(t)+"return\n":this.l(t)+("return "+this.build(t.value)+"\n")},t.prototype[";"]=function(t){var e;return null==t.expression?"":"object_init"===t.expression.typeName()?(e=this.object_init(t.expression),t.parenthesized?e:""+v(a(e))+"\n"):this.build(t.expression)+"\n"},t.prototype["new"]=function(t){return this.l(t)+("new "+this.build(t.left()))},t.prototype.new_with_args=function(t){return this.l(t)+("new "+this.build(t.left())+"("+this.build(t.right())+")")},t.prototype.unary_plus=function(t){return"+"+this.build(t.left())},t.prototype.unary_minus=function(t){return"-"+this.build(t.left())},t.prototype["this"]=function(t){return this.l(t)+"this"},t.prototype["null"]=function(t){return this.l(t)+"null"},t.prototype["true"]=function(t){return this.l(t)+"true"},t.prototype["false"]=function(t){return this.l(t)+"false"},t.prototype["void"]=function(t){return this.l(t)+"undefined"},t.prototype["debugger"]=function(t){return this.l(t)+"debugger\n"},t.prototype["break"]=function(t){return this.l(t)+"break\n"},t.prototype["continue"]=function(t){return this.l(t)+"continue\n"},t.prototype["~"]=function(t){return"~"+this.build(t.left())},t.prototype["typeof"]=function(t){return this.l(t)+("typeof "+this.build(t.left()))},t.prototype.index=function(t){var e;return e=this.build(t.right()),b.any(t.children,function(t){return"object_init"===t.typeName()&&t.children.length>1})&&(e="{"+e+"}"),this.l(t)+(""+this.build(t.left())+"["+e+"]")},t.prototype["throw"]=function(t){return this.l(t)+("throw "+this.build(t.exception))},t.prototype["!"]=function(t){var e,n;for(n=t.left(),e=1;n.isA("!")&&(n=n.left());)++e;return 1&e&&n.isA("==","!=","===","!==","in","instanceof")?(n.negated=!n.negated,this.build(n)):this.l(t)+(""+(1&e?"not ":"!!")+this.build(n))},t.prototype["in"]=function(t){return this.binary_operator(t,"of")},t.prototype["+"]=function(t){return this.binary_operator(t,"+")},t.prototype["-"]=function(t){return this.binary_operator(t,"-")},t.prototype["*"]=function(t){return this.binary_operator(t,"*")},t.prototype["/"]=function(t){return this.binary_operator(t,"/")},t.prototype["%"]=function(t){return this.binary_operator(t,"%")},t.prototype[">"]=function(t){return this.binary_operator(t,">")},t.prototype["<"]=function(t){return this.binary_operator(t,"<")},t.prototype["&"]=function(t){return this.binary_operator(t,"&")},t.prototype["|"]=function(t){return this.binary_operator(t,"|")},t.prototype["^"]=function(t){return this.binary_operator(t,"^")},t.prototype["&&"]=function(t){return this.binary_operator(t,"and")},t.prototype["||"]=function(t){return this.binary_operator(t,"or")},t.prototype["<<"]=function(t){return this.binary_operator(t,"<<")},t.prototype["<="]=function(t){return this.binary_operator(t,"<=")},t.prototype[">>"]=function(t){return this.binary_operator(t,">>")},t.prototype[">="]=function(t){return this.binary_operator(t,">=")},t.prototype["==="]=function(t){return this.binary_operator(t,"is")},t.prototype["!=="]=function(t){return this.binary_operator(t,"isnt")},t.prototype[">>>"]=function(t){return this.binary_operator(t,">>>")},t.prototype["instanceof"]=function(t){return this.binary_operator(t,"instanceof")},t.prototype["=="]=function(t){return this.binary_operator(t,"is")},t.prototype["!="]=function(t){return this.binary_operator(t,"isnt")},t.prototype.binary_operator=function(){var t,e,n;t={is:"isnt","in":"not in",of:"not of","instanceof":"not instanceof"};for(e in t)_.call(t,e)&&(n=t[e],t[n]=e);return function(e,n){return e.negated&&(n=t[n]),this.l(e)+(""+this.build(e.left())+" "+n+" "+this.build(e.right()))}}(),t.prototype["--"]=function(t){return this.increment_decrement(t,"--")},t.prototype["++"]=function(t){return this.increment_decrement(t,"++")},t.prototype.increment_decrement=function(t,e){return t.postfix?this.l(t)+(""+this.build(t.left())+e):this.l(t)+(""+e+this.build(t.left()))},t.prototype["="]=function(t){var e;return e=null!=t.assignOp?o[t.assignOp]+"=":"=",this.l(t)+(""+this.build(t.left())+" "+e+" "+this.build(t.right()))},t.prototype[","]=function(t){var e,n=this;return e=b.map(t.children,function(t){return n.l(t)+n.build(t)+"\n"}),e.join("")},t.prototype.regexp=function(t){var e,n,r,i;return r=t.value.toString().match(/^\/(.*)\/([a-z]?)/),i=r[1],n=r[2],e=i[0]," "===e||"="===e?n.length>0?this.l(t)+("RegExp("+N(i)+', "'+n+'")'):this.l(t)+("RegExp("+N(i)+")"):this.l(t)+("/"+i+"/"+n)},t.prototype.string=function(t){return this.l(t)+N(t.value)},t.prototype.call=function(t){return 0===t.right().children.length?""+this.build(t.left())+"()"+this.l(t):""+this.build(t.left())+"("+this.build(t.right())+")"+this.l(t)},t.prototype.call_statement=function(t){var e;return e=this.build(t.left()),t.left().isA("function")&&(e=f(e)),0===t.right().children.length?""+e+"()"+this.l(t):""+e+" "+this.build(t.right())+this.l(t)},t.prototype.list=function(t,n){var r,i=this;return null==n&&(n={}),r=b.map(t.children,function(r){var o,s;return t.children.length>1&&(r.is_list_element=!0),n.array===!0&&t.children.length>0?(s=i[r.typeName()](r),o=new e(i,r),o.scope(s),o=g(o+e.INDENT),"object_init"===r.typeName()&&(o="{\n"+e.INDENT+e.INDENT+o+"\n"+e.INDENT+"}"),o):i.build(r)}),n.array===!0&&t.children.length>0?this.l(t)+("\n"+e.INDENT+r.join("\n"+e.INDENT)):this.l(t)+r.join(", ")},t.prototype["delete"]=function(t){var e,n=this;return e=b.map(t.children,function(t){return n.build(t)}),e=e.join(", "),this.l(t)+("delete "+e+"\n")},t.prototype["."]=function(t){var e,n,r;return e=this.build(t.left()),r=t.right(),r.property_accessor=!0,n=this.build(r),t.isThis&&t.isPrototype?this.l(t)+"@::":t.isThis?this.l(t)+("@"+n):t.isPrototype?this.l(t)+(""+e+"::"):t.left().isPrototype?this.l(t)+(""+e+n):this.l(t)+(""+e+"."+n)},t.prototype["try"]=function(t){var n,r=this;return n=new e,n.add("try"),n.scope(this.body(t.tryBlock)),b.each(t.catchClauses,function(t){return n.add(r.build(t))}),null!=t.finallyBlock&&(n.add("finally"),n.scope(this.body(t.finallyBlock))),this.l(t)+n},t.prototype["catch"]=function(t){var n,r;return n=this.body(t.block),0===g(n).length?"":(r=new e,null!=t.varName?r.add("catch "+t.varName):r.add("catch"),r.scope(this.body(t.block)),this.l(t)+r)},t.prototype["?"]=function(t){return this.l(t)+("(if "+this.build(t.left())+" then "+this.build(t.children[1])+" else "+this.build(t.children[2])+")")},t.prototype["for"]=function(t){var n;return n=new e,null!=t.setup&&n.add(""+this.build(t.setup)+"\n"),null!=t.condition?n.add("while "+this.build(t.condition)+"\n"):n.add("loop"),n.scope(this.body(t.body)),null!=t.update&&n.scope(this.body(t.update)),this.l(t)+n},t.prototype.for_in=function(t){var n;return n=new e,n.add("for "+this.build(t.iterator)+" of "+this.build(t.object)),n.scope(this.body(t.body)),this.l(t)+n},t.prototype["while"]=function(t){var n,r,i,o;return r=new e,i=t.positive?"while":"until",n=this.body(t.body),o=I(t.condition)?"loop":""+i+" "+this.build(t.condition),l(n)&&"loop"!==o?r.add(""+g(n)+e.INDENT+o+"\n"):(r.add(o),r.scope(n)),this.l(t)+r},t.prototype["do"]=function(t){var n;return n=new e,n.add("loop"),n.scope(this.body(t.body)),null!=t.condition&&n.scope("break unless "+this.build(t.condition)),this.l(t)+n},t.prototype["if"]=function(t){var n,r,i;return r=new e,i=t.positive?"if":"unless",n=this.body(t.thenPart),t.condition.parenthesized=!1,t.thenPart.isA("block")&&0===t.thenPart.children.length&&null==t.elsePart?(console.log(t.thenPart),r.add(""+this.build(t.condition)+"\n")):l(n)&&null==t.elsePart?r.add(""+g(n)+e.INDENT+i+" "+this.build(t.condition)+"\n"):(r.add(""+i+" "+this.build(t.condition)),r.scope(this.body(t.thenPart)),null!=t.elsePart&&("if"===t.elsePart.typeName()?r.add("else "+this.build(t.elsePart).toString()):(r.add(this.l(t.elsePart)+"else\n"),r.scope(this.body(t.elsePart))))),this.l(t)+r},t.prototype["switch"]=function(t){var n,r,i=this;return n=new e,n.add("switch "+this.build(t.discriminant)+"\n"),r=!1,b.each(t.cases,function(t){var e;return"default"===t.value?n.scope(i.l(t)+"else"):r===!0?n.add(i.l(t)+(", "+i.build(t.caseLabel)+"\n")):n.add(i.l(t)+(" when "+i.build(t.caseLabel))),0===i.body(t.statements).length?r=!0:(r=!1,n.add("\n"),n.scope(i.body(t.statements),2)),e=!1}),this.l(t)+n},t.prototype.existence_check=function(t){return this.l(t)+(""+this.build(t.left())+"?")},t.prototype.array_init=function(t){var e;return e={array:!0},0===t.children.length?this.l(t)+"[]":t.children.length>1?this.l(t)+("["+this.list(t,e)+"\n]"):this.l(t)+("["+this.list(t)+"]")},t.prototype.property_init=function(t){var e,n;return e=t.left(),n=t.right(),n.is_property_value=!0,""+this.property_identifier(e)+": "+this.build(n)},t.prototype.object_init=function(t,n){var r,i,o=this;return null==n&&(n={}),0===t.children.length?this.l(t)+"{}":1!==t.children.length||t.is_property_value||t.is_list_element?(i=b.map(t.children,function(t){return o.build(t)}),r=new e(this,t),r.scope(i.join("\n")),null!=n.brackets&&(r="{"+r+"}"),r):this.build(t.children[0])},t.prototype["function"]=function(t){var n,r,i,o=this;return r=new e,i=b.map(t.params,function(t){return t.constructor===String?o.id_param(t):o.build(t)}),t.name&&r.add(""+t.name+" = "),t.params.length>0?r.add("("+i.join(", ")+") ->"):r.add("->"),n=this.body(t.body),g(n).length>0?r.scope(n):r.add("\n"),this.l(t)+r},t.prototype["var"]=function(t){var e,n=this;return e=b.map(t.children,function(t){return""+T(t.value)+" = "+(null!=t.initializer?n.build(t.initializer):"undefined")}),this.l(t)+b.compact(e).join("\n")+"\n"},t.prototype.other=function(t){return this.unsupported(t,""+t.typeName()+" is not supported yet")},t.prototype.getter=function(t){return this.unsupported(t,"getter syntax is not supported; use __defineGetter__")},t.prototype.setter=function(t){return this.unsupported(t,"setter syntax is not supported; use __defineSetter__")},t.prototype.label=function(t){return this.unsupported(t,"labels are not supported by CoffeeScript")},t.prototype["const"]=function(t){return this.unsupported(t,"consts are not supported by CoffeeScript")},t.prototype.block=function(){var t;return t=1<=arguments.length?x.call(arguments,0):[],this.script.apply(this,t)},t.prototype.unsupported=function(t,e){throw new s("Unsupported: "+e,t)},t}(),r=function(){function t(){}return t.prototype.transform=function(){var t,e,n,r;return t=1<=arguments.length?x.call(arguments,0):[],n=t[0],null==n.transformed?(r=n.typeName(),e=this[r],e?(e.apply(this,t),n.transformed=!0):void 0):void 0},t.prototype.script=function(t){var e;return t.functions=[],t.nonfunctions=[],b.each(t.children,function(e){return e.isA("function")?t.functions.push(e):t.nonfunctions.push(e)}),e=null,b.each(t.nonfunctions,function(t){var n;return null!=t.expression?(n=t.expression,t.parenthesized=(null!=e?e.isA("object_init"):void 0)&&n.isA("object_init")?!0:!1,e=n):void 0})},t.prototype["."]=function(t){return t.isThis=t.left().isA("this"),t.isPrototype=t.right().isA("identifier")&&"prototype"===t.right().value},t.prototype[";"]=function(t){return null!=t.expression&&(t.expression.parenthesized=!1,t.expression.isA("call"))?(t.expression.type=i.call_statement,this.call_statement(t)):void 0},t.prototype["function"]=function(t){return t.body.walk({last:!0},function(t,e,n){var r;return e.isA("return")&&e.value&&(r=n?t[n]:t.children[t.children.length-1])?(r.type=i[";"],r.expression=r.value):void 0})},t.prototype["switch"]=function(t){return b.each(t.cases,function(t){var e,n,r;return e=t.statements,n=e.children,(null!=(r=e.last())?r.isA("break"):void 0)?delete n[n.length-1]:void 0})},t.prototype.call_statement=function(t){return t.children[1]?b.each(t.children[1].children,function(e,n){return e.isA("function")&&n!==t.children[1].children.length-1?e.parenthesized=!0:void 0}):void 0},t.prototype["return"]=function(t){return t.value&&t.value.isA("object_init")&&t.value.children.length>1?t.value.parenthesized=!0:void 0},t.prototype.block=function(t){return this.script(t)},t.prototype["if"]=function(t){var e;return 0===t.thenPart.children.length&&(null!=(e=t.elsePart)?e.children.length:void 0)>0&&(t.positive=!1,t.thenPart=t.elsePart,delete t.elsePart),this.inversible(t)},t.prototype["while"]=function(t){return 0===t.body.children.length&&t.body.children.push(t.clone({type:i["continue"],value:"continue",children:[]})),this.inversible(t)},t.prototype.inversible=function(t){var e;return this.transform(t.condition),e=null!=t.positive?t.positive:!0,t.condition.isA("!=")?(t.condition.type=i["=="],t.positive=!e):t.condition.isA("!")?(t.condition=t.condition.left(),t.positive=!e):t.positive=e},t.prototype["=="]=function(t){return t.right().isA("null","void")?(t.type=i["!"],t.children=[t.clone({type:i.existence_check,children:[t.left()]})]):void 0},t.prototype["!="]=function(t){return t.right().isA("null","void")?(t.type=i.existence_check,t.children=[t.left()]):void 0},t}(),s=function(){function t(t,e){this.message=t,this.cursor=e.start,this.line=e.lineno,this.source=e.tokenizer.source}return t.prototype.toString=function(){return this.message},t}(),this.Js2coffee=c={VERSION:"0.1.3",build:u,UnsupportedError:s},"undefined"!=typeof module&&null!==module&&(module.exports=c)}.call(this);
(function() {
var BANNER, SWITCHES, UnsupportedError, batch, cmd, compileFromStdin, compilePath, compileScript, encoding, fileUtil, fsUtil, hidden, js2coffee, options, optparse, parseOptions, pathUtil, sources, tty, usage, version, writeFile;
var BANNER, UnsupportedError, batch, cmd, compileFromStdin, compilePath, compileScript, description, encoding, fileUtil, fsUtil, hidden, inspect, js2coffee, knownOpts, nopt, options, parseOptions, pathUtil, shortHands, sources, tty, usage, version, writeFile;

@@ -14,8 +14,36 @@ js2coffee = require('./js2coffee');

optparse = require('./optparse');
inspect = require('util').inspect;
nopt = require('nopt');
BANNER = "Usage: js2coffee [options] path/to/script.js\n\n js2coffee file.js\n js2coffee file.js > output.coffee\n cat file.js | js2coffee";
SWITCHES = [['-v', '--version', 'Show js2coffee version'], ['-V', '--verbose', 'Be verbose'], ['-X', '--no_comments', 'Do not translate comments'], ['-l', '--show_src_lineno', 'Show src lineno\'s as comments'], ['-h', '--help', 'If you need help']];
knownOpts = {
version: Boolean,
verbose: Boolean,
no_comments: Boolean,
show_src_lineno: Boolean,
help: Boolean,
indent: String
};
shortHands = {
v: ["--version"],
V: ["--verbose"],
X: ["--no_comments"],
l: ["--show_src_lineno"],
h: ["--help"],
i4: ["--indent", " "],
it: ["--indent", "\t"]
};
description = {
'version': 'Show js2coffee version',
'verbose': 'Be verbose',
'no_comments': 'Do not translate comments',
'show_src_lineno': 'Show src lineno\'s as comments',
'help': 'If you need help',
'indent': 'Specify the indent character(s) - default 2 spaces'
};
options = {};

@@ -32,6 +60,13 @@

parseOptions = function() {
var optionParser;
optionParser = new optparse.OptionParser(SWITCHES, BANNER);
options = optionParser.parse(process.argv.slice(2));
return sources = options["arguments"];
var index, _base;
options = nopt(knownOpts, shortHands, process.argv, 2);
sources = (_base = options.argv).remain || (_base.remain = []);
if (options.no_comments === true && options.show_src_lineno === true) {
console.warn("You cannot combine -l and -X");
return process.exit(1);
}
index = options.argv.cooked.indexOf("--indent");
if (index !== -1 && options.argv.cooked.length >= index) {
return options.indent = options.argv.cooked[index + 1];
}
};

@@ -56,3 +91,3 @@

if (options.verbose) {
console.warn("writing %s ", newFile);
console.log("writing %s ", newFile);
}

@@ -62,3 +97,3 @@ return fsUtil.writeFileSync(newFile, coffee, encoding);

e = _error;
return console.warn(e);
return console.error(e);
}

@@ -78,3 +113,3 @@ };

if (options.verbose) {
console.warn("read file %s", readf);
console.log("read file %s", readf);
}

@@ -89,3 +124,3 @@ contents = fsUtil.readFileSync(readf, encoding);

e = _error;
_results.push(console.warn(e));
_results.push(console.error(e));
}

@@ -193,3 +228,16 @@ }

usage = function() {
console.warn((new optparse.OptionParser(SWITCHES, BANNER)).help());
var arg, long, short;
console.warn(BANNER + "\n");
console.warn("options:");
for (arg in knownOpts) {
console.warn("--" + arg + " # " + description[arg]);
}
console.warn("\nshorcuts:");
for (short in shortHands) {
long = shortHands[short];
if (short === '___singles') {
continue;
}
console.warn("-" + short + " = " + (inspect(long)));
}
return process.exit(0);

@@ -196,0 +244,0 @@ };

@@ -22,2 +22,5 @@ (function() {

str += "\n";
if (opts.indent != null) {
Code.INDENT = opts.indent;
}
builder = new Builder(opts);

@@ -24,0 +27,0 @@ scriptNode = parser.parse(str);

{
"name": "js2coffee",
"version": "0.2.0",
"version": "0.2.1",
"description": "JavaScript to CoffeeScript compiler",

@@ -43,3 +43,4 @@ "homepage": "http://ricostacruz.com/js2coffee",

"joe": "~1.3.0",
"joe-reporter-console": "~1.2.1"
"joe-reporter-console": "~1.2.1",
"nopt": "~2.1.1"
},

@@ -46,0 +47,0 @@ "directories": {

@@ -24,3 +24,16 @@ # Js2Coffee

## API Usage
### build(content, option) ###
- **content** String - javascript source code
- **option** Object - option object
- **no_comments** Boolean - ignore comments, if true
- **show_src_lineno** Boolean - show source line numbers in each line as comment, if true
- **indent** String - specify indent
``` javascript
js2coffee = require('js2coffee');
coffeeContent = js2coffee.build(jstContent, {show_src_lineno: true, indent: " ");
```
## Development

@@ -27,0 +40,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc