npm.io
1.14.1 • Published 6d ago

@arcjet/runtime

Licence
Apache-2.0
Version
1.14.1
Deps
0
Size
17 kB
Vulns
0
Weekly
0
Stars
685
Arcjet Logo

@arcjet/runtime

npm badge

Arcjet runtime detection.

This package attempts to discover and provide runtime keys as defined by the WinterCG.

What is this?

This is an internal utility to help us figure out what platform we are running on. It’s a fork of unjs/std-env. We chose to fork so that we can cut away functionality that we do not use and keep our dependency tree as light as possible. We only need the runtime detection.

When should I use this?

You should not use this but use unjs/std-env or one of the alternatives instead. This package matches our current needs which are likely different from yours.

Install

This package is ESM only. Install with npm in Node.js:

npm install @arcjet/runtime

Use

import { runtime } from "@arcjet/runtime";

console.log(runtime()); // => "bun" or "node" and such

API

This package exports the identifier runtime. There is no default export.

This package exports the TypeScript type Runtime.

Runtime

This type represents the runtime environments that can be detected.

Type
type Runtime = "workerd" | "deno" | "node" | "bun" | "edge-light" | "";
runtime()

Detects which runtime environment your code is currently running in.

Returns

The detected runtime (string), or an empty string if the runtime could not be determined.

License

Apache License, Version 2.0 Arcjet Labs, Inc.

Derivative work based on std-env licensed under MIT Pooya Parsa. Our work cherry picks only what we need.

Keywords