Gets an array of all definitely assigned key-value pairs from the underlying envar store.
Gets a boolean
value for a given key. Returns the default value if no value was found.
The name of the envar.
A default boolean, which itself defaults to false
if not otherwise supplied.
Gets a string
value from a finite set of expected values derived from the keys of a given object of type T
,
matched case-insensitively. An optional transform
may be provided that will preprocess both the found value
and any provided default before testing for membership in the target object's key set.
The name of the envar.
The object providing the keys to test with.
A transform function applied to both the default and value before testing that
either is a key of T
.
enum Mode { TEST = 'test', DEMO = 'demo' }
env.setString('MY_ENVAR', Mode.DEMO);
const check = env.getString('MY_ENVAR');
// check -> 'demo'
// typeof check -> string
const value = env.getKeyOf('MY_ENVAR', Mode, v => v.toUpperCase());
// value -> 'DEMO'
// typeof value -> 'TEST' | 'DEMO' (i.e. Extract<keyof typeof Mode, string>)
const enumValue = Mode[value];
// enumValue -> 'demo'
// typeof enumValue -> Mode
Gets a string
value from a finite set of expected values derived from the keys of a given object of type T
,
matched case-insensitively, using a default if not found. An optional transform
may be provided that will
preprocess both the found value and any provided default before testing for membership in the target object's
key set.
The name of the envar.
The object providing the keys to test with.
A default value.
A transform function applied to both the default and value before testing that
either is a key of T
.
Gets a list of string
values for a given key by splitting the raw value on ,
chars.
The name of the envar.
Gets a list of string
values for a given key by splitting the raw value on ,
chars.
The name of the envar.
A default list of values.
Gets a string
value for a given key.
The name of the envar.
Gets a string
value for a given key.
The name of the envar.
A default value.
Gets a string
value from a finite set of expected values, matched case-insensitively.
The name of the envar.
The finite set of expected values.
Gets a string
value from a finite set of expected values, matched case-insensitively, using a default if
not found.
The name of the envar.
The finite set of expected values.
A default value.
Sets a boolean
value for a given key, or removes the current value when no value is given.
The name of the envar.
The value to set.
Sets a string
value from a list for a given key by joining values with a ,
into a raw string
value,
or removes the current value when no value is given.
The name of the envar.
The values to set.
Sets a string
value for a given key, or removes the current value when no value is given.
The name of the envar.
The value to set.
Unsets a value for a given key.
The name of the envar.
An injectable abstraction on top of
process.env
with various convenience functions for accessing environment variables of different anticipated shapes.