Skip to content

Commit 91ed4ad

Browse files
committed
docs: update changelog and environment documentation for parameter reordering in getEnum and getNumberEnum methods
1 parent c956a07 commit 91ed4ad

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [1.0.4] - 2025-10-09
4+
5+
### Changed
6+
- **Utils**
7+
- Reordered parameters in `Env.getEnum` and `Env.getNumberEnum` for improved clarity and usability.
8+
- New signature: `(key, defaultValue, allowedValues)`.
9+
- Previous signature: `(key, allowedValues, defaultValue)`.
10+
- Updated related documentation and examples to reflect this change.
11+
312
## [1.0.3] - 2025-10-03
413
### Added
514
- **Server**

docs/docs/utils/environment.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Provides a single `Env` class with static methods for reading, validating, and t
3636
- [**`getJSON<T>(key: string, defaultValue: T): T`**](#getjson) - Parses a JSON object from an environment variable.
3737
- [**`getArray<T>(key: string, defaultValue?: T[], splitter?: string, transform?: (item: string) => T): T[]`**](#getarray) - Parses a delimited string as an array, with optional transformation.
3838
- [**`getNumberArray(key: string, defaultValue?: number[], splitter?: string): number[]`**](#getnumberarray) - Parses a delimited string as an array of numbers.
39-
- [**`getEnum<T extends string>(key: string, allowedValues: readonly T[], defaultValue: T): T`**](#getenum) - Gets an enum environment variable, throws if not a valid value.
40-
- [**`getNumberEnum(key: string, allowedValues: number[], defaultValue: number): number`**](#getnumberenum) - Gets a number enum environment variable, throws if not a valid value.
39+
- [**`getEnum<T extends string>(key: string, defaultValue: T, allowedValues: readonly T[]): T`**](#getenum) - Gets an enum environment variable, throws if not a valid value.
40+
- [**`getNumberEnum(key: string, defaultValue: number, allowedValues: number[]): number`**](#getnumberenum) - Gets a number enum environment variable, throws if not a valid value.
4141
- [**`getUrl(key: string, defaultValue: string, options?: UrlOptions): string`**](#geturl) - Gets a URL environment variable, with optional validation.
4242
- [**`getEmail(key: string, defaultValue: string): string`**](#getemail) - Gets an email environment variable, with basic validation.
4343
- [**`getPath(key: string, defaultValue: string, options?: PathOptions): string`**](#getpath) - Gets a path environment variable, with optional validation.
@@ -485,13 +485,13 @@ Gets an environment variable as a string enum, validates allowed values.
485485

486486
**Method Signature:**
487487
```ts
488-
getEnum<T extends string>(key: string, allowedValues: readonly T[], defaultValue: T): T
488+
getEnum<T extends string>(key: string, defaultValue: T, allowedValues: readonly T[]): T
489489
```
490490
491491
**Parameters:**
492492
- `key`: The name of the environment variable to get.
493-
- `allowedValues`: The list of allowed string values.
494493
- `defaultValue`: The default value to return if the environment variable is not set or invalid.
494+
- `allowedValues`: The list of allowed string values.
495495
496496
**Returns:**
497497
- The value of the environment variable if valid, otherwise the default value.
@@ -503,7 +503,7 @@ getEnum<T extends string>(key: string, allowedValues: readonly T[], defaultValue
503503
```ts
504504
import { Env } from "@catbee/utils";
505505

506-
Env.getEnum('LOG_LEVEL', ['debug', 'info', 'warn', 'error'] as const, 'info'); // 'debug', 'info', etc.
506+
Env.getEnum('LOG_LEVEL', 'info', ['debug', 'info', 'warn', 'error'] as const);
507507
```
508508

509509
---
@@ -513,13 +513,13 @@ Gets an environment variable as a number enum, validates allowed values.
513513

514514
**Method Signature:**
515515
```ts
516-
getNumberEnum(key: string, allowedValues: number[], defaultValue: number): number
516+
getNumberEnum(key: string, defaultValue: number, allowedValues: number[]): number
517517
```
518518

519519
**Parameters:**
520520
- `key`: The name of the environment variable to get.
521-
- `allowedValues`: The list of allowed number values.
522521
- `defaultValue`: The default value to return if the environment variable is not set or invalid.
522+
- `allowedValues`: The list of allowed number values.
523523

524524
**Returns:**
525525
- The numeric value of the environment variable if valid, otherwise the default value.
@@ -531,7 +531,7 @@ getNumberEnum(key: string, allowedValues: number[], defaultValue: number): numbe
531531
```ts
532532
import { Env } from "@catbee/utils";
533533

534-
Env.getNumberEnum('NODE_VERSION', [14, 16, 18], 16); // 14, 16, or 18
534+
Env.getNumberEnum('NODE_VERSION', 16, [14, 16, 18]);
535535
```
536536

537537
---

docs/docusaurus.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const config: Config = {
230230
label: 'Docs',
231231
},
232232
{ to: '/license/', label: 'License', position: 'left' },
233-
{ to: '/changelog/', label: 'Changelog', position: 'left' },
233+
// { to: '/changelog/', label: 'Changelog', position: 'left' },
234234
// { to: '/contributors', label: 'Contributors', position: 'left' },
235235
{ href: 'https://github.com/catbee-technologies/catbee-utils', label: 'GitHub', position: 'right' },
236236
{ href: 'https://www.npmjs.com/package/@catbee/utils', label: 'NPM', position: 'right' }

0 commit comments

Comments
 (0)