-
Notifications
You must be signed in to change notification settings - Fork 16
/
aspect.html
54 lines (44 loc) · 1 KB
/
aspect.html
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
<!DOCTYPE html>
<html>
<head>
<title>Aspect test</title>
<!-- <script type="module" src="/src/scaleX/aop.js"></script> -->
</head>
<body>
<script type="module">
import Aspect from "./src/scaleX/aspect.js"
class Test {
c = 0
method1() {
console.log("method executed")
}
add(a, b) {
return a + b + this.c
}
}
function beforeMethod() {
console.log("before method")
}
function afterMethod() {
console.log("after method")
}
function aroundMethod() {
console.log("around method")
}
function multi() {
this.c = 2
}
// const test = new Test()
const aspect1 = new Aspect()
aspect1.before("method1", beforeMethod)
aspect1.after("method1", afterMethod)
aspect1.around("method1", aroundMethod)
aspect1.before("add", multi)
let test = new Test()
let mod = Aspect.add(aspect1, test)
// Mod.method1()
mod.method1()
console.log(mod.add(2,2))
</script>
</body>
</html>