-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test68.ts
70 lines (51 loc) 路 1.63 KB
/
test68.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
import { Evt } from "../lib/index.ts";
import { assert } from "https://deno.land/x/tsafe@v1.1.1/assert.ts";;
let warn_str = "";
Object.defineProperty(console, "warn", {
"value": (str: string) => warn_str += str + "\n"
});
const evt = new Evt();
for (let i = 1; i <= 60; i++) {
if (i === 27) {
evt.enableTrace({
"id": "my event",
"log": false
});
}
evt.attach(function () {
console.log("identification from source");
});
}
const warn_str_expected =
`MaxHandlersExceededWarning: Possible Evt memory leak detected.26 handlers attached.
Use Evt.prototype.setMaxHandlers(n) to increase limit on a specific Evt.
Use Evt.setDefaultMaxHandlers(n) to change the default limit currently set to 25.
26 handlers like:
{
hasCtx: false,
once: false,
prepend: false,
extract: false,
isWaitFor: false,
callback: function () {
console.log("identification from source");
}
}
To validate the identify of the Evt instance that is triggering this warning you can call Evt.prototype.enableTrace({ "id": "My evt id", "log": false }) on the Evt that you suspect.
MaxHandlersExceededWarning: Possible Evt memory leak detected.52 handlers attached to "my event".
Use Evt.prototype.setMaxHandlers(n) to increase limit on a specific Evt.
Use Evt.setDefaultMaxHandlers(n) to change the default limit currently set to 25.
52 handlers like:
{
hasCtx: false,
once: false,
prepend: false,
extract: false,
isWaitFor: false,
callback: function () {
console.log("identification from source");
}
}
`;
assert(warn_str === warn_str_expected);
console.log("PASS");