std-env

  • Version 3.8.0
  • Published
  • 25.9 kB
  • No dependencies
  • MIT license

Install

npm i std-env
yarn add std-env
pnpm add std-env

Overview

Runtime agnostic JS utils

Index

Variables

variable env

const env: EnvObject;

    variable hasTTY

    const hasTTY: boolean;
    • Detect if stdout.TTY is available

    variable hasWindow

    const hasWindow: boolean;
    • Detect if global window object is available

    variable isBun

    const isBun: boolean;
    • Indicates if running in Bun runtime.

    variable isCI

    const isCI: boolean;
    • Detect if CI environment variable is set or a provider CI detected

    variable isColorSupported

    const isColorSupported: boolean;
    • Color Support

    variable isDebug

    const isDebug: boolean;
    • Detect if DEBUG environment variable is set

    variable isDeno

    const isDeno: boolean;
    • Indicates if running in Deno runtime.

    variable isDevelopment

    const isDevelopment: boolean;
    • Detect if NODE_ENV environment variable is dev or development

    variable isEdgeLight

    const isEdgeLight: boolean;
    • Indicates if running in EdgeLight (Vercel Edge) runtime.

    variable isFastly

    const isFastly: boolean;
    • Indicates if running in Fastly runtime.

    variable isLinux

    const isLinux: boolean;
    • Detect if process.platform is Linux

    variable isMacOS

    const isMacOS: boolean;
    • Detect if process.platform is macOS (darwin kernel)

    variable isMinimal

    const isMinimal: boolean;
    • Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable

    variable isNetlify

    const isNetlify: boolean;
    • Indicates if running in Netlify runtime.

    variable isNode

    const isNode: boolean;
    • Indicates if running in Node.js or a Node.js compatible runtime.

      **Note:** 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.

      Use runtime === "node" if you need strict check for Node.js runtime.

    variable isProduction

    const isProduction: boolean;
    • Detect if NODE_ENV environment variable is production

    variable isTest

    const isTest: boolean;
    • Detect if NODE_ENV environment variable is test

    variable isWindows

    const isWindows: boolean;
    • Detect if process.platform is Windows

    variable isWorkerd

    const isWorkerd: boolean;
    • Indicates if running in Cloudflare Workers runtime.

    variable nodeENV

    const nodeENV: string;

      variable nodeMajorVersion

      const nodeMajorVersion: number;

        variable nodeVersion

        const nodeVersion: string;
        • Node.js versions

        variable platform

        const platform: NodeJS.Platform;
        • Value of process.platform

        variable process

        const process: Process;

          variable provider

          const provider: ProviderName;

            variable providerInfo

            const providerInfo: ProviderInfo;
            • Current provider info

            variable runtime

            const runtime: RuntimeName;

              variable runtimeInfo

              const runtimeInfo: RuntimeInfo;

                Interfaces

                interface Process

                interface Process extends Partial<Omit<typeof globalThis.process, 'versions'>> {}

                  property env

                  env: EnvObject;

                    property versions

                    versions: Record<string, string>;

                      Type Aliases

                      type EnvObject

                      type EnvObject = Record<string, string | undefined>;

                        type ProviderInfo

                        type ProviderInfo = {
                        name: ProviderName;
                        ci?: boolean;
                        [meta: string]: any;
                        };

                          type ProviderName

                          type ProviderName =
                          | ''
                          | 'appveyor'
                          | 'aws_amplify'
                          | 'azure_pipelines'
                          | 'azure_static'
                          | 'appcircle'
                          | 'bamboo'
                          | 'bitbucket'
                          | 'bitrise'
                          | 'buddy'
                          | 'buildkite'
                          | 'circle'
                          | 'cirrus'
                          | 'cloudflare_pages'
                          | 'codebuild'
                          | 'codefresh'
                          | 'drone'
                          | 'drone'
                          | 'dsari'
                          | 'github_actions'
                          | 'gitlab'
                          | 'gocd'
                          | 'layerci'
                          | 'hudson'
                          | 'jenkins'
                          | 'magnum'
                          | 'netlify'
                          | 'nevercode'
                          | 'render'
                          | 'sail'
                          | 'semaphore'
                          | 'screwdriver'
                          | 'shippable'
                          | 'solano'
                          | 'strider'
                          | 'teamcity'
                          | 'travis'
                          | 'vercel'
                          | 'appcenter'
                          | 'codesandbox'
                          | 'stackblitz'
                          | 'stormkit'
                          | 'cleavr'
                          | 'zeabur'
                          | 'codesphere'
                          | 'railway'
                          | 'deno-deploy'
                          | 'firebase_app_hosting';

                            type RuntimeInfo

                            type RuntimeInfo = {
                            name: RuntimeName;
                            };

                              type RuntimeName

                              type RuntimeName =
                              | 'workerd'
                              | 'deno'
                              | 'netlify'
                              | 'node'
                              | 'bun'
                              | 'edge-light'
                              | 'fastly'
                              | '';

                                Package Files (1)

                                Dependencies (0)

                                No dependencies.

                                Dev Dependencies (12)

                                Peer Dependencies (0)

                                No peer dependencies.

                                Badge

                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/std-env.

                                • Markdown
                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/std-env)
                                • HTML
                                  <a href="https://www.jsdocs.io/package/std-env"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>