Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quiibz/detect-runtime
Detects the current runtime environment (Node.js, Cloudflare Workers, Deno, ...)
https://github.com/quiibz/detect-runtime
Last synced: 12 days ago
JSON representation
Detects the current runtime environment (Node.js, Cloudflare Workers, Deno, ...)
- Host: GitHub
- URL: https://github.com/quiibz/detect-runtime
- Owner: QuiiBz
- License: mit
- Created: 2023-07-02T14:14:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-18T11:45:40.000Z (about 1 year ago)
- Last Synced: 2024-10-20T01:11:21.292Z (24 days ago)
- Language: TypeScript
- Size: 40 KB
- Stars: 33
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## detect-runtime
> **Warning**
> detect-runtime has been deprecated in favor of [std-env](https://github.com/unjs/std-env) (since version 3.4.0), which includes the same functionalities and much more.Small library to detect the current JavaScript runtime. The list of supported runtimes is based on the [WinterCG Runtime Keys proposal](https://runtime-keys.proposal.wintercg.org/):
- `edge-routine` Alibaba Cloud Edge Routine
- `workerd` Cloudflare Workers
- `deno` Deno and Deno Deploy
- `lagon` Lagon
- `react-native` React Native
- `netlify` Netlify Edge Functions
- `electron` Electron
- `node` Node.js
- `bun` Bun
- `edge-light` Vercel Edge Functions
- `fastly` Fastly Compute@EdgeThis package is properly typed and exported to both ESM and CJS.
## Installation
`detect-runtime` is published on [NPM](https://www.npmjs.com/package/detect-runtime):
```bash
# NPM
npm install detect-runtime
# Yarn
yarn add detect-runtime
# PNPM
pnpm install detect-runtime
# Bun
bun install detect-runtime
```Or in Deno:
```ts
import { ... } from 'npm:detect-runtime'
```## Usage
Import and call the `detectRuntime()` function from the `detect-runtime` package:
```ts
import { detectRuntime } from 'detect-runtime'const runtime = detectRuntime()
// ^? 'edge-routine' | 'workerd' | 'deno' | 'lagon' | 'react-native' | 'netlify | 'electron | 'node | 'bun | 'edge-light | 'unknown'
```You can also import the `Runtime` type which is the return type of `detectRuntime()`.
## License
[MIT](./LICENSE)