You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,8 @@ import {
82
82
has,
83
83
getDefault,
84
84
getThrow,
85
+
getTrimmedThrow,
86
+
getValidatedThrow,
85
87
86
88
getIntegerThrowInvalid, // equivalent to get
87
89
getIntegerDefault,
@@ -228,6 +230,8 @@ import {
228
230
has,
229
231
getDefault,
230
232
getThrow,
233
+
getTrimmedThrow,
234
+
getValidatedThrow,
231
235
232
236
getIntegerThrowInvalid, // equivalent to get
233
237
getIntegerDefault,
@@ -241,6 +245,8 @@ const {
241
245
has,
242
246
getDefault,
243
247
getThrow,
248
+
getTrimmedThrow,
249
+
getValidatedThrow,
244
250
245
251
getIntegerThrowInvalid, // equivalent to get
246
252
getIntegerDefault,
@@ -249,5 +255,18 @@ const {
249
255
250
256
console.log(`get('USER') >${get("USER")}`);
251
257
258
+
# Methods description
259
+
260
+
-`all()`: Returns a complete object containing all environment variables.
261
+
-`get(key)`: Retrieves an environment variable if it exists, otherwise returns `undefined`.
262
+
-`has(key)`: Checks if an environment variable exists.
263
+
-`getDefault(key, defaultValue)`: Retrieves an environment variable or returns the specified `defaultValue`if not found.
264
+
-`getThrow(key)`: Retrieves an environment variable or throws an error if it doesn't exist.
265
+
- `getTrimmedThrow(key)`: Retrieves, trims, and throws an error if the variable is missing or empty after trimming.
266
+
- `getValidatedThrow(key, validator)`: Retrieves and validates using a `RegExp` or a custom function. The validator function should return an error message `string` on failure, or `null`/`undefined` on success. It can also throw an error directly.
267
+
- `getIntegerThrowInvalid(key)`: Retrieves and converts to an integer. Throws if it exists but is not a valid integer.
268
+
- `getIntegerDefault(key, defaultValue)`: Retrieves as an integer, or returns `defaultValue` if not found or invalid.
269
+
- `getIntegerThrow(key)`: Retrieves as an integer, throws if missing or invalid.
0 commit comments