https://github.com/tr1ckydev/runtimey
Easily detect which JavaScript runtime is being used.
https://github.com/tr1ckydev/runtimey
bun deno node runtime
Last synced: about 1 year ago
JSON representation
Easily detect which JavaScript runtime is being used.
- Host: GitHub
- URL: https://github.com/tr1ckydev/runtimey
- Owner: tr1ckydev
- License: mit
- Created: 2023-06-27T11:28:53.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-21T18:05:51.000Z (over 2 years ago)
- Last Synced: 2025-05-27T14:25:17.849Z (about 1 year ago)
- Topics: bun, deno, node, runtime
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/runtimey
- Size: 4.88 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# runtimey
Easily detect which JavaScript runtime is being used. [Bun](https://bun.sh/), [Deno](https://deno.com/runtime), [Node.JS](https://nodejs.org/) or browser.
Useful for packages or scripts to customize functionality of their code depending on the runtime being executed.
## Usage
*index.js*
```javascript
import { currentRuntime } from "runtimey";
console.log(currentRuntime);
```
*shell*
```bash
$ bun index.js && deno run index.js && node index.js
bun
deno
node
```
## Documentation
- ### `isBun`
`true` if the Bun runtime is being used.
- ### `isDeno`
`true` if the Deno runtime is being used.
- ### `isNode`
`true` if the Node.JS runtime is being used.
- ### `isBrowser`
`true` if running inside a browser.
- ### `currentRuntime`: `"bun"` | `"deno"` | `"node"` | `"browser"` | `"unknown"`
The name of the current runtime being used.
- ### `runtimeValue({ bun, deno, node, browser, default })`
Returns the value according to the runtime being used.
*index.js*
```javascript
import { runtimeValue } from "runtimey";
const val = runtimeValue({ bun: "RUNTIME_BUN", deno: "RUNTIME_DENO", node: "RUNTIME_NODE" });
console.log("Current runtime:", val);
```
*shell*
```bash
$ bun index.js && deno run index.js && node index.js
Current runtime: RUNTIME_BUN
Current runtime: RUNTIME_DENO
Current runtime: RUNTIME_NODE
```
- ### `isServiceWorker`
`true` if running in a worker environment.
## License
This repository uses MIT License. See [LICENSE](https://github.com/tr1ckydev/runtimey/blob/main/LICENSE) for full license text.