-
Notifications
You must be signed in to change notification settings - Fork 2
/
translated_normal.js
141 lines (141 loc) · 2.49 KB
/
translated_normal.js
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
let bb = {
c: `d`
};
let aa = {
[bb[c]]: `4`
};
`keyword`;
let func = (a, {
...kwargs
}, ...args) => {
console.log(a)
};
func(`a`, `b`, `c`, {
kw: `kw`
});
`generator`;
let generator_func = function*() {
yield 1;
yield 2;
yield 3;
yield*[9, 8, 7];
return 0
};
for (let item of generator_func()) {
console.log(item)
};
`for-else`;
__else: {
for (let i of [0, 1, 2, 3]) {
if (i > 2) {
break __else
}
}
console.log(`else`)
};
`f-string`;
let a = 4;
console.log(`fstring ${a}`);
`class`;
let Main = class {
a;
constructor() {
this.a = 1
};
func() {
console.log(this.a)
}
}
Main = new Proxy(Main, {
apply: (clazz, thisValue, args) => new clazz(...args)
});;
Main().func();
`try catch else finally`;
__else: {
try {
throw SyntaxError(`syntax error`)
} catch (__err) {
if (__err instanceof SyntaxError) {
e = __err;
console.log(`syntax error raised`);
break __else
} {
console.log(`excepted`);
break __else
}
}
console.log(`else`)
};
try {
if (Boolean(1)) {
throw SyntaxError(`syntax error`)
}
} catch (__err) {
{
/* pass */ }
} finally {
console.log(`finally`)
};
`while`;
let i = 10;
while (i > 0) {
i -= 1
};
`comparator`;
i = 5;
if (0 < i < 9) {
console.log(`true`)
} else {
console.log(`false`)
};
`comprehension`;
console.log(Array(10).map((i) => i));
console.log(Array(10).filter(i => (i % 2) == 0).map((i) => i));
`decorator`;
let decorator = (func) => {
let wrapper = () => {
console.log(`decorator`);
func()
};
return wrapper
};
let decorated = decorator(() => {
console.log(`decorated`)
});
let Decorated = class {
;
decorated = decorator(() => {
console.log(`decorated`)
})
}
Decorated = new Proxy(Decorated, {
apply: (clazz, thisValue, args) => new clazz(...args)
});;
decorated();
`lambda`;
console.log(((x) => {
(x + 1)
})(1));
`async`;
letasync_func = async () => {
console.log(`async`);
return 0
};
letasync_func2 = async () => {
await async_func()
};
`async for`;
letasync_for = async () => {
for (i of Array(10)) {
await async_func()
}
};
`async with`;
letasync_with = async () => {
{
let [__with_0] = [open(`translated_normal.js`, `r`)];
f = await __with_0.__aenter__();
console.log(await f.read());
await __with_0.__aexit__()
}
}