|
| 1 | +let avgJs = ` |
| 2 | +const str = "we" + "do" + "some" + "ops"; |
| 3 | +for(const x of str.split("")) { |
| 4 | + if(x.charCodeAt(0) > 40) { |
| 5 | + console.log("omg"); |
| 6 | + } else { |
| 7 | + console.log(Math.random() * 2 + 3 * 2); |
| 8 | + } |
| 9 | +} |
| 10 | +
|
| 11 | +// Some comment |
| 12 | +switch(a.b.c.d.f.e.g.h.i) { |
| 13 | + case true: |
| 14 | + break; |
| 15 | + case "magic": |
| 16 | + throw new Error("Error!"); |
| 17 | + case 9: |
| 18 | + (function() { |
| 19 | + // extra scope |
| 20 | + var x = 123; |
| 21 | + var y = 456; |
| 22 | + var z = x + z * x / y; |
| 23 | + x && y && (z = x ? y : x); |
| 24 | + }()) |
| 25 | +} |
| 26 | +
|
| 27 | +function a() {} |
| 28 | +function b() {} |
| 29 | +function c() {} |
| 30 | +function d() {} |
| 31 | +function e() {} |
| 32 | +function f() {} |
| 33 | +` |
| 34 | + |
| 35 | +for(var i = 0; i < 2; i++) { |
| 36 | + avgJs += `(function() {${avgJs}}());`; |
| 37 | +} |
| 38 | + |
| 39 | +const fs = require("fs"); |
| 40 | +const root = __dirname; |
| 41 | + |
| 42 | +createTree(fs, 100, `${root}/modules-100`); |
| 43 | +createTree(fs, 500, `${root}/modules-500`); |
| 44 | +createTree(fs, 1000, `${root}/modules-1000`); |
| 45 | +createTree(fs, 3000, `${root}/modules-3000`); |
| 46 | +createTree(fs, 5000, `${root}/modules-5000`); |
| 47 | + |
| 48 | +function createTree(fs, count, folder) { |
| 49 | + fs.mkdirSync(folder); |
| 50 | + let remaining = count - 1; |
| 51 | + function make(prefix, count, depth) { |
| 52 | + if(count === 0) { |
| 53 | + fs.writeFileSync(`${folder}/${prefix}.js`, `export default 1;\n${avgJs}`); |
| 54 | + } else { |
| 55 | + const list = []; |
| 56 | + for(let i = 0; i < count; i++) { |
| 57 | + if(remaining-- <= 0) break; |
| 58 | + if(depth <= 4 && i >= 3 && i <= 4) { |
| 59 | + list.push(`const module${i} = import("./${prefix}-${i}");\ncounter += module${i};`); |
| 60 | + } else { |
| 61 | + list.push(`import module${i} from "./${prefix}-${i}";\ncounter += module${i};`); |
| 62 | + } |
| 63 | + make(`${prefix}-${i}`, depth > 4 || count > 30 ? 0 : count + depth + i ** 2, depth + 1); |
| 64 | + } |
| 65 | + fs.writeFileSync(`${folder}/${prefix}.js`, `let counter = 0;\n${list.join("\n")};\nexport default counter;\n${avgJs}`) |
| 66 | + } |
| 67 | + } |
| 68 | + make("index", 2, 0); |
| 69 | +} |
0 commit comments