You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python/pythonmonkey/builtin_modules/timers.js
+49-6Lines changed: 49 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ class Timeout
96
96
}
97
97
98
98
/**
99
-
* Normalize the arguments to `setTimeout` or `setInterval`
99
+
* Normalize the arguments to `setTimeout`,`setImmediate` or `setInterval`
100
100
* @param {Function | string} handler
101
101
* @param {number} delayMs timeout milliseconds
102
102
* @param {any[]} additionalArgs additional arguments to be passed to the `handler`
@@ -123,7 +123,19 @@ function _normalizeTimerArgs(handler, delayMs, additionalArgs)
123
123
delayMs=0;// as spec-ed
124
124
constdelaySeconds=delayMs/1000;// convert ms to s
125
125
126
-
return{ boundHandler, delaySeconds };
126
+
// Populate debug information for the WTFPythonMonkey tool
127
+
conststacks=newError().stack.split('\n');
128
+
consttimerType=stacks[1]?.match(/^set(Timeout|Immediate|Interval)/)?.[0];// `setTimeout@...`/`setImmediate@...`/`setInterval@...` is on the second line of stack trace
129
+
constdebugInfo={
130
+
type: timerType,// "setTimeout", "setImmediate", or "setInterval"
131
+
fn: handler,
132
+
args: additionalArgs,
133
+
startTime: newDate(),
134
+
delaySeconds,
135
+
stack: stacks.slice(2).join('\n'),// remove the first line `_normalizeTimerArgs@...` and the second line `setTimeout/setImmediate/setInterval@...`
136
+
};
137
+
138
+
return{ boundHandler, delaySeconds, debugInfo };
127
139
}
128
140
129
141
/**
@@ -137,8 +149,8 @@ function _normalizeTimerArgs(handler, delayMs, additionalArgs)
0 commit comments