blob: 263f46b4ce6e7dc6bb1bd396d4c5f66a2e1d2053 (
plain)
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
|
import process from "node:process";
let count = 0;
process.on("beforeExit", () => {
if (count === 0 || count === 1) {
setTimeout(() => console.log("more work done!", count), 10);
}
count++;
console.log("beforeExit emitted from process.on");
});
process.on("exit", () => console.log("exit emitted from process.on"));
let countWeb = 0;
addEventListener("beforeunload", (event) => {
if (countWeb == 0 || countWeb == 1) {
event.preventDefault();
}
countWeb++;
console.log("beforeunload emitted from addEventListener");
});
addEventListener(
"unload",
() => console.log("unload emitted from addEventListener"),
);
|