@@ -23,10 +23,8 @@ function setTimeout(handler, delayMs = 0, ...args)
2323{
2424 // Ensure the first parameter is a function
2525 // We support passing a `code` string to `setTimeout` as the callback function
26- if ( typeof handler !== 'function' )
27- {
26+ if ( typeof handler !== 'function' )
2827 handler = new Function ( handler ) ;
29- }
3028
3129 // `setTimeout` allows passing additional arguments to the callback, as spec-ed
3230 // FIXME (Tom Tang): the spec doesn't allow additional arguments to be passed if the original `handler` is not a function
@@ -39,7 +37,8 @@ function setTimeout(handler, delayMs = 0, ...args)
3937 // Get the delay time in seconds
4038 // JS `setTimeout` takes milliseconds, but Python takes seconds
4139 delayMs = Number ( delayMs ) || 0 ; // ensure the `delayMs` is a `number`, explicitly do type coercion
42- if ( delayMs < 0 ) { delayMs = 0 ; } // as spec-ed
40+ if ( delayMs < 0 )
41+ delayMs = 0 ; // as spec-ed
4342 const delaySeconds = delayMs / 1000 ; // convert ms to s
4443
4544 return enqueueWithDelay ( boundHandler , delaySeconds ) ;
@@ -57,14 +56,10 @@ function clearTimeout(timeoutId)
5756 return cancelByTimeoutId ( timeoutId ) ;
5857}
5958
60- if ( ! globalThis . setTimeout )
61- {
59+ if ( ! globalThis . setTimeout )
6260 globalThis . setTimeout = setTimeout ;
63- }
64- if ( ! globalThis . clearTimeout )
65- {
61+ if ( ! globalThis . clearTimeout )
6662 globalThis . clearTimeout = clearTimeout ;
67- }
6863
6964exports . setTimeout = setTimeout ;
7065exports . clearTimeout = clearTimeout ;
0 commit comments