Skip to content

Commit

Permalink
Fixes #17458
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Feb 20, 2025
1 parent 1e6fdc9 commit 6e45e3b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/api/workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,17 @@ const worker = new Worker("./i-am-smol.ts", {
{% details summary="What does `smol` mode actually do?" %}
Setting `smol: true` sets `JSC::HeapSize` to be `Small` instead of the default `Large`.
{% /details %}

## `Bun.isMainThread`

You can check if you're in the main thread by checking `Bun.isMainThread`.

```ts
if (Bun.isMainThread) {
console.log("I'm the main thread");
} else {
console.log("I'm in a worker");
}
```

This is useful for conditionally running code based on whether you're in the main thread or not.

0 comments on commit 6e45e3b

Please sign in to comment.