basant307/AI_Governance_Project
045
1# std-env2 3[](http://npmjs.com/package/std-env)4[](http://npmjs.com/package/std-env)5[](https://bundlephobia.com/result?p=std-env)6 7> Runtime agnostic JS utils8 9## Installation10 11```sh12# Using npm13npm i std-env14 15# Using pnpm16pnpm i std-env17 18# Using yarn19yarn add std-env20```21 22## Usage23 24```js25// ESM26import { env, isDevelopment, isProduction } from "std-env";27 28// CommonJS29const { env, isDevelopment, isProduction } = require("std-env");30```31 32## Flags33 34- `hasTTY`35- `hasWindow`36- `isDebug`37- `isDevelopment`38- `isLinux`39- `isMacOS`40- `isMinimal`41- `isProduction`42- `isTest`43- `isWindows`44- `platform`45- `isColorSupported`46- `nodeVersion`47- `nodeMajorVersion`48 49You can read more about how each flag works from [./src/flags.ts](./src/flags.ts).50 51## Provider Detection52 53`std-env` can automatically detect the current runtime provider based on environment variables.54 55You can use `isCI` and `platform` exports to detect it:56 57```ts58import { isCI, provider, providerInfo } from "std-env";59 60console.log({61 isCI, // true62 provider, // "github_actions"63 providerInfo, // { name: "github_actions", isCI: true }64});65```66 67List of well known providers can be found from [./src/providers.ts](./src/providers.ts).68 69## Runtime Detection70 71`std-env` can automatically detect the current JavaScript runtime based on global variables, following the [WinterCG Runtime Keys proposal](https://runtime-keys.proposal.wintercg.org/):72 73```ts74import { runtime, runtimeInfo } from "std-env";75 76// "" | "node" | "deno" | "bun" | "workerd" ...77console.log(runtime);78 79// { name: "node" }80console.log(runtimeInfo);81```82 83You can also use individual named exports for each runtime detection:84 85> [!NOTE]86> When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.87>88> Use `runtime === "node"` if you need strict check for Node.js runtime.89 90- `isNode`91- `isBun`92- `isDeno`93- `isNetlify`94- `isEdgeLight`95- `isWorkerd`96- `isFastly`97 98List of well known providers can be found from [./src/runtimes.ts](./src/runtimes.ts).99 100## Platform-Agnostic `env`101 102`std-env` provides a lightweight proxy to access environment variables in a platform agnostic way.103 104```ts105import { env } from "std-env";106```107 108## Platform-Agnostic `process`109 110`std-env` provides a lightweight proxy to access [`process`](https://nodejs.org/api/process.html) object in a platform agnostic way.111 112```ts113import { process } from "std-env";114```115 116## License117 118MIT119 