Hacker News new | ask | show | jobs
by antipurist 904 days ago
Something like

    if ('Bun' in globalThis) ...
    if ('Deno' in globalThis) ...
    if ('window' in globalThis) ...
could be used to determine the runtime.
1 comments

That certainly works for Bun and Deno, not sure about what is effective in Node, though.
Checking for process.versions.{node,bun} works, not sure if Deno has an equivalent.