Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ All detection modules follow the same pattern:
- Priority order: netlify → edge-light → workerd → fastly → deno → bun → node
- Uses global objects (e.g., `globalThis.Bun`, `globalThis.Deno`, `navigator.userAgent`)
- `isNode` is true for Node-compatible runtimes (Bun, Deno with compat); use `runtime === "node"` for strict check
- `isNub` (`!!process.versions.nub`) detects [Nub](https://github.com/nubjs/nub), a Node.js augmentation layer — additive, so `isNode` stays true and `runtime` stays `"node"`; it is deliberately NOT in `runtimeChecks` or `RuntimeName`

### Flags (`src/flags.ts`)

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ console.log(runtime); // "" | "node" | "deno" | "bun" | "workerd" ...
console.log(runtimeInfo); // { name: "node" }
```

Individual named exports: `isNode`, `isBun`, `isDeno`, `isNetlify`, `isEdgeLight`, `isWorkerd`, `isFastly`
Individual named exports: `isNode`, `isBun`, `isDeno`, `isNetlify`, `isEdgeLight`, `isWorkerd`, `isFastly`, `isNub`

> [!NOTE]
> `isNode` is also `true` in Bun/Deno with Node.js compatibility mode. Use `runtime === "node"` for strict checks.
>
> `isNub` detects [Nub](https://github.com/nubjs/nub), which augments Node.js rather than replacing it. It is additive: `isNode` is also `true` and `runtime` stays `"node"`.

Comment thread
coderabbitai[bot] marked this conversation as resolved.
See [./src/runtimes.ts](./src/runtimes.ts) for the full list.

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export {
isBun,
isDeno,
isNode,
isNub,
runtime,
runtimeInfo,
isEdgeLight,
Expand Down
9 changes: 9 additions & 0 deletions src/runtimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export type RuntimeInfo = {
*/
export const isNode: boolean = !!process?.versions?.node;

/**
* Indicates if running under [Nub](https://github.com/nubjs/nub).
*
* **Note:** Nub augments Node.js rather than replacing it, so `isNode` is also `true` and
* `runtime` stays `"node"`. This flag is additive — it detects the Nub augmentation layer
* on top of Node.
*/
export const isNub: boolean = !!process?.versions?.nub;

/**
* Indicates if running in Bun runtime.
*/
Expand Down
1 change: 1 addition & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe("std-env", () => {
isProduction: false,
isDevelopment: false,
isMinimal: true,
isNub: false,
isWindows: expect.any(Boolean),
isLinux: expect.any(Boolean),
isMacOS: expect.any(Boolean),
Expand Down
Loading