-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node/timers): work around |this| check in deno (#1827)
Deno's built-in timer functions throw "Illegal invocation" exceptions unless they are called with this == globalThis or this == null.
- Loading branch information
1 parent
f4e0d45
commit fedb88a
Showing
2 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. | ||
|
||
import timers from "./timers.ts"; | ||
|
||
Deno.test("[node/timers setTimeout]", () => { | ||
{ | ||
const { clearTimeout, setTimeout } = timers; | ||
const id = setTimeout(() => {}); | ||
clearTimeout(id); | ||
} | ||
|
||
{ | ||
const id = timers.setTimeout(() => {}); | ||
timers.clearTimeout(id); | ||
} | ||
}); | ||
|
||
Deno.test("[node/timers setInterval]", () => { | ||
{ | ||
const { clearInterval, setInterval } = timers; | ||
const id = setInterval(() => {}); | ||
clearInterval(id); | ||
} | ||
|
||
{ | ||
const id = timers.setInterval(() => {}); | ||
timers.clearInterval(id); | ||
} | ||
}); | ||
|
||
Deno.test("[node/timers setImmediate]", () => { | ||
{ | ||
const { clearImmediate, setImmediate } = timers; | ||
const id = setImmediate(() => {}); | ||
clearImmediate(id); | ||
} | ||
|
||
{ | ||
const id = timers.setImmediate(() => {}); | ||
timers.clearImmediate(id); | ||
} | ||
}); |