shelving
Version:
Toolkit for using data in JavaScript.
22 lines (21 loc) • 1.15 kB
TypeScript
import type { AnyCaller } from "./function.js";
/**
* Get a `process.env` variable safely in all environments, or `undefined` if it doesn't exist or this environment does not support `process.env` (i.e. web environments).
*/
export declare function getEnv(name: string): string | undefined;
/**
* Get a `process.env` variable safely in all environments, or throw `RequiredError` if it doesn't exist or this environment does not support `process.env` (i.e. web environments).
*/
export declare function requireEnv(name: string, caller?: AnyCaller): string;
/**
* Get a `process.env` variable and resolve it to to `true` or `false`, or `undefined` if it isn't a true/false value.
*/
export declare function getEnvBoolean(name: string): boolean | undefined;
/**
* Get a `process.env` variable and resolve it to to `true` or `false`
*
* @returns `false` if the environment variable is `0`, `off`, `no`, `false`
* @returns `true` if the environment variable is `1`, `on`, `yes`, `true`
* @throws `RequiredError` if the env variable is any other value.
*/
export declare function requireEnvBoolean(name: string, caller?: AnyCaller): boolean;