# @valu/env

> Tiny helper for managing enviroment variables type safely.

Latest version **1.1.0** (published 2022-06-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install @valu/env
pnpm add @valu/env
yarn add @valu/env
bun add @valu/env
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-06-20 |
| First published | 2022-05-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Esa-Matti Suuronen |
| Maintainers | saulirajala, valudigital, esamatti, joonasvaris |

## Links

- npm: https://www.npmjs.com/package/@valu/env
- npm.io page: https://npm.io/package/@valu/env

## Recent versions

- 1.1.0 (latest) — 2022-06-20
- 1.0.1 — 2022-05-09
- 1.0.0 — 2022-05-09

## README

# `@valu/env`

Tiny helper for managing enviroment variables type safely.

## Install

```
npm install @valu/env
```

## Usage

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

type AllowedKeys = "FOO" | "BAR";

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

Reading

```ts
// 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

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

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

---
_Source: https://npm.io/package/@valu/env · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
