New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

read-env-value

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-env-value

Read env with default value

Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
1.2K
-1.71%
Maintainers
1
Weekly downloads
 
Created
Source

read-env-value

JSR JSR Score NPM Version NPM Downloads NPM License codecov GitHub Workflow Status PRs Welcome CodeRabbit Pull Request Reviews

Read env with default value

Usage

import { env } from 'read-env-value';

// read env 'NODE_ENV' with default value 'development'
const value = env('NODE_ENV', 'string', 'development');

API

env(key: string, type: 'string' | 'number' | 'boolean', defaultValue?: string | number | boolean)

Parameters

  • key: The environment variable key to read.
  • type: The type of the value to be returned.
  • defaultValue: The default value to return if the environment variable is not set.

Returns

  • The value of the environment variable.

Example

import { env } from 'read-env-value';

const value = env('NODE_ENV', 'string', 'development');

License

MIT

Contributors

Contributors

Made with contributors-img.

Keywords

env

FAQs

Package last updated on 10 May 2025

Related posts