Integrate runtime detection
QuiiBz opened this issue · 1 comments
Describe the feature
I've created detect-runtime a few months ago as a way to detect the current JavaScript runtime where the code is running. As Atinux suggested, we could bring this feature to std-env, which could be a great fit.
detect-runtime follows the WinterCG Runtime Keys specification, which sometimes duplicate the same underlying JavaScript runtime (edge-light
is technically workerd
, netlify
is technically deno
). Do we also want to follow this specification, or instead use a subset? (node
, deno
, bun
, workerd
, lagon
, fastly
)
Additional information
- Would you be willing to help implement this feature?
Thanks for creating the issue. I think it is a brilliant idea to add flags to detect runtime environments as well.
Currently, we detect "platforms" mainly for CI environments. We can extend it for runtimes as well from here using a new Array.
I think platform names following runtime key consistency makes the most sense as platforms usually have specific setup and behavior.
We shall also export more flags (from flags.ts
) for isNode
, isBun
, isDeno
, etc indicating actual runtime.
Feel free to draft a PR 💯