@catbee/utils 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.cjs CHANGED
@@ -402,17 +402,17 @@ var Env = class _Env {
402
402
  *
403
403
  * @typeParam T - The allowed value type (string literal types).
404
404
  * @param {string} key - The environment variable key.
405
- * @param {T[]} allowedValues - Array of accepted string values.
406
405
  * @param {T} [defaultValue] - Optional fallback value.
406
+ * @param {T[]} allowedValues - Array of accepted string values.
407
407
  * @returns {T} The validated environment value.
408
408
  * @throws {Error} If missing or invalid.
409
409
  *
410
410
  * @example
411
411
  * // If LOG_LEVEL=debug
412
- * const level = Env.getEnum('LOG_LEVEL', ['debug', 'info', 'warn', 'error'] as const, 'info');
412
+ * const level = Env.getEnum('LOG_LEVEL', 'info', ['debug', 'info', 'warn', 'error'] as const);
413
413
  * // 'debug' (typed as 'debug' | 'info' | 'warn' | 'error')
414
414
  */
415
- static getEnum(key, allowedValues, defaultValue) {
415
+ static getEnum(key, defaultValue, allowedValues) {
416
416
  const value = process.env[key];
417
417
  if (!value) {
418
418
  return defaultValue;
@@ -426,15 +426,15 @@ var Env = class _Env {
426
426
  * Retrieves an enum-like numeric environment variable.
427
427
  *
428
428
  * @param {string} key - The environment variable key.
429
- * @param {number[]} allowedValues - Array of accepted values.
430
429
  * @param {number} defaultValue - Default value if not present.
430
+ * @param {number[]} allowedValues - Array of accepted values.
431
431
  * @returns {number} The validated value.
432
432
  *
433
433
  * @example
434
434
  * // If NODE_VERSION=16
435
- * const version = Env.getNumberEnum('NODE_VERSION', [14, 16, 18], 16);
435
+ * const version = Env.getNumberEnum('NODE_VERSION', 16, [14, 16, 18]);
436
436
  */
437
- static getNumberEnum(key, allowedValues, defaultValue) {
437
+ static getNumberEnum(key, defaultValue, allowedValues) {
438
438
  const value = _Env.getNumber(key, defaultValue);
439
439
  if (!allowedValues.includes(value)) {
440
440
  throw new Error(`Environment variable '${key}' must be one of: ${allowedValues.join(", ")}. Received: ${value}`);
package/build/index.d.ts CHANGED
@@ -2437,30 +2437,30 @@ declare class Env {
2437
2437
  *
2438
2438
  * @typeParam T - The allowed value type (string literal types).
2439
2439
  * @param {string} key - The environment variable key.
2440
- * @param {T[]} allowedValues - Array of accepted string values.
2441
2440
  * @param {T} [defaultValue] - Optional fallback value.
2441
+ * @param {T[]} allowedValues - Array of accepted string values.
2442
2442
  * @returns {T} The validated environment value.
2443
2443
  * @throws {Error} If missing or invalid.
2444
2444
  *
2445
2445
  * @example
2446
2446
  * // If LOG_LEVEL=debug
2447
- * const level = Env.getEnum('LOG_LEVEL', ['debug', 'info', 'warn', 'error'] as const, 'info');
2447
+ * const level = Env.getEnum('LOG_LEVEL', 'info', ['debug', 'info', 'warn', 'error'] as const);
2448
2448
  * // 'debug' (typed as 'debug' | 'info' | 'warn' | 'error')
2449
2449
  */
2450
- static getEnum<T extends string>(key: string, allowedValues: readonly T[], defaultValue: T): T;
2450
+ static getEnum<T extends string>(key: string, defaultValue: T, allowedValues: readonly T[]): T;
2451
2451
  /**
2452
2452
  * Retrieves an enum-like numeric environment variable.
2453
2453
  *
2454
2454
  * @param {string} key - The environment variable key.
2455
- * @param {number[]} allowedValues - Array of accepted values.
2456
2455
  * @param {number} defaultValue - Default value if not present.
2456
+ * @param {number[]} allowedValues - Array of accepted values.
2457
2457
  * @returns {number} The validated value.
2458
2458
  *
2459
2459
  * @example
2460
2460
  * // If NODE_VERSION=16
2461
- * const version = Env.getNumberEnum('NODE_VERSION', [14, 16, 18], 16);
2461
+ * const version = Env.getNumberEnum('NODE_VERSION', 16, [14, 16, 18]);
2462
2462
  */
2463
- static getNumberEnum(key: string, allowedValues: number[], defaultValue: number): number;
2463
+ static getNumberEnum(key: string, defaultValue: number, allowedValues: number[]): number;
2464
2464
  /**
2465
2465
  * Retrieves a URL environment variable and validates it.
2466
2466
  *
package/build/index.mjs CHANGED
@@ -390,17 +390,17 @@ var Env = class _Env {
390
390
  *
391
391
  * @typeParam T - The allowed value type (string literal types).
392
392
  * @param {string} key - The environment variable key.
393
- * @param {T[]} allowedValues - Array of accepted string values.
394
393
  * @param {T} [defaultValue] - Optional fallback value.
394
+ * @param {T[]} allowedValues - Array of accepted string values.
395
395
  * @returns {T} The validated environment value.
396
396
  * @throws {Error} If missing or invalid.
397
397
  *
398
398
  * @example
399
399
  * // If LOG_LEVEL=debug
400
- * const level = Env.getEnum('LOG_LEVEL', ['debug', 'info', 'warn', 'error'] as const, 'info');
400
+ * const level = Env.getEnum('LOG_LEVEL', 'info', ['debug', 'info', 'warn', 'error'] as const);
401
401
  * // 'debug' (typed as 'debug' | 'info' | 'warn' | 'error')
402
402
  */
403
- static getEnum(key, allowedValues, defaultValue) {
403
+ static getEnum(key, defaultValue, allowedValues) {
404
404
  const value = process.env[key];
405
405
  if (!value) {
406
406
  return defaultValue;
@@ -414,15 +414,15 @@ var Env = class _Env {
414
414
  * Retrieves an enum-like numeric environment variable.
415
415
  *
416
416
  * @param {string} key - The environment variable key.
417
- * @param {number[]} allowedValues - Array of accepted values.
418
417
  * @param {number} defaultValue - Default value if not present.
418
+ * @param {number[]} allowedValues - Array of accepted values.
419
419
  * @returns {number} The validated value.
420
420
  *
421
421
  * @example
422
422
  * // If NODE_VERSION=16
423
- * const version = Env.getNumberEnum('NODE_VERSION', [14, 16, 18], 16);
423
+ * const version = Env.getNumberEnum('NODE_VERSION', 16, [14, 16, 18]);
424
424
  */
425
- static getNumberEnum(key, allowedValues, defaultValue) {
425
+ static getNumberEnum(key, defaultValue, allowedValues) {
426
426
  const value = _Env.getNumber(key, defaultValue);
427
427
  if (!allowedValues.includes(value)) {
428
428
  throw new Error(`Environment variable '${key}' must be one of: ${allowedValues.join(", ")}. Received: ${value}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catbee/utils",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A modular, production-grade utility toolkit for Node.js and TypeScript, designed for robust, scalable applications (including Express-based services). All utilities are tree-shakable and can be imported independently.",
5
5
  "main": "build/index.cjs",
6
6
  "module": "build/index.mjs",