diff --git a/lib/coffeescript/cake.js b/lib/coffeescript/cake.js index 710c5437d9..13fb0e7e06 100644 --- a/lib/coffeescript/cake.js +++ b/lib/coffeescript/cake.js @@ -27,11 +27,7 @@ if (!action) { [action, description] = [description, action]; } - return tasks[name] = { - name: name, - description: description, - action: action - }; + return tasks[name] = {name, description, action}; }, option: function(letter, flag, description) { return switches.push([letter, flag, description]); diff --git a/lib/coffeescript/coffeescript.js b/lib/coffeescript/coffeescript.js index 9d5be3fcc8..35f38ac13c 100644 --- a/lib/coffeescript/coffeescript.js +++ b/lib/coffeescript/coffeescript.js @@ -9,13 +9,9 @@ path = require('path'); - ({ - Lexer: Lexer - } = require('./lexer')); + ({Lexer} = require('./lexer')); - ({ - parser: parser - } = require('./parser')); + ({parser} = require('./parser')); helpers = require('./helpers'); @@ -63,10 +59,7 @@ exports.compile = compile = withPrettyErrors(function(code, options) { var currentColumn, currentLine, encoded, extend, filename, fragment, fragments, generateSourceMap, header, i, j, js, len, len1, map, merge, newLines, ref, ref1, sourceMapDataURI, sourceURL, token, tokens, v3SourceMap; - ({ - merge: merge, - extend: extend - } = helpers); + ({merge, extend} = helpers); options = extend({}, options); generateSourceMap = options.sourceMap || options.inlineMap || (options.filename == null); filename = options.filename || ''; @@ -139,7 +132,7 @@ } if (options.sourceMap) { return { - js: js, + js, sourceMap: map, v3SourceMap: JSON.stringify(v3SourceMap, null, 2) }; @@ -261,9 +254,9 @@ stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw; try { answer = compile(stripped, { - filename: filename, - sourceMap: sourceMap, - inlineMap: inlineMap, + filename, + sourceMap, + inlineMap, sourceFiles: [filename], literate: helpers.isLiterate(filename) }); @@ -302,13 +295,8 @@ parser.yy.parseError = function(message, arg) { var errorLoc, errorTag, errorText, errorToken, token, tokens; - ({ - token: token - } = arg); - ({ - errorToken: errorToken, - tokens: tokens - } = parser); + ({token} = arg); + ({errorToken, tokens} = parser); [errorTag, errorText, errorLoc] = errorToken; errorText = (function() { switch (false) { diff --git a/lib/coffeescript/command.js b/lib/coffeescript/command.js index 95558397dc..13478f4d86 100644 --- a/lib/coffeescript/command.js +++ b/lib/coffeescript/command.js @@ -13,14 +13,9 @@ CoffeeScript = require('./coffeescript'); - ({ - spawn: spawn, - exec: exec - } = require('child_process')); + ({spawn, exec} = require('child_process')); - ({ - EventEmitter: EventEmitter - } = require('events')); + ({EventEmitter} = require('events')); useWinPathSep = path.sep === '\\'; @@ -208,11 +203,7 @@ o = opts; options = compileOptions(file, base); try { - t = task = { - file: file, - input: input, - options: options - }; + t = task = {file, input, options}; CoffeeScript.emit('compile', task); if (o.tokens) { return printTokens(CoffeeScript.tokens(t.input, t.options)); @@ -551,7 +542,7 @@ compileOptions = function(filename, base) { var answer, cwd, jsDir, jsPath; answer = { - filename: filename, + filename, literate: opts.literate || helpers.isLiterate(filename), bare: opts.bare, header: opts.compile && !opts['no-header'], @@ -564,7 +555,7 @@ jsPath = outputPath(filename, base); jsDir = path.dirname(jsPath); answer = helpers.merge(answer, { - jsPath: jsPath, + jsPath, sourceRoot: path.relative(jsDir, cwd), sourceFiles: [path.relative(cwd, filename)], generatedFile: helpers.baseFileName(jsPath, false, useWinPathSep) diff --git a/lib/coffeescript/grammar.js b/lib/coffeescript/grammar.js index 8e7eee0d8e..f778dbb5b3 100644 --- a/lib/coffeescript/grammar.js +++ b/lib/coffeescript/grammar.js @@ -2,9 +2,7 @@ (function() { var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; - ({ - Parser: Parser - } = require('jison')); + ({Parser} = require('jison')); unwrap = /^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/; diff --git a/lib/coffeescript/helpers.js b/lib/coffeescript/helpers.js index 39c2da690e..134a74dbcb 100644 --- a/lib/coffeescript/helpers.js +++ b/lib/coffeescript/helpers.js @@ -201,12 +201,7 @@ if (!(this.code && this.location)) { return Error.prototype.toString.call(this); } - ({ - first_line: first_line, - first_column: first_column, - last_line: last_line, - last_column: last_column - } = this.location); + ({first_line, first_column, last_line, last_column} = this.location); if (last_line == null) { last_line = first_line; } diff --git a/lib/coffeescript/lexer.js b/lib/coffeescript/lexer.js index 99f2d2a696..b91efc1c1b 100644 --- a/lib/coffeescript/lexer.js +++ b/lib/coffeescript/lexer.js @@ -3,20 +3,9 @@ var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, HERE_JSTOKEN, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVALID_ESCAPE, INVERSES, JSTOKEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, isForFrom, isUnassignable, key, locationDataToString, repeat, starts, throwSyntaxError, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; - ({ - Rewriter: Rewriter, - INVERSES: INVERSES - } = require('./rewriter')); - - ({ - count: count, - starts: starts, - compact: compact, - repeat: repeat, - invertLiterate: invertLiterate, - locationDataToString: locationDataToString, - throwSyntaxError: throwSyntaxError - } = require('./helpers')); + ({Rewriter, INVERSES} = require('./rewriter')); + + ({count, starts, compact, repeat, invertLiterate, locationDataToString, throwSyntaxError} = require('./helpers')); exports.Lexer = Lexer = class Lexer { tokenize(code, opts = {}) { @@ -256,7 +245,7 @@ })(); heredoc = quote.length === 3; ({ - tokens: tokens, + tokens, index: end } = this.matchWithInterpolations(regex, quote)); $ = tokens.length - 1; @@ -283,9 +272,7 @@ if (indent) { indentRegex = RegExp(`\\n${indent}`, "g"); } - this.mergeInterpolationTokens(tokens, { - delimiter: delimiter - }, (value, i) => { + this.mergeInterpolationTokens(tokens, {delimiter}, (value, i) => { value = this.formatString(value); if (indentRegex) { value = value.replace(indentRegex, '\n'); @@ -299,9 +286,7 @@ return value; }); } else { - this.mergeInterpolationTokens(tokens, { - delimiter: delimiter - }, (value, i) => { + this.mergeInterpolationTokens(tokens, {delimiter}, (value, i) => { value = this.formatString(value); value = value.replace(SIMPLE_STRING_OMIT, function(match, offset) { if ((i === 0 && offset === 0) || (i === $ && offset + match.length === value.length)) { @@ -358,10 +343,7 @@ }); break; case !(match = this.matchWithInterpolations(HEREGEX, '///')): - ({ - tokens: tokens, - index: index - } = match); + ({tokens, index} = match); break; case !(match = REGEX.exec(this.chunk)): [regex, body, closed] = match; @@ -651,9 +633,7 @@ return this; } stack = []; - ({ - tokens: tokens - } = this); + ({tokens} = this); i = tokens.length; tokens[--i][0] = 'PARAM_END'; while (tok = tokens[--i]) { @@ -692,7 +672,7 @@ [strPart] = regex.exec(str); this.validateEscapes(strPart, { isRegex: delimiter.charAt(0) === '/', - offsetInChunk: offsetInChunk + offsetInChunk }); tokens.push(this.makeToken('NEOSTRING', strPart, offsetInChunk)); str = str.slice(strPart.length); @@ -703,7 +683,7 @@ [line, column] = this.getLineAndColumnFromChunk(offsetInChunk + 1); ({ tokens: nested, - index: index + index } = new Lexer().tokenize(str.slice(1), { line: line, column: column, @@ -738,7 +718,7 @@ lastToken[2].last_column -= 1; } return { - tokens: tokens, + tokens, index: offsetInChunk + delimiter.length }; } @@ -946,8 +926,8 @@ error(message, options = {}) { var first_column, first_line, location, ref, ref1; location = 'first_line' in options ? options : ([first_line, first_column] = this.getLineAndColumnFromChunk((ref = options.offset) != null ? ref : 0), { - first_line: first_line, - first_column: first_column, + first_line, + first_column, last_column: first_column + ((ref1 = options.length) != null ? ref1 : 1) - 1 }); return throwSyntaxError(message, location); diff --git a/lib/coffeescript/nodes.js b/lib/coffeescript/nodes.js index 05f3efc4cd..c076004cb2 100644 --- a/lib/coffeescript/nodes.js +++ b/lib/coffeescript/nodes.js @@ -6,28 +6,11 @@ Error.stackTraceLimit = 2e308; - ({ - Scope: Scope - } = require('./scope')); - - ({ - isUnassignable: isUnassignable, - JS_FORBIDDEN: JS_FORBIDDEN - } = require('./lexer')); - - ({ - compact: compact, - flatten: flatten, - extend: extend, - merge: merge, - del: del, - starts: starts, - ends: ends, - some: some, - addLocationDataFn: addLocationDataFn, - locationDataToString: locationDataToString, - throwSyntaxError: throwSyntaxError - } = require('./helpers')); + ({Scope} = require('./scope')); + + ({isUnassignable, JS_FORBIDDEN} = require('./lexer')); + + ({compact, flatten, extend, merge, del, starts, ends, some, addLocationDataFn, locationDataToString, throwSyntaxError} = require('./helpers')); exports.extend = extend; @@ -588,9 +571,7 @@ this.expressions = rest; } post = this.compileNode(o); - ({ - scope: scope - } = o); + ({scope} = o); if (scope.expressions === this) { declars = o.scope.hasDeclarations(); assigns = scope.hasAssignments; @@ -1239,10 +1220,7 @@ } this.inCtor = !!method.ctor; if (!(this.inCtor || (this.accessor != null))) { - ({ - name: name, - variable: variable - } = method); + ({name, variable} = method); if (name.shouldCache() || (name instanceof Index && name.index.isAssignable())) { nref = new IdentifierLiteral(o.scope.parent.freeVariable('name')); name.index = new Assign(nref, name.index); @@ -1469,10 +1447,7 @@ compileNode(o) { var compiled, compiledText, from, fromCompiled, to, toStr; - ({ - to: to, - from: from - } = this.range); + ({to, from} = this.range); fromCompiled = from && from.compileToFragments(o, LEVEL_PAREN) || [this.makeCode('0')]; if (to) { compiled = to.compileToFragments(o, LEVEL_PAREN); @@ -1516,7 +1491,7 @@ } compileNode(o) { - var answer, i, idt, indent, j, join, k, key, lastNoncom, len1, len2, node, prop, props, value; + var answer, i, idt, indent, isCompact, j, join, k, key, l, lastNoncom, len1, len2, len3, node, prop, props, ref1, value; props = this.properties; if (this.generated) { for (j = 0, len1 = props.length; j < len1; j++) { @@ -1528,12 +1503,20 @@ } idt = o.indent += TAB; lastNoncom = this.lastNonComment(this.properties); + isCompact = true; + ref1 = this.properties; + for (k = 0, len2 = ref1.length; k < len2; k++) { + prop = ref1[k]; + if (prop instanceof Assign || prop instanceof Comment) { + isCompact = false; + } + } answer = []; - answer.push(this.makeCode(`{${(props.length === 0 ? '}' : '\n')}`)); - for (i = k = 0, len2 = props.length; k < len2; i = ++k) { + answer.push(this.makeCode(`{${(isCompact ? '' : '\n')}`)); + for (i = l = 0, len3 = props.length; l < len3; i = ++l) { prop = props[i]; - join = i === props.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n'; - indent = prop instanceof Comment ? '' : idt; + join = i === props.length - 1 ? '' : isCompact ? ', ' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n'; + indent = isCompact || prop instanceof Comment ? '' : idt; if (prop instanceof Assign) { if (prop.context !== 'object') { prop.operatorToken.error(`unexpected ${prop.operatorToken.value}`); @@ -1552,7 +1535,7 @@ key = new PropertyName(key.value); } prop = new Assign(key, value, 'object'); - } else { + } else if (!(typeof prop.bareLiteral === "function" ? prop.bareLiteral(IdentifierLiteral) : void 0)) { prop = new Assign(prop, prop, 'object'); } } @@ -1564,9 +1547,7 @@ answer.push(this.makeCode(join)); } } - if (props.length !== 0) { - answer.push(this.makeCode(`\n${this.tab}}`)); - } + answer.push(this.makeCode(`${(isCompact ? '' : `\n${this.tab}`)}}`)); if (this.front) { return this.wrapInBraces(answer); } else { @@ -1728,9 +1709,7 @@ } } if (this.variable) { - assign = new Assign(this.variable, new Literal(''), null, { - moduleDeclaration: this.moduleDeclaration - }); + assign = new Assign(this.variable, new Literal(''), null, {moduleDeclaration: this.moduleDeclaration}); return [...assign.compileToFragments(o), ...result]; } else { return result; @@ -1800,17 +1779,13 @@ this.boundMethods = []; executableBody = null; initializer = []; - ({ - expressions: expressions - } = this.body); + ({expressions} = this.body); i = 0; ref1 = expressions.slice(); for (j = 0, len1 = ref1.length; j < len1; j++) { expression = ref1[j]; if (expression instanceof Value && expression.isObject(true)) { - ({ - properties: properties - } = expression.base); + ({properties} = expression.base); exprs = []; end = 0; start = 0; @@ -1899,7 +1874,7 @@ addInitializerMethod(assign) { var method, methodName, variable; ({ - variable: variable, + variable, value: method } = assign); method.isMethod = true; @@ -2337,12 +2312,7 @@ this.variable = variable1; this.value = value1; this.context = context1; - ({ - param: this.param, - subpattern: this.subpattern, - operatorToken: this.operatorToken, - moduleDeclaration: this.moduleDeclaration - } = options); + ({param: this.param, subpattern: this.subpattern, operatorToken: this.operatorToken, moduleDeclaration: this.moduleDeclaration} = options); } isStatement(o) { @@ -2438,12 +2408,8 @@ compilePatternMatch(o) { var acc, assigns, code, defaultValue, expandedIdx, fragments, i, idx, isObject, ivar, j, len1, message, name, obj, objects, olen, ref, rest, top, val, value, vvar, vvarText; top = o.level === LEVEL_TOP; - ({ - value: value - } = this); - ({ - objects: objects - } = this.variable.base); + ({value} = this); + ({objects} = this.variable.base); if (!(olen = objects.length)) { code = value.compileToFragments(o); if (o.level >= LEVEL_OP) { @@ -2613,11 +2579,7 @@ compileSplice(o) { var answer, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef; ({ - range: { - from: from, - to: to, - exclusive: exclusive - } + range: {from, to, exclusive} } = this.variable.properties.pop()); name = this.variable.compile(o); if (from) { @@ -3150,9 +3112,7 @@ jumps() { var expressions, j, jumpNode, len1, node; - ({ - expressions: expressions - } = this.body); + ({expressions} = this.body); if (!expressions.length) { return false; } @@ -3171,9 +3131,7 @@ var answer, body, rvar, set; o.indent += TAB; set = ''; - ({ - body: body - } = this); + ({body} = this); if (body.isEmpty()) { body = this.makeCode(''); } else { @@ -3772,13 +3730,7 @@ constructor(body, source) { var ref1, ref2; super(); - ({ - source: this.source, - guard: this.guard, - step: this.step, - name: this.name, - index: this.index - } = source); + ({source: this.source, guard: this.guard, step: this.step, name: this.name, index: this.index} = source); this.body = Block.wrap([body]); this.own = !!source.own; this.object = !!source.object; @@ -3857,7 +3809,7 @@ if (this.range) { forPartFragments = source.compileToFragments(merge(o, { index: ivar, - name: name, + name, step: this.step, shouldCache: shouldCacheOrIsAssignable })); @@ -4063,9 +4015,7 @@ this.condition = options.type === 'unless' ? condition.invert() : condition; this.elseBody = null; this.isChain = false; - ({ - soak: this.soak - } = options); + ({soak: this.soak} = options); } bodyNode() { @@ -4135,9 +4085,7 @@ } indent = o.indent + TAB; cond = this.condition.compileToFragments(o, LEVEL_PAREN); - body = this.ensureBlock(this.body).compileToFragments(merge(o, { - indent: indent - })); + body = this.ensureBlock(this.body).compileToFragments(merge(o, {indent})); ifPart = [].concat(this.makeCode("if ("), cond, this.makeCode(") {\n"), body, this.makeCode(`\n${this.tab}}`)); if (!child) { ifPart.unshift(this.makeCode(this.tab)); @@ -4150,9 +4098,7 @@ o.chainChild = true; answer = answer.concat(this.elseBody.unwrap().compileToFragments(o, LEVEL_TOP)); } else { - answer = answer.concat(this.makeCode("{\n"), this.elseBody.compileToFragments(merge(o, { - indent: indent - }), LEVEL_TOP), this.makeCode(`\n${this.tab}}`)); + answer = answer.concat(this.makeCode("{\n"), this.elseBody.compileToFragments(merge(o, {indent}), LEVEL_TOP), this.makeCode(`\n${this.tab}}`)); } return answer; } @@ -4221,9 +4167,7 @@ utility = function(name, o) { var ref, root; - ({ - root: root - } = o.scope); + ({root} = o.scope); if (name in root.utilities) { return root.utilities[name]; } else { diff --git a/lib/coffeescript/optparse.js b/lib/coffeescript/optparse.js index fb4998c4a6..dbd707953f 100644 --- a/lib/coffeescript/optparse.js +++ b/lib/coffeescript/optparse.js @@ -2,9 +2,7 @@ (function() { var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat; - ({ - repeat: repeat - } = require('./helpers')); + ({repeat} = require('./helpers')); exports.OptionParser = OptionParser = class OptionParser { constructor(rules, banner) { diff --git a/lib/coffeescript/register.js b/lib/coffeescript/register.js index 7b0a2f9930..bc759db22a 100644 --- a/lib/coffeescript/register.js +++ b/lib/coffeescript/register.js @@ -48,9 +48,7 @@ } if (child_process) { - ({ - fork: fork - } = child_process); + ({fork} = child_process); binary = require.resolve('../../bin/coffee'); child_process.fork = function(path, args, options) { if (helpers.isCoffee(path)) { diff --git a/lib/coffeescript/repl.js b/lib/coffeescript/repl.js index dfbbdaeff9..0c299bedf0 100644 --- a/lib/coffeescript/repl.js +++ b/lib/coffeescript/repl.js @@ -12,10 +12,7 @@ CoffeeScript = require('./coffeescript'); - ({ - merge: merge, - updateSyntaxError: updateSyntaxError - } = require('./helpers')); + ({merge, updateSyntaxError} = require('./helpers')); replDefaults = { prompt: 'coffee> ', @@ -26,12 +23,7 @@ input = input.replace(/\uFF00/g, '\n'); input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1'); input = input.replace(/^\s*try\s*{([\s\S]*)}\s*catch.*$/m, '$1'); - ({ - Block: Block, - Assign: Assign, - Value: Value, - Literal: Literal - } = require('./nodes')); + ({Block, Assign, Value, Literal} = require('./nodes')); try { tokens = CoffeeScript.tokens(input); referencedVars = (function() { @@ -50,7 +42,7 @@ js = ast.compile({ bare: true, locals: Object.keys(context), - referencedVars: referencedVars + referencedVars }); return cb(null, runInContext(js, context, filename)); } catch (error) { @@ -71,11 +63,7 @@ addMultilineHandler = function(repl) { var inputStream, multiline, nodeLineListener, origPrompt, outputStream, ref, rli; - ({ - rli: rli, - inputStream: inputStream, - outputStream: outputStream - } = repl); + ({rli, inputStream, outputStream} = repl); origPrompt = (ref = repl._prompt) != null ? ref : repl.prompt; multiline = { enabled: false, diff --git a/lib/coffeescript/rewriter.js b/lib/coffeescript/rewriter.js index f629ece855..938da10920 100644 --- a/lib/coffeescript/rewriter.js +++ b/lib/coffeescript/rewriter.js @@ -30,9 +30,7 @@ scanTokens(block) { var i, token, tokens; - ({ - tokens: tokens - } = this); + ({tokens} = this); i = 0; while (token = tokens[i]) { i += block.call(this, token, i, tokens); @@ -42,9 +40,7 @@ detectEnd(i, condition, action) { var levels, ref, ref1, token, tokens; - ({ - tokens: tokens - } = this); + ({tokens} = this); levels = 0; while (token = tokens[i]) { if (levels === 0 && condition.call(this, token, i)) { @@ -320,12 +316,7 @@ newLine = prevTag === 'OUTDENT' || prevToken.newLine; if (indexOf.call(IMPLICIT_END, tag) >= 0 || indexOf.call(CALL_CLOSERS, tag) >= 0 && newLine) { while (inImplicit()) { - [ - stackTag, stackIdx, { - sameLine: sameLine, - startsLine: startsLine - } - ] = stackTop(); + [stackTag, stackIdx, {sameLine, startsLine}] = stackTop(); if (inImplicitCall() && prevTag !== ',') { endImplicitCall(); } else if (inImplicitObject() && !this.insideForDeclaration && sameLine && tag !== 'TERMINATOR' && prevTag !== ':') { diff --git a/lib/coffeescript/scope.js b/lib/coffeescript/scope.js index c8e823ca31..87a4938443 100644 --- a/lib/coffeescript/scope.js +++ b/lib/coffeescript/scope.js @@ -30,10 +30,7 @@ if (Object.prototype.hasOwnProperty.call(this.positions, name)) { return this.variables[this.positions[name]].type = type; } else { - return this.positions[name] = this.variables.push({ - name: name, - type: type - }) - 1; + return this.positions[name] = this.variables.push({name, type}) - 1; } } @@ -110,7 +107,7 @@ assign(name, value) { this.add(name, { - value: value, + value, assigned: true }, true); return this.hasAssignments = true; diff --git a/lib/coffeescript/sourcemap.js b/lib/coffeescript/sourcemap.js index 98c898d56f..659fb5cd20 100644 --- a/lib/coffeescript/sourcemap.js +++ b/lib/coffeescript/sourcemap.js @@ -19,9 +19,9 @@ } return this.columns[column] = { line: this.line, - column: column, - sourceLine: sourceLine, - sourceColumn: sourceColumn + column, + sourceLine, + sourceColumn }; } diff --git a/src/nodes.coffee b/src/nodes.coffee index 4c5ab47584..5f55de8d69 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1128,16 +1128,22 @@ exports.Obj = class Obj extends Base node.error 'cannot have an implicit value in an implicit object' idt = o.indent += TAB lastNoncom = @lastNonComment @properties + + isCompact = true + isCompact = false for prop in @properties when prop instanceof Assign or prop instanceof Comment + answer = [] - answer.push @makeCode "{#{if props.length is 0 then '}' else '\n'}" + answer.push @makeCode "{#{if isCompact then '' else '\n'}" for prop, i in props join = if i is props.length - 1 '' + else if isCompact + ', ' else if prop is lastNoncom or prop instanceof Comment '\n' else ',\n' - indent = if prop instanceof Comment then '' else idt + indent = if isCompact or prop instanceof Comment then '' else idt if prop instanceof Assign if prop.context isnt 'object' prop.operatorToken.error "unexpected #{prop.operatorToken.value}" @@ -1150,12 +1156,12 @@ exports.Obj = class Obj extends Base [key, value] = prop.base.cache o key = new PropertyName key.value if key instanceof IdentifierLiteral prop = new Assign key, value, 'object' - else + else if not prop.bareLiteral?(IdentifierLiteral) prop = new Assign prop, prop, 'object' if indent then answer.push @makeCode indent answer.push prop.compileToFragments(o, LEVEL_TOP)... if join then answer.push @makeCode join - answer.push @makeCode "\n#{@tab}}" unless props.length is 0 + answer.push @makeCode "#{if isCompact then '' else "\n#{@tab}"}}" if @front then @wrapInBraces answer else answer assigns: (name) ->