@hugoalh/env
v0.4.0
Published
A module for enhanced environment variables operation.
Downloads
238
Readme
Env (ES)
🔗 DistBoard @hugoalh ● GitHub ● JSR ● NPM
An ECMAScript module for enhanced environment variables operation.
🎯 Runtime Targets
Any runtime which support ECMAScript should able to use this; These runtimes are officially supported:
🛡️ Runtime Permissions
- Environment Variable (Deno:
env)PATH(Optional)PATHEXT(Optional, Windows Platforms)
- File System - Read (Deno:
read; NodeJS:fs-read) (Optional) - System Info (Deno:
sys)gid(Optional, POSIX/UNIX Platforms)uid(Optional, POSIX/UNIX Platforms)
#️⃣ Sources & Entrypoints
- GitHub Raw
https://raw.githubusercontent.com/hugoalh/env-es/{Tag}/mod.ts - JSR
jsr:@hugoalh/env[@{Tag}] - NPM
npm:@hugoalh/env[@{Tag}]
| Name | Path | Description |
|:--|:--|:--|
| . | ./mod.ts | Default. |
| ./delimitation | ./delimitation.ts | Environment variable operation with delimitation. |
| ./executable | ./executable.ts | Path execution operation. |
| ./general | ./general.ts | General operation. |
| ./path | ./path.ts | PATH operation. |
| ./pathext | ./pathext.ts | PATHEXT operation. |
[!NOTE]
- Different runtimes have vary support for the sources and entrypoints, visit the runtime documentation for more information.
- It is recommended to include tag for immutability.
- These are not part of the public APIs hence should not be used:
- Benchmark/Test file (e.g.:
example.bench.ts,example.test.ts).- Entrypoint name or path include any underscore prefix (e.g.:
_example.ts,foo/_example.ts).- Identifier/Namespace/Symbol include any underscore prefix (e.g.:
_example,Foo._example).
🧩 APIs
function deleteEnv(key: string | RegExp): void;function getAllEnv(): Record<string, string | undefined>;function getEnv(key: string): string | undefined;function hasEnv(key: string | RegExp): boolean;function setEnv(key: string, value: string): void;function deleteEnvPath(...values: readonly (string | RegExp)[]): void;function getEnvPath(): string[];function hasEnvPath(value: string | RegExp): boolean;function pushEnvPath(...values: readonly string[]): void;function deleteEnvPathExt(...values: readonly string[]): void;function getEnvPathExt(): string[];function pushEnvPathExt(...values: readonly string[]): void;
[!NOTE]
- For the full or prettier documentation, can visit via:
✍️ Examples
setEnv("SOME_VAR", "Value"); hasEnv("SOME_VAR"); //=> true getEnv("SOME_VAR"); //=> "Value"
