From 90f2fad8ea3c9f74fb4e34acd0d7da243a6ff901 Mon Sep 17 00:00:00 2001 From: Mark Vayngrib Date: Tue, 31 Oct 2023 14:36:46 +0800 Subject: [PATCH] chore: refactor arrows in comments --- lib/ast.js | 4 ++-- lib/compress.js | 16 ++++++++-------- lib/output.js | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/ast.js b/lib/ast.js index 2bebe7e0..b049321e 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -304,7 +304,7 @@ var AST_With = DEFNODE("With", "expression", { var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent_scope enclosed cname", { $documentation: "Base class for all statements introducing a lexical scope", $propdoc: { - variables: "[Object/S] a map of name -> SymbolDef for all variables/functions defined in this scope", + variables: "[Object/S] a map of name ---> SymbolDef for all variables/functions defined in this scope", functions: "[Object/S] like `variables`, but only lists function declarations", uses_with: "[boolean/S] tells whether this scope uses the `with` statement", uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`", @@ -331,7 +331,7 @@ var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent var AST_Toplevel = DEFNODE("Toplevel", "globals", { $documentation: "The toplevel scope", $propdoc: { - globals: "[Object/S] a map of name -> SymbolDef for all undeclared names", + globals: "[Object/S] a map of name ---> SymbolDef for all undeclared names", }, wrap_commonjs: function(name) { var body = this.body; diff --git a/lib/compress.js b/lib/compress.js index 886a4b5b..722708b6 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1625,7 +1625,7 @@ merge(Compressor.prototype, { var value = stat.body.value; //--- // pretty silly case, but: - // if (foo()) return; return; ==> foo(); return; + // if (foo()) return; return; ---> foo(); return; if (!value && !stat.alternative && (in_lambda && !next || next instanceof AST_Return && !next.value)) { CHANGED = true; @@ -1635,7 +1635,7 @@ merge(Compressor.prototype, { continue; } //--- - // if (foo()) return x; return y; ==> return foo() ? x : y; + // if (foo()) return x; return y; ---> return foo() ? x : y; if (value && !stat.alternative && next instanceof AST_Return && next.value) { CHANGED = true; stat = stat.clone(); @@ -1645,7 +1645,7 @@ merge(Compressor.prototype, { continue; } //--- - // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined; + // if (foo()) return x; [ return ; ] ---> return foo() ? x : undefined; if (value && !stat.alternative && (!next && in_lambda && multiple_if_returns || next instanceof AST_Return)) { @@ -1659,7 +1659,7 @@ merge(Compressor.prototype, { continue; } //--- - // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e; + // if (a) return b; if (c) return d; e; ---> return a ? b : c ? d : void e; // // if sequences is not enabled, this can lead to an endless loop (issue #866). // however, with sequences on this helps producing slightly better output for @@ -4992,7 +4992,7 @@ merge(Compressor.prototype, { switch (self.operator) { case "!": if (e instanceof AST_UnaryPrefix && e.operator == "!") { - // !!foo ==> foo, if we're in boolean context + // !!foo ---> foo, if we're in boolean context return e.expression; } if (e instanceof AST_Binary) { @@ -5480,9 +5480,9 @@ merge(Compressor.prototype, { } } } - // x && (y && z) ==> x && y && z - // x || (y || z) ==> x || y || z - // x + ("y" + z) ==> x + "y" + z + // x && (y && z) ---> x && y && z + // x || (y || z) ---> x || y || z + // x + ("y" + z) ---> x + "y" + z // "x" + (y + "z")==> "x" + y + "z" if (self.right instanceof AST_Binary && self.right.operator == self.operator diff --git a/lib/output.js b/lib/output.js index 01cd311d..c0bc58eb 100644 --- a/lib/output.js +++ b/lib/output.js @@ -761,13 +761,13 @@ function OutputStream(options) { var p = output.parent(); return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4) || p instanceof AST_Unary // !(foo, bar, baz) - || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8 - || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4 - || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2 - || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ] - || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2 + || p instanceof AST_Binary // 1 + (2, 3) + 4 ---> 8 + || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ---> b == 4 + || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ---> 2 + || p instanceof AST_Array // [ 1, (2, 3), 4 ] ---> [ 1, 3, 4 ] + || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ---> 2 || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30) - * ==> 20 (side effect, set a := 10 and b := 20) */ + * ---> 20 (side effect, set a := 10 and b := 20) */ || p instanceof AST_Arrow // x => (x, x) || p instanceof AST_DefaultAssign // x => (x = (0, function(){})) || p instanceof AST_Expansion // [...(a, b)]