-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test65.ts
60 lines (45 loc) 路 1.47 KB
/
test65.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
import { Evt, throttleTime } from "../lib/index.ts";
import type * as dom from "../lib/types/lib.dom.ts";
declare const document: dom.Document;
//Type only test
if (1 + 0 === 2) {
{
let count = 0;
const rate = 1000;
let lastClick = Date.now() - rate;
document.addEventListener('click', event => {
if (Date.now() - lastClick >= rate) {
count += event.clientX;
console.log(count);
lastClick = Date.now();
}
});
}
//clientX should be number
Evt.from(document, "click")
.pipe(
throttleTime(1000),
event => [parseInt(event.clientX.toFixed())],
[(clientX, count) => [count + clientX], 0]
).attach(count => console.log(count));
{
let count = 0;
const rate = 1000;
let lastClick = Date.now() - rate;
document.getElementById("app")!.addEventListener('click', event => {
if (Date.now() - lastClick >= rate) {
count += event.clientX;
console.log(count);
lastClick = Date.now();
}
});
}
//clientX should be number
Evt.from(document.getElementById("app")!, "click")
.pipe(
throttleTime(1000),
event => [parseInt(event.clientX.toFixed())],
[(clientX, count) => [count + clientX], 0]
).attach(count => console.log(count));
}
console.log("PASS");