bun
is to check for the existence of the Bun
global.
This is similar to how you’d check for the existence of the window
variable to detect when code is being executed in a browser.
In TypeScript environments, the previous approach will result in a type error unless
@types/bun
is installed. To avoid this, you can check process.versions
instead.