1.0.0 • Published 3 years ago
@okou/typed-env v1.0.0
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 = 123456789import { 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 asbooleanwhen specified boolean.
Usabel types
stringnumberbooleanbigint- Array of these
1.0.0
3 years ago