-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-coffee.ts
89 lines (79 loc) · 1.98 KB
/
test-coffee.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// import { build } from "arenaless-bundler";
import { build } from "./dist/index";
// import * as fs from "fs";
async function test() {
let files_text: Record<string, string> = {
"index.coffee": `
import JSON5 from "npm:json5"
console.log(JSON5.parse("{a:1}"))
# Assignment:
number = 42
opposite = true
# Conditions:
number = -42 if opposite
# Functions:
square = (x) -> x * x
# Arrays:
list = [1, 2, 3, 4, 5]
# Objects:
math =
root: Math.sqrt
square: square
cube: (x) -> x * square x
# Splats:
race = (winner, runners...) ->
print winner, runners
# Existence:
alert "I knew it!" if elvis?
# Array comprehensions:
cubes = (math.cube num for num in list)`,
"importMap.arenaless.jsonc":`{"imports":{"dao3-areact":"npm:dao3-areact"}}`
}
// let imagebuf=fs.readFileSync("./image.png");
// to uint array
// let image=new Uint8Array(imagebuf);
let files: Record<string, Uint8Array> = {
//"image.png": image,
};
for (let key in files_text) {
files[key] = new TextEncoder().encode(files_text[key]);
}
let res = await build(files, "index.coffee", `{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"baseUrl": "./",
"rootDir": "./",
"outDir": "dist", // do not change this
"lib": [],
"paths": {
},
},
"include": [
"./**/*.ts",
"./**/*.d.ts",
"./types"
],
"exclude": [
"node_modules",
"dist"
]
}`, console, "cjs", `{
"imports":{"json5":"npm:json5"}
}`, false);
// console.log(res)
return res;
};
(async () => {
for (let i = 1; i < 10 + 1; i++) {
let start = Date.now();
let res = await test();
console.log(res);
}
})();