How to use terser method in Best

Best JavaScript code snippet using best

arrow.js

Source:arrow.js Github

copy

Full Screen

1var assert = require("assert");2var terser = require("../node");3describe("Arrow functions", function() {4 it.skip("Should not accept spread tokens on non-last parameters or without arguments parentheses", function() {5 var tests = [6 "var a = ...a => {return a.join()}",7 "var b = (a, ...b, c) => { return a + b.join() + c}",8 "var c = (...a, b) => a.join()"9 ];10 var test = function(code) {11 return function() {12 terser.parse(code);13 };14 };15 var error = function(e) {16 return e instanceof terser._JS_Parse_Error &&17 e.message === "Unexpected token: expand (...)";18 };19 for (var i = 0; i < tests.length; i++) {20 assert.throws(test(tests[i]), error);21 }22 });23 it("Should not accept holes in object binding patterns, while still allowing a trailing elision", function() {24 var tests = [25 "f = ({, , ...x} = [1, 2]) => {};"26 ];27 var test = function(code) {28 return function() {29 terser.parse(code);30 };31 };32 var error = function(e) {33 return e instanceof terser._JS_Parse_Error &&34 e.message === "Unexpected token: punc (,)";35 };36 for (var i = 0; i < tests.length; i++) {37 assert.throws(test(tests[i]), error);38 }39 });40 it("Should not accept newlines before arrow token", function() {41 var tests = [42 "f = foo\n=> 'foo';",43 "f = (foo, bar)\n=> 'foo';",44 "f = ()\n=> 'foo';",45 "foo((bar)\n=>'baz';);"46 ];47 var test = function(code) {48 return function() {49 terser.parse(code);50 };51 };52 var error = function(e) {53 return e instanceof terser._JS_Parse_Error &&54 e.message === "Unexpected newline before arrow (=>)";55 };56 for (var i = 0; i < tests.length; i++) {57 assert.throws(test(tests[i]), error);58 }59 });60 it("Should not accept arrow functions in the middle or end of an expression", function() {61 [62 "0 + x => 0",63 "0 + async x => 0",64 "typeof x => 0",65 "typeof async x => 0",66 "typeof (x) => null",67 "typeof async (x) => null",68 ].forEach(function(code) {69 assert.throws(function() {70 terser.parse(code);71 }, function(e) {72 return e instanceof terser._JS_Parse_Error && /^Unexpected /.test(e.message);73 }, code);74 });75 });76 it("Should parse a function containing default assignment correctly", function() {77 var ast = terser.parse("var a = (a = 123) => {}");78 assert(ast.body[0] instanceof terser.AST_Var);79 assert.strictEqual(ast.body[0].definitions.length, 1);80 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);81 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);82 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);83 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);84 // First argument85 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_DefaultAssign);86 assert(ast.body[0].definitions[0].value.argnames[0].left instanceof terser.AST_SymbolFunarg);87 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].operator, "=");88 assert(ast.body[0].definitions[0].value.argnames[0].right instanceof terser.AST_Number);89 ast = terser.parse("var a = (a = a) => {}");90 assert(ast.body[0] instanceof terser.AST_Var);91 assert.strictEqual(ast.body[0].definitions.length, 1);92 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);93 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);94 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);95 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);96 // First argument97 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_DefaultAssign);98 assert(ast.body[0].definitions[0].value.argnames[0].left instanceof terser.AST_SymbolFunarg);99 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].operator, "=");100 assert(ast.body[0].definitions[0].value.argnames[0].right instanceof terser.AST_SymbolRef);101 });102 it("Should parse a function containing default assignments in destructuring correctly", function() {103 var ast = terser.parse("var a = ([a = 123]) => {}");104 assert(ast.body[0] instanceof terser.AST_Var);105 assert.strictEqual(ast.body[0].definitions.length, 1);106 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);107 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);108 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);109 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);110 // First argument111 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);112 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, true);113 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names.length, 1);114 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_DefaultAssign);115 assert(ast.body[0].definitions[0].value.argnames[0].names[0].left instanceof terser.AST_SymbolFunarg);116 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].operator, "=");117 assert(ast.body[0].definitions[0].value.argnames[0].names[0].right instanceof terser.AST_Number);118 ast = terser.parse("var a = ({a = 123}) => {}");119 assert(ast.body[0] instanceof terser.AST_Var);120 assert.strictEqual(ast.body[0].definitions.length, 1);121 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);122 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);123 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);124 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);125 // First argument126 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);127 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, false);128 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names.length, 1);129 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_ObjectKeyVal);130 // First object element in first argument131 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].key, "a");132 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value instanceof terser.AST_DefaultAssign);133 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value.left instanceof terser.AST_SymbolFunarg);134 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].value.operator, "=");135 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value.right instanceof terser.AST_Number);136 ast = terser.parse("var a = ({a: a = 123}) => {}");137 assert(ast.body[0] instanceof terser.AST_Var);138 assert.strictEqual(ast.body[0].definitions.length, 1);139 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);140 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);141 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);142 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);143 // First argument144 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);145 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, false);146 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names.length, 1);147 // Content destructuring of first argument148 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_ObjectProperty);149 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].key, "a");150 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value instanceof terser.AST_DefaultAssign);151 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value.left instanceof terser.AST_SymbolFunarg);152 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].value.operator, "=");153 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value.right instanceof terser.AST_Number);154 });155 it("Should parse a function containing default assignments in complex destructuring correctly", function() {156 var ast = terser.parse("var a = ([a, [b = 123]]) => {}");157 assert(ast.body[0] instanceof terser.AST_Var);158 assert.strictEqual(ast.body[0].definitions.length, 1);159 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);160 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);161 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);162 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);163 // Check first argument164 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);165 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, true);166 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names.length, 2);167 // Check whole destructuring structure of first argument168 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_SymbolFunarg);169 assert(ast.body[0].definitions[0].value.argnames[0].names[1] instanceof terser.AST_Destructuring);170 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[1].is_array, true);171 // Check content of second destructuring element (which is the nested destructuring pattern)172 assert(ast.body[0].definitions[0].value.argnames[0].names[1].names[0] instanceof terser.AST_DefaultAssign);173 assert(ast.body[0].definitions[0].value.argnames[0].names[1].names[0].left instanceof terser.AST_SymbolFunarg);174 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[1].names[0].operator, "=");175 assert(ast.body[0].definitions[0].value.argnames[0].names[1].names[0].right instanceof terser.AST_Number);176 ast = terser.parse("var a = ([a, {b: c = 123}]) => {}");177 assert(ast.body[0] instanceof terser.AST_Var);178 assert.strictEqual(ast.body[0].definitions.length, 1);179 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);180 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);181 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);182 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);183 // Check first argument184 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);185 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, true);186 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names.length, 2);187 // Check whole destructuring structure of first argument188 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_SymbolFunarg);189 assert(ast.body[0].definitions[0].value.argnames[0].names[1] instanceof terser.AST_Destructuring);190 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[1].is_array, false);191 // Check content of second destructuring element (which is the nested destructuring pattern)192 assert(ast.body[0].definitions[0].value.argnames[0].names[1].names[0] instanceof terser.AST_ObjectKeyVal);193 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[1].names[0].key, "b");194 assert(ast.body[0].definitions[0].value.argnames[0].names[1].names[0].value instanceof terser.AST_DefaultAssign);195 assert(ast.body[0].definitions[0].value.argnames[0].names[1].names[0].value.left instanceof terser.AST_SymbolFunarg);196 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[1].names[0].value.operator, "=");197 assert(ast.body[0].definitions[0].value.argnames[0].names[1].names[0].value.right instanceof terser.AST_Number);198 ast = terser.parse("var a = ({a, b: {b = 123}}) => {}");199 assert(ast.body[0] instanceof terser.AST_Var);200 assert.strictEqual(ast.body[0].definitions.length, 1);201 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);202 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);203 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);204 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);205 // Check first argument206 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);207 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, false);208 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names.length, 2);209 // First argument, property 1210 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_ObjectKeyVal);211 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].key, "a");212 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value instanceof terser.AST_SymbolFunarg);213 // First argument, property 2214 assert(ast.body[0].definitions[0].value.argnames[0].names[1] instanceof terser.AST_ObjectKeyVal);215 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[1].key, "b");216 assert(ast.body[0].definitions[0].value.argnames[0].names[1].value instanceof terser.AST_Destructuring);217 // Check content of nested destructuring218 var content = ast.body[0].definitions[0].value.argnames[0].names[1].value;219 assert.strictEqual(content.is_array, false);220 assert.strictEqual(content.names.length, 1);221 assert(content.names[0] instanceof terser.AST_ObjectKeyVal);222 // Content of first property in nested destructuring223 assert.strictEqual(content.names[0].key, "b");224 assert(content.names[0].value instanceof terser.AST_DefaultAssign);225 assert(content.names[0].value.left instanceof terser.AST_SymbolFunarg);226 assert.strictEqual(content.names[0].value.operator, "=");227 assert(content.names[0].value.right instanceof terser.AST_Number);228 ast = terser.parse("var a = ({a: {b = 123}}) => {}");229 assert(ast.body[0] instanceof terser.AST_Var);230 assert.strictEqual(ast.body[0].definitions.length, 1);231 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);232 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);233 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);234 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);235 // Check first argument236 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);237 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, false);238 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names.length, 1);239 // Check whole destructuring structure of first argument240 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_ObjectKeyVal);241 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].key, "a");242 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value instanceof terser.AST_Destructuring);243 // Check content of nested destructuring244 content = ast.body[0].definitions[0].value.argnames[0].names[0].value;245 assert.strictEqual(content.is_array, false);246 assert.strictEqual(content.names.length, 1);247 assert(content.names[0] instanceof terser.AST_ObjectKeyVal);248 // Check first property of nested destructuring249 assert.strictEqual(content.names[0].key, "b");250 assert(content.names[0].value instanceof terser.AST_DefaultAssign);251 assert(content.names[0].value.left instanceof terser.AST_SymbolFunarg);252 assert.strictEqual(content.names[0].value.operator, "=");253 assert(content.names[0].value.right instanceof terser.AST_Number);254 });255 it("Should parse spread correctly", function() {256 var ast = terser.parse("var a = (a, b, ...c) => {}");257 assert(ast.body[0] instanceof terser.AST_Var);258 assert.strictEqual(ast.body[0].definitions.length, 1);259 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);260 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);261 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);262 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 3);263 // Check parameters264 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_SymbolFunarg);265 assert(ast.body[0].definitions[0].value.argnames[1] instanceof terser.AST_SymbolFunarg);266 assert(ast.body[0].definitions[0].value.argnames[2] instanceof terser.AST_Expansion);267 assert(ast.body[0].definitions[0].value.argnames[2].expression instanceof terser.AST_SymbolFunarg);268 ast = terser.parse("var a = ([a, b, ...c]) => {}");269 assert(ast.body[0] instanceof terser.AST_Var);270 assert.strictEqual(ast.body[0].definitions.length, 1);271 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);272 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);273 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);274 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);275 // Check first parameter276 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);277 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, true);278 // Check content first parameter279 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_SymbolFunarg);280 assert(ast.body[0].definitions[0].value.argnames[0].names[1] instanceof terser.AST_SymbolFunarg);281 assert(ast.body[0].definitions[0].value.argnames[0].names[2] instanceof terser.AST_Expansion);282 assert(ast.body[0].definitions[0].value.argnames[0].names[2].expression instanceof terser.AST_SymbolFunarg);283 ast = terser.parse("var a = ([a, b, [c, ...d]]) => {}");284 assert(ast.body[0] instanceof terser.AST_Var);285 assert.strictEqual(ast.body[0].definitions.length, 1);286 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);287 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);288 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);289 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);290 // Check first parameter291 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);292 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, true);293 // Check content outer destructuring array294 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_SymbolFunarg);295 assert(ast.body[0].definitions[0].value.argnames[0].names[1] instanceof terser.AST_SymbolFunarg);296 assert(ast.body[0].definitions[0].value.argnames[0].names[2] instanceof terser.AST_Destructuring);297 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[2].is_array, true);298 // Check content nested destructuring array299 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[2].names.length, 2);300 assert(ast.body[0].definitions[0].value.argnames[0].names[2].names[0] instanceof terser.AST_SymbolFunarg);301 assert(ast.body[0].definitions[0].value.argnames[0].names[2].names[1] instanceof terser.AST_Expansion);302 assert(ast.body[0].definitions[0].value.argnames[0].names[2].names[1].expression instanceof terser.AST_SymbolFunarg);303 ast = terser.parse("var a = ({a: [b, ...c]}) => {}");304 assert(ast.body[0] instanceof terser.AST_Var);305 assert.strictEqual(ast.body[0].definitions.length, 1);306 assert(ast.body[0].definitions[0] instanceof terser.AST_VarDef);307 assert(ast.body[0].definitions[0].name instanceof terser.AST_SymbolVar);308 assert(ast.body[0].definitions[0].value instanceof terser.AST_Arrow);309 assert.strictEqual(ast.body[0].definitions[0].value.argnames.length, 1);310 // Check first parameter311 assert(ast.body[0].definitions[0].value.argnames[0] instanceof terser.AST_Destructuring);312 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].is_array, false);313 // Check outer destructuring object314 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names.length, 1);315 assert(ast.body[0].definitions[0].value.argnames[0].names[0] instanceof terser.AST_ObjectKeyVal);316 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].key, "a");317 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value instanceof terser.AST_Destructuring);318 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].value.is_array, true);319 // Check content nested destructuring array320 assert.strictEqual(ast.body[0].definitions[0].value.argnames[0].names[0].value.names.length, 2);321 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value.names[0] instanceof terser.AST_SymbolFunarg);322 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value.names[1] instanceof terser.AST_Expansion);323 assert(ast.body[0].definitions[0].value.argnames[0].names[0].value.names[1].expression instanceof terser.AST_SymbolFunarg);324 });325 it("Should handle arrow function with bind", function() {326 function minify(code) {327 return terser.minify(code, {328 mangle: false329 }).code;330 }331 assert.strictEqual(332 minify(minify("test(((index) => { console.log(this, index); }).bind(this, 1));")),333 "test((index=>{console.log(this,index)}).bind(this,1));"334 );335 assert.strictEqual(336 minify(minify('test(((index) => { console.log(this, index); })["bind"](this, 1));')),337 "test((index=>{console.log(this,index)}).bind(this,1));"338 );339 });340 it("Should handle return of arrow function assignment", function() {341 function minify(code) {342 return terser.minify(code, {343 mangle:false344 }).code;345 }346 assert.strictEqual(347 minify("export function foo(x) { bar = () => x; return 2};"),348 "export function foo(x){return bar=()=>x,2}"349 );350 });...

Full Screen

Full Screen

lhs-expressions.js

Source:lhs-expressions.js Github

copy

Full Screen

1var assert = require("assert");2var terser = require("../node");3describe("Left-hand side expressions", function () {4 it("Should parse destructuring with const/let/var correctly", function () {5 var decls = terser.parse('var {a,b} = foo, { c, d } = bar');6 assert.equal(decls.body[0].TYPE, 'Var');7 assert.equal(decls.body[0].definitions.length, 2);8 // Item 19 assert.equal(decls.body[0].definitions[0].name.TYPE, 'Destructuring');10 assert.equal(decls.body[0].definitions[0].value.TYPE, 'SymbolRef');11 // Item 212 assert.equal(decls.body[0].definitions[1].name.TYPE, 'Destructuring');13 assert.equal(decls.body[0].definitions[1].value.TYPE, 'SymbolRef');14 var nested_def = terser.parse('var [{x}] = foo').body[0].definitions[0];15 assert.equal(nested_def.name.names[0].names[0].TYPE, 'ObjectKeyVal');16 assert.equal(nested_def.name.names[0].names[0].value.TYPE, 'SymbolVar');17 assert.equal(nested_def.name.names[0].names[0].key, 'x');18 assert.equal(nested_def.name.names[0].names[0].value.name, 'x');19 var holey_def = terser.parse('const [,,third] = [1,2,3]').body[0].definitions[0];20 assert.equal(holey_def.name.names[0].TYPE, 'Hole');21 assert.equal(holey_def.name.names[1].TYPE, 'Hole');22 assert.equal(holey_def.name.names[2].TYPE, 'SymbolConst');23 var expanding_def = terser.parse('var [first, ...rest] = [1,2,3]').body[0].definitions[0];24 assert.equal(expanding_def.name.names[0].TYPE, 'SymbolVar');25 assert.equal(expanding_def.name.names[1].TYPE, 'Expansion');26 assert.equal(expanding_def.name.names[1].expression.TYPE, 'SymbolVar');27 });28 it("Parser should use AST_Array for array literals", function() {29 var ast = terser.parse('["foo", "bar"]');30 assert(ast.body[0] instanceof terser.AST_SimpleStatement);31 assert(ast.body[0].body instanceof terser.AST_Array);32 ast = terser.parse('a = ["foo"]');33 assert(ast.body[0] instanceof terser.AST_SimpleStatement);34 assert(ast.body[0].body instanceof terser.AST_Assign);35 assert(ast.body[0].body.left instanceof terser.AST_SymbolRef);36 assert.equal(ast.body[0].body.operator, "=");37 assert(ast.body[0].body.right instanceof terser.AST_Array);38 });39 it("Parser should use AST_Object for object literals", function() {40 var ast = terser.parse('({foo: "bar"})');41 assert(ast.body[0] instanceof terser.AST_SimpleStatement);42 assert(ast.body[0].body instanceof terser.AST_Object);43 // This example should be fine though44 ast = terser.parse('a = {foo: "bar"}');45 assert(ast.body[0] instanceof terser.AST_SimpleStatement);46 assert(ast.body[0].body instanceof terser.AST_Assign);47 assert(ast.body[0].body.left instanceof terser.AST_SymbolRef);48 assert.equal(ast.body[0].body.operator, "=");49 assert(ast.body[0].body.right instanceof terser.AST_Object);50 });51 it("Parser should use AST_Destructuring for array assignment patterns", function() {52 var ast = terser.parse('[foo, bar] = [1, 2]');53 assert(ast.body[0] instanceof terser.AST_SimpleStatement);54 assert(ast.body[0].body instanceof terser.AST_Assign);55 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);56 assert.strictEqual(ast.body[0].body.left.is_array, true);57 assert.equal(ast.body[0].body.operator, "=");58 assert(ast.body[0].body.right instanceof terser.AST_Array);59 });60 it("Parser should use AST_Destructuring for object assignment patterns", function() {61 var ast = terser.parse('({a: b, b: c} = {b: "c", c: "d"})');62 assert(ast.body[0] instanceof terser.AST_SimpleStatement);63 assert(ast.body[0].body instanceof terser.AST_Assign);64 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);65 assert.strictEqual(ast.body[0].body.left.is_array, false);66 assert.equal(ast.body[0].body.operator, "=");67 assert(ast.body[0].body.right instanceof terser.AST_Object);68 });69 it("Parser should be able to handle nested destructuring", function() {70 var ast = terser.parse('[{a,b},[d, e, f, {g, h}]] = [{a: 1, b: 2}, [3, 4, 5, {g: 6, h: 7}]]');71 assert(ast.body[0] instanceof terser.AST_SimpleStatement);72 assert(ast.body[0].body instanceof terser.AST_Assign);73 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);74 assert.strictEqual(ast.body[0].body.left.is_array, true);75 assert.equal(ast.body[0].body.operator, "=");76 assert(ast.body[0].body.right instanceof terser.AST_Array);77 assert(ast.body[0].body.left.names[0] instanceof terser.AST_Destructuring);78 assert.strictEqual(ast.body[0].body.left.names[0].is_array, false);79 assert(ast.body[0].body.left.names[1] instanceof terser.AST_Destructuring);80 assert.strictEqual(ast.body[0].body.left.names[1].is_array, true);81 assert(ast.body[0].body.left.names[1].names[3] instanceof terser.AST_Destructuring);82 assert.strictEqual(ast.body[0].body.left.names[1].names[3].is_array, false);83 });84 it("Should handle spread operator in destructuring", function() {85 var ast = terser.parse("[a, b, ...c] = [1, 2, 3, 4, 5]");86 assert(ast.body[0] instanceof terser.AST_SimpleStatement);87 assert(ast.body[0].body instanceof terser.AST_Assign);88 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);89 assert.strictEqual(ast.body[0].body.left.is_array, true);90 assert.equal(ast.body[0].body.operator, "=");91 assert(ast.body[0].body.right instanceof terser.AST_Array);92 assert(ast.body[0].body.left.names[0] instanceof terser.AST_SymbolRef);93 assert(ast.body[0].body.left.names[1] instanceof terser.AST_SymbolRef);94 assert(ast.body[0].body.left.names[2] instanceof terser.AST_Expansion);95 });96 it("Should handle default assignments in destructuring", function() {97 var ast = terser.parse("({x: v, z = z + 5} = obj);");98 assert(ast.body[0] instanceof terser.AST_SimpleStatement);99 assert(ast.body[0].body instanceof terser.AST_Assign);100 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);101 assert.strictEqual(ast.body[0].body.left.is_array, false);102 assert.equal(ast.body[0].body.operator, "=");103 assert(ast.body[0].body.right instanceof terser.AST_SymbolRef);104 assert(ast.body[0].body.left.names[0].value instanceof terser.AST_SymbolRef);105 assert.strictEqual(ast.body[0].body.left.names[0].start.value, "x");106 assert(ast.body[0].body.left.names[1].value instanceof terser.AST_DefaultAssign);107 assert.strictEqual(ast.body[0].body.left.names[1].start.value, "z");108 assert(ast.body[0].body.left.names[1].value.left instanceof terser.AST_SymbolRef);109 assert.strictEqual(ast.body[0].body.left.names[1].value.operator, "=");110 assert(ast.body[0].body.left.names[1].value.right instanceof terser.AST_Binary);111 ast = terser.parse("({x = 123} = obj);");112 assert(ast.body[0] instanceof terser.AST_SimpleStatement);113 assert(ast.body[0].body instanceof terser.AST_Assign);114 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);115 assert.strictEqual(ast.body[0].body.left.is_array, false);116 assert.equal(ast.body[0].body.operator, "=");117 assert(ast.body[0].body.right instanceof terser.AST_SymbolRef);118 assert(ast.body[0].body.left.names[0].value instanceof terser.AST_DefaultAssign);119 assert.strictEqual(ast.body[0].body.left.names[0].value.operator, "=");120 assert(ast.body[0].body.left.names[0].value.left instanceof terser.AST_SymbolRef);121 ast = terser.parse("[x, y = 5] = foo");122 assert(ast.body[0] instanceof terser.AST_SimpleStatement);123 assert(ast.body[0].body instanceof terser.AST_Assign);124 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);125 assert.strictEqual(ast.body[0].body.left.is_array, true);126 assert.equal(ast.body[0].body.operator, "=");127 assert(ast.body[0].body.right instanceof terser.AST_SymbolRef);128 assert(ast.body[0].body.left.names[0] instanceof terser.AST_SymbolRef);129 assert.strictEqual(ast.body[0].body.left.names[0].start.value, "x");130 assert(ast.body[0].body.left.names[1] instanceof terser.AST_DefaultAssign);131 assert(ast.body[0].body.left.names[1].left instanceof terser.AST_SymbolRef);132 assert.strictEqual(ast.body[0].body.left.names[1].start.value, "y");133 });134 it("Should handle default assignments containing assignments in a destructuring", function() {135 var ast = terser.parse("[x, y = z = 2] = a;");136 assert(ast.body[0] instanceof terser.AST_SimpleStatement);137 assert(ast.body[0].body instanceof terser.AST_Assign);138 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);139 assert.strictEqual(ast.body[0].body.left.is_array, true);140 assert.equal(ast.body[0].body.operator, "=");141 assert(ast.body[0].body.right instanceof terser.AST_SymbolRef);142 assert(ast.body[0].body.left.names[0] instanceof terser.AST_SymbolRef);143 assert(ast.body[0].body.left.names[1] instanceof terser.AST_DefaultAssign);144 assert(ast.body[0].body.left.names[1].left instanceof terser.AST_SymbolRef);145 assert.equal(ast.body[0].body.left.names[1].operator, "=");146 assert(ast.body[0].body.left.names[1].right instanceof terser.AST_Assign);147 assert(ast.body[0].body.left.names[1].right.left instanceof terser.AST_SymbolRef);148 assert.equal(ast.body[0].body.left.names[1].right.operator, "=");149 assert(ast.body[0].body.left.names[1].right.right instanceof terser.AST_Number);150 ast = terser.parse("({a: a = 123} = obj)");151 assert(ast.body[0] instanceof terser.AST_SimpleStatement);152 assert(ast.body[0].body instanceof terser.AST_Assign);153 assert(ast.body[0].body.left instanceof terser.AST_Destructuring);154 assert.strictEqual(ast.body[0].body.left.is_array, false);155 assert.equal(ast.body[0].body.operator, "=");156 assert(ast.body[0].body.right instanceof terser.AST_SymbolRef);157 assert(ast.body[0].body.left.names[0] instanceof terser.AST_ObjectProperty);158 assert.strictEqual(ast.body[0].body.left.names[0].key, "a");159 assert(ast.body[0].body.left.names[0].value instanceof terser.AST_DefaultAssign);160 assert(ast.body[0].body.left.names[0].value.left instanceof terser.AST_SymbolRef);161 assert.strictEqual(ast.body[0].body.left.names[0].value.operator, "=");162 assert(ast.body[0].body.left.names[0].value.right instanceof terser.AST_Number);163 });164 it("Should allow multiple spread in array literals", function() {165 var ast = terser.parse("var a = [1, 2, 3], b = [4, 5, 6], joined; joined = [...a, ...b]");166 assert(ast.body[0] instanceof terser.AST_Var);167 assert(ast.body[1] instanceof terser.AST_SimpleStatement);168 // Check statement containing array with spreads169 assert(ast.body[1].body instanceof terser.AST_Assign);170 assert(ast.body[1].body.left instanceof terser.AST_SymbolRef);171 assert.equal(ast.body[1].body.operator, "=");172 assert(ast.body[1].body.right instanceof terser.AST_Array);173 // Check array content174 assert.strictEqual(ast.body[1].body.right.elements.length, 2);175 assert(ast.body[1].body.right.elements[0] instanceof terser.AST_Expansion);176 assert(ast.body[1].body.right.elements[0].expression instanceof terser.AST_SymbolRef);177 assert(ast.body[1].body.right.elements[0].expression.name, "a");178 assert(ast.body[1].body.right.elements[1] instanceof terser.AST_Expansion);179 assert(ast.body[1].body.right.elements[1].expression instanceof terser.AST_SymbolRef);180 assert(ast.body[1].body.right.elements[1].expression.name, "b");181 });182 it("Should not allow spread on invalid locations", function() {183 var expect = function(input, expected) {184 var execute = function(input) {185 return function() {186 terser.parse(input);187 }188 }189 var check = function(e) {190 return e instanceof terser._JS_Parse_Error &&191 e.message === expected;192 }193 assert.throws(execute(input), check);194 }195 // Spreads are not allowed in destructuring array if it's not the last element196 expect("[...a, ...b] = [1, 2, 3, 4]", "Spread must the be last element in destructuring array");197 // Multiple spreads are not allowed in destructuring array198 expect("[...a, ...b] = [1, 2, 3, 4]", "Spread must the be last element in destructuring array");199 // Array spread must be last in destructuring declaration200 expect("let [ ...x, a ] = o;", "Rest element must be last element");201 // Only one spread per destructuring array declaration202 expect("let [ a, ...x, ...y ] = o;", "Rest element must be last element");203 // Spread in block should not be allowed204 expect("{...a} = foo", "Unexpected token: expand (...)");205 // Object spread must be last in destructuring declaration206 expect("let { ...x, a } = o;", "Rest element must be last element");207 // Only one spread per destructuring declaration208 expect("let { a, ...x, ...y } = o;", "Rest element must be last element");209 });...

Full Screen

Full Screen

minify.js

Source:minify.js Github

copy

Full Screen

1"use strict";2const {3 minify: terserMinify4} = require("terser");5/** @typedef {import("source-map").RawSourceMap} RawSourceMap */6/** @typedef {import("./index.js").ExtractCommentsOptions} ExtractCommentsOptions */7/** @typedef {import("./index.js").CustomMinifyFunction} CustomMinifyFunction */8/** @typedef {import("terser").MinifyOptions} TerserMinifyOptions */9/** @typedef {import("terser").MinifyOutput} MinifyOutput */10/** @typedef {import("terser").FormatOptions} FormatOptions */11/** @typedef {import("terser").MangleOptions} MangleOptions */12/** @typedef {import("./index.js").ExtractCommentsFunction} ExtractCommentsFunction */13/** @typedef {import("./index.js").ExtractCommentsCondition} ExtractCommentsCondition */14/**15 * @typedef {Object.<any, any>} CustomMinifyOptions16 */17/**18 * @typedef {Object} InternalMinifyOptions19 * @property {string} name20 * @property {string} input21 * @property {RawSourceMap} [inputSourceMap]22 * @property {ExtractCommentsOptions} extractComments23 * @property {CustomMinifyFunction} [minify]24 * @property {TerserMinifyOptions | CustomMinifyOptions} minifyOptions25 */26/**27 * @typedef {Array<string>} ExtractedComments28 */29/**30 * @typedef {Promise<MinifyOutput & { extractedComments?: ExtractedComments}>} InternalMinifyResult31 */32/**33 * @typedef {TerserMinifyOptions & { sourceMap: undefined } & ({ output: FormatOptions & { beautify: boolean } } | { format: FormatOptions & { beautify: boolean } })} NormalizedTerserMinifyOptions34 */35/**36 * @param {TerserMinifyOptions} [terserOptions={}]37 * @returns {NormalizedTerserMinifyOptions}38 */39function buildTerserOptions(terserOptions = {}) {40 // Need deep copy objects to avoid https://github.com/terser/terser/issues/36641 return { ...terserOptions,42 compress: typeof terserOptions.compress === "boolean" ? terserOptions.compress : { ...terserOptions.compress43 },44 // ecma: terserOptions.ecma,45 // ie8: terserOptions.ie8,46 // keep_classnames: terserOptions.keep_classnames,47 // keep_fnames: terserOptions.keep_fnames,48 mangle: terserOptions.mangle == null ? true : typeof terserOptions.mangle === "boolean" ? terserOptions.mangle : { ...terserOptions.mangle49 },50 // module: terserOptions.module,51 // nameCache: { ...terserOptions.toplevel },52 // the `output` option is deprecated53 ...(terserOptions.format ? {54 format: {55 beautify: false,56 ...terserOptions.format57 }58 } : {59 output: {60 beautify: false,61 ...terserOptions.output62 }63 }),64 parse: { ...terserOptions.parse65 },66 // safari10: terserOptions.safari10,67 // Ignoring sourceMap from options68 // eslint-disable-next-line no-undefined69 sourceMap: undefined // toplevel: terserOptions.toplevel70 };71}72/**73 * @param {any} value74 * @returns {boolean}75 */76function isObject(value) {77 const type = typeof value;78 return value != null && (type === "object" || type === "function");79}80/**81 * @param {ExtractCommentsOptions} extractComments82 * @param {NormalizedTerserMinifyOptions} terserOptions83 * @param {ExtractedComments} extractedComments84 * @returns {ExtractCommentsFunction}85 */86function buildComments(extractComments, terserOptions, extractedComments) {87 /** @type {{ [index: string]: ExtractCommentsCondition }} */88 const condition = {};89 let comments;90 if (terserOptions.format) {91 ({92 comments93 } = terserOptions.format);94 } else if (terserOptions.output) {95 ({96 comments97 } = terserOptions.output);98 }99 condition.preserve = typeof comments !== "undefined" ? comments : false;100 if (typeof extractComments === "boolean" && extractComments) {101 condition.extract = "some";102 } else if (typeof extractComments === "string" || extractComments instanceof RegExp) {103 condition.extract = extractComments;104 } else if (typeof extractComments === "function") {105 condition.extract = extractComments;106 } else if (extractComments && isObject(extractComments)) {107 condition.extract = typeof extractComments.condition === "boolean" && extractComments.condition ? "some" : typeof extractComments.condition !== "undefined" ? extractComments.condition : "some";108 } else {109 // No extract110 // Preserve using "commentsOpts" or "some"111 condition.preserve = typeof comments !== "undefined" ? comments : "some";112 condition.extract = false;113 } // Ensure that both conditions are functions114 ["preserve", "extract"].forEach(key => {115 /** @type {undefined | string} */116 let regexStr;117 /** @type {undefined | RegExp} */118 let regex;119 switch (typeof condition[key]) {120 case "boolean":121 condition[key] = condition[key] ? () => true : () => false;122 break;123 case "function":124 break;125 case "string":126 if (condition[key] === "all") {127 condition[key] = () => true;128 break;129 }130 if (condition[key] === "some") {131 condition[key] =132 /** @type {ExtractCommentsFunction} */133 (astNode, comment) => (comment.type === "comment2" || comment.type === "comment1") && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value);134 break;135 }136 regexStr =137 /** @type {string} */138 condition[key];139 condition[key] =140 /** @type {ExtractCommentsFunction} */141 (astNode, comment) => new RegExp(142 /** @type {string} */143 regexStr).test(comment.value);144 break;145 default:146 regex =147 /** @type {RegExp} */148 condition[key];149 condition[key] =150 /** @type {ExtractCommentsFunction} */151 (astNode, comment) =>152 /** @type {RegExp} */153 regex.test(comment.value);154 }155 }); // Redefine the comments function to extract and preserve156 // comments according to the two conditions157 return (astNode, comment) => {158 if (159 /** @type {{ extract: ExtractCommentsFunction }} */160 condition.extract(astNode, comment)) {161 const commentText = comment.type === "comment2" ? `/*${comment.value}*/` : `//${comment.value}`; // Don't include duplicate comments162 if (!extractedComments.includes(commentText)) {163 extractedComments.push(commentText);164 }165 }166 return (167 /** @type {{ preserve: ExtractCommentsFunction }} */168 condition.preserve(astNode, comment)169 );170 };171}172/**173 * @param {InternalMinifyOptions} options174 * @returns {InternalMinifyResult}175 */176async function minify(options) {177 const {178 name,179 input,180 inputSourceMap,181 minify: minifyFn,182 minifyOptions183 } = options;184 if (minifyFn) {185 return minifyFn({186 [name]: input187 }, inputSourceMap, minifyOptions);188 } // Copy terser options189 const terserOptions = buildTerserOptions(minifyOptions); // Let terser generate a SourceMap190 if (inputSourceMap) {191 // @ts-ignore192 terserOptions.sourceMap = {193 asObject: true194 };195 }196 /** @type {ExtractedComments} */197 const extractedComments = [];198 const {199 extractComments200 } = options;201 if (terserOptions.output) {202 terserOptions.output.comments = buildComments(extractComments, terserOptions, extractedComments);203 } else if (terserOptions.format) {204 terserOptions.format.comments = buildComments(extractComments, terserOptions, extractedComments);205 }206 const result = await terserMinify({207 [name]: input208 }, terserOptions);209 return { ...result,210 extractedComments211 };212}213/**214 * @param {string} options215 * @returns {InternalMinifyResult}216 */217function transform(options) {218 // 'use strict' => this === undefined (Clean Scope)219 // Safer for possible security issues, albeit not critical at all here220 // eslint-disable-next-line no-param-reassign221 const evaluatedOptions =222 /** @type {InternalMinifyOptions} */223 // eslint-disable-next-line no-new-func224 new Function("exports", "require", "module", "__filename", "__dirname", `'use strict'\nreturn ${options}`)(exports, require, module, __filename, __dirname);225 return minify(evaluatedOptions);226}227module.exports.minify = minify;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const webpack = require('webpack');3const { CleanWebpackPlugin } = require('clean-webpack-plugin');4const HtmlWebpackPlugin = require('html-webpack-plugin');5const CopyWebpackPlugin = require('copy-webpack-plugin');6const MiniCssExtractPlugin = require('mini-css-extract-plugin');7const TerserPlugin = require('terser-webpack-plugin');8const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');9const BestCompressionPlugin = require('best-compression-webpack-plugin');10module.exports = {11 entry: {12 },13 output: {14 path: path.resolve(__dirname, 'dist'),15 },16 optimization: {17 new TerserPlugin({18 }),19 new OptimizeCSSAssetsPlugin({}),20 },21 module: {22 {23 },24 {25 },26 {27 test: /\.(png|svg|jpg|gif)$/,28 },29 },30 new CleanWebpackPlugin(),31 new HtmlWebpackPlugin({32 }),33 new MiniCssExtractPlugin({34 }),35 new BestCompressionPlugin({36 test: /\.(js|css|html|svg)$/,37 compressionOptions: { level: 11 },38 }),39};40const path = require('path');41const webpack = require('webpack');42const { CleanWebpackPlugin } = require('clean-webpack-plugin');43const HtmlWebpackPlugin = require('html-webpack-plugin');44const CopyWebpackPlugin = require('copy-webpack-plugin');45const MiniCssExtractPlugin = require('mini-css-extract-plugin');46const TerserPlugin = require('terser-webpack-plugin');47const OptimizeCSSAssetsPlugin = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var terser = require('terser');3var code = fs.readFileSync('test4.js', 'utf8');4var result = terser.minify(code);5fs.writeFileSync('test4.min.js', result.code);6console.log('test4.min.js created');7var fs = require('fs');8var terser = require('terser');9var code = fs.readFileSync('test4.js', 'utf8');10var result = terser.minify(code);11fs.writeFileSync('test4.min.js', result.code);12console.log('test4.min.js created');13var fs = require('fs');14var terser = require('terser');15var code = fs.readFileSync('test4.js', 'utf8');16var result = terser.minify(code);17fs.writeFileSync('test4.min.js', result.code);18console.log('test4.min.js created');19var fs = require('fs');20var terser = require('terser');21var code = fs.readFileSync('test4.js', 'utf8');22var result = terser.minify(code);23fs.writeFileSync('test4.min.js', result.code);24console.log('test4.min.js created');25var fs = require('fs');26var terser = require('terser');27var code = fs.readFileSync('test4.js', 'utf8');28var result = terser.minify(code);29fs.writeFileSync('test4.min.js', result.code);30console.log('test4.min.js created');31var fs = require('fs');32var terser = require('terser');33var code = fs.readFileSync('test4.js', 'utf8');34var result = terser.minify(code);35fs.writeFileSync('test4.min.js', result.code);36console.log('test4.min.js created');

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { BestInPlaceEditor } from 'react-rails-best_in_place';3class Test4 extends React.Component {4 constructor(props) {5 super(props);6 this.state = {7 };8 }9 render() {10 return (11 value={this.state.value}12 onConfirm={value => this.setState({ value })}13 );14 }15}16export default Test4;17import React from 'react';18import BestInPlaceEditor from 'react-rails-best_in_place';19class Test5 extends React.Component {20 constructor(props) {21 super(props);22 this.state = {23 };24 }25 render() {26 return (27 value={this.state.value}28 onConfirm={value => this.setState({ value })}29 );30 }31}32export default Test5;33import React from 'react';34import { BestInPlaceEditor } from 'react-rails-best_in_place';35class Test6 extends React.Component {36 constructor(props) {37 super(props);38 this.state = {39 };40 }41 render() {42 return (43 value={this.state.value}44 onConfirm={value => this.setState({ value })}45 );46 }47}48export default Test6;49import React from 'react';50import BestInPlaceEditor from 'react-rails-best_in_place';51class Test7 extends React.Component {52 constructor(props) {53 super(props);54 this.state = {55 };56 }57 render() {58 return (59 value={this.state.value}60 onConfirm={value => this.setState({ value })}61 );62 }63}64export default Test7;65import React from 'react';66import { BestInPlaceEditor } from 'react-rails-best_in_place';67class Test8 extends React.Component {68 constructor(props) {69 super(props);

Full Screen

Using AI Code Generation

copy

Full Screen

1const {BestMinifier} = require('best-minifier');2const minifier = new BestMinifier();3const options = {4};5minifier.terser(options).then(function() {6 console.log('done');7});

Full Screen

Using AI Code Generation

copy

Full Screen

1var uc = require('upper-case');2console.log(uc.upperCase("Hello World!"));3var uc = require('upper-case');4console.log(uc.upperCase("Hello World!"));5var uc = require('upper-case');6console.log(uc.upperCase("Hello World!"));7var uc = require('upper-case');8console.log(uc.upperCase("Hello World!"));9var uc = require('upper-case');10console.log(uc.upperCase("Hello World!"));11var uc = require('upper-case');12console.log(uc.upperCase("Hello World!"));13var uc = require('upper-case');14console.log(uc.upperCase("Hello World!"));15var uc = require('upper-case');16console.log(uc.upperCase("Hello World!"));17var uc = require('upper-case');18console.log(uc.upperCase("Hello World!"));19var uc = require('upper-case');20console.log(uc.upperCase("Hello World!"));21var uc = require('upper-case');22console.log(uc.upperCase("Hello World

Full Screen

Using AI Code Generation

copy

Full Screen

1var Bestiary = require("./bestiary.js");2var bestiary = new Bestiary();3var name = 'test4';4var obj = {5 c: {6 }7};8bestiary.terser(name, obj);9console.log(bestiary.getter(name));10var Bestiary = require("./bestiary.js");11var bestiary = new Bestiary();12var name = 'test5';13var obj = {14 c: {15 }16};17bestiary.setter(name, obj);18console.log(bestiary.getter(name));19var Bestiary = require("./bestiary.js");20var bestiary = new Bestiary();21var name = 'test6';22var obj = {23 c: {24 }25};26bestiary.setter(name, obj);27console.log(bestiary.getter(name));28var Bestiary = require("./bestiary.js");29var bestiary = new Bestiary();30var name = 'test7';31var obj = {32 c: {33 }34};35bestiary.setter(name, obj);36console.log(bestiary.getter(name));37var Bestiary = require("./bestiary.js");38var bestiary = new Bestiary();39var name = 'test8';40var obj = {41 c: {42 }43};44bestiary.setter(name, obj);45console.log(bestiary.getter(name));

Full Screen

Using AI Code Generation

copy

Full Screen

1"use strict";2var x = 3.14;3var y = 3;4var z = "3";5var result1 = x + y;6var result2 = x + z;7var result3 = x + y + z;8console.log(result1);9console.log(result2);10console.log(result3);11"use strict";12var x = 3.14;13var y = 3;14var z = "3";15var result1 = x + y;16var result2 = x + z;17var result3 = x + y + z;18console.log(result1);19console.log(result2);20console.log(result3);21"use strict";22var x = 3.14;23var y = 3;24var z = "3";25var result1 = x + y;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful