@okou/typed-env
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

About

Simple typed-parser of process.env .
This is NOT a loader of .env such as Dotenv.

Usage

STR = hogehoge
NUM = 1234.5
BOOL = true, false, 0, 1
INT = 123456789
import { load } from 'env-typed';

// env-name: type
const Env = load({
  STR: 'string',
  NUM: 'number',
  BOOL: 'boolean[]',
  INT: 'bigint',
});

/*
Env:{
  STR: 'hogehoge',
  NUM: 1234.5,
  BOOL: [ true, false, true, false ],
  INT: 123456789n
}

typeof Env = {
  STR: string;
  NUM: number;
  BOOL: boolean[];
  INT: bigint;
}
*/

Note

  • Strings 'false', '0' and '' (blank) are parsed as boolean when specified boolean.

Usabel types

  • string
  • number
  • boolean
  • bigint
  • Array of these

Readme

Keywords

Package Sidebar

Install

npm i @okou/typed-env

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

11.6 kB

Total Files

21

Last publish

Collaborators

  • okou