Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/content/docs/workers/runtime-apis/nodejs/timers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ and [`setImmediate`](https://nodejs.org/api/timers.html#setimmediatecallback-arg
import timers from "node:timers";

export default {
async fetch() {
async fetch(): Promise<Response> {
console.log("first");
const { promise1, resolve1 } = Promise.withResolvers();
const { promise2, resolve2 } = Promise.withResolvers();
const { promise: promise1, resolve: resolve1 } = Promise.withResolvers<void>();
const { promise: promise2, resolve: resolve2 } = Promise.withResolvers<void>();
timers.setTimeout(() => {
console.log("last");
resolve1();
Expand All @@ -35,10 +35,8 @@ export default {
await Promise.all([promise1, promise2]);

return new Response("ok");

}
}

}
} satisfies ExportedHandler<Env>;
```
</TypeScriptExample>

Expand All @@ -55,4 +53,3 @@ compatibility, you must call functions from the `node:timers` module.
:::

The full `node:timers` API is documented in the [Node.js documentation for `node:timers`](https://nodejs.org/api/timers.html).
```
Loading