Socket
Book a DemoInstallSign in
Socket

@echristian/env

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@echristian/env

Small wrapper around std-env

0.0.6
latest
npmnpm
Version published
Weekly downloads
1
-50%
Maintainers
0
Weekly downloads
 
Created
Source

@ericc/env

A simple wrapper around std-env, providing a convenient interface for environment variable handling.

Installation

npm i @echristian/env std-env
deno add jsr:@ericc/env jsr:@std/env

Dependencies

This package requires std-env as a peer dependency. Make sure to install it alongside this package:

  • std-env >= 3.0.0

Why?

This package provides a simplified interface for common environment variable operations:

  • Throw when required environment variable does not exist
  • Fallback to default value for optional variable
  • Avoid repeatedly writing optional chaining and error throwing (with this the value won't be Value | undefined)

Usage

import { getEnv } from "@ericc/env";
import { env } from "std-env";

// Using getEnv helper
const API_KEY = getEnv("API_KEY"); // throws if not found
const IMAGE_DIR = getEnv("IMAGE_DIR", "/tmp"); // with fallback

// Use std-env directly for its exports
console.log(env.NODE_ENV);
console.log(env.platform);

Check out std-env because unjs is awesome.

Keywords

utils

FAQs

Package last updated on 10 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.