Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@valu/env

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@valu/env

Tiny helper for managing enviroment variables type safely.

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@valu/env

Tiny helper for managing enviroment variables type safely.

Install

npm install @valu/env

Usage

import { TypedEnv } from "@valu/env";

type AllowedKeys = "FOO" | "BAR";

const env = new TypedEnv<AllowedKeys>(process.env);

Reading

// Get value in FOO env. Throws if FOO is not defined. The return type is always
// `string`.
const value = env.get("FOO");

// Type error
const value = env.get("WAT");

// Second argument can be used for default values to avoid throwing.
const value = env.get("FOO", "default");

// Use null as the default the get return value of `string | null` without
// throwing
const value = env.get("FOO", null);

Mutation

// Set env var
env.set("FOO", "value");

// Delete env var
env.delete("FOO");

FAQs

Package last updated on 20 Jun 2022

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc