-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
46 lines (43 loc) · 845 Bytes
/
test.js
File metadata and controls
46 lines (43 loc) · 845 Bytes
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
const aop = require('./index')
var originFunction = function () {
return new Promise(function (resolve, reject) {
console.log('in origin function')
setTimeout(function () {
resolve('pass to after')
}, 1000)
})
}
var aopi = aop(originFunction)
.before(function a(next) {
console.log('1')
next('pass to next')
})
.before(function b(next,a) {
console.log('here in next :' + a)
console.log('2')
next()
})
.before(function (next) {
console.log('after 2 s')
setTimeout(next, 2000)
})
.before(function (next) {
console.log('after 1 s')
setTimeout(next, 1000)
})
.before(function c(next) {
console.log('3')
next()
})
.after(function d(next, b) {
console.log(b)
next()
})
.after(function d(next) {
console.log('after 3 s')
setTimeout(next, 3000)
})
.end(function () {
console.log('end')
})
aopi()