@rzl-zone/utils-js 3.5.7 → 3.7.0

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.
Files changed (119) hide show
  1. package/README.md +1 -1
  2. package/dist/assertions/index.cjs +1 -1
  3. package/dist/assertions/index.d.ts +1 -1
  4. package/dist/assertions/index.js +1 -1
  5. package/dist/chunk-2CQI36UD.cjs +1 -1
  6. package/dist/chunk-2VO2CBTU.js +1 -1
  7. package/dist/chunk-3KTD3QDI.js +1 -1
  8. package/dist/{chunk-RS5RBLPB.js → chunk-3LEWQV3R.js} +46 -8
  9. package/dist/chunk-4ACKNPL5.js +1 -1
  10. package/dist/chunk-4ZOXSUXB.js +1 -1
  11. package/dist/chunk-5NN4ZDE2.cjs +1 -1
  12. package/dist/chunk-66WLOZOD.cjs +1 -1
  13. package/dist/{chunk-6DSPJA5U.js → chunk-6PKW4WCT.js} +2 -2
  14. package/dist/chunk-6RFNZ2ZZ.cjs +1 -1
  15. package/dist/chunk-6WMB5AJR.js +1 -1
  16. package/dist/chunk-7QQV66RX.cjs +1 -1
  17. package/dist/chunk-7WBMA2VE.cjs +1 -1
  18. package/dist/chunk-7ZNEUWYP.js +1 -1
  19. package/dist/chunk-A3YI6Y2P.js +1 -1
  20. package/dist/chunk-ABA2ZSBQ.js +1 -1
  21. package/dist/chunk-AKKM6MOX.cjs +1 -1
  22. package/dist/chunk-ATLFMKAF.cjs +1 -1
  23. package/dist/chunk-B4SDEBN7.cjs +1 -1
  24. package/dist/chunk-B6UIKBHR.cjs +1 -1
  25. package/dist/chunk-BAV5T2E3.cjs +1 -1
  26. package/dist/chunk-BG3AS5BU.cjs +173 -0
  27. package/dist/chunk-BYUT376O.cjs +1 -1
  28. package/dist/{chunk-RIEYB2AW.cjs → chunk-CKUEZF4R.cjs} +1 -1
  29. package/dist/chunk-D53CE4BT.js +1 -1
  30. package/dist/chunk-DPLL67OT.js +1 -1
  31. package/dist/chunk-DVMHRLKP.cjs +1 -1
  32. package/dist/chunk-EK7FSI7F.cjs +1 -1
  33. package/dist/chunk-F3WBQKRI.cjs +1 -1
  34. package/dist/chunk-FI76UZRF.js +1 -1
  35. package/dist/chunk-GAJBF6DR.js +1 -1
  36. package/dist/chunk-JY4HLZ4W.js +1 -1
  37. package/dist/chunk-K3SONK25.cjs +1 -1
  38. package/dist/chunk-K63WO3XA.cjs +1 -1
  39. package/dist/chunk-KHO2SBNA.cjs +1 -1
  40. package/dist/{chunk-TPYENEQ4.cjs → chunk-KIYALQQF.cjs} +44 -9
  41. package/dist/chunk-KPCDDYTZ.js +1 -1
  42. package/dist/chunk-KTQLDIIT.cjs +1 -1
  43. package/dist/chunk-L5RDAVVH.js +1 -1
  44. package/dist/chunk-LEX4TQW2.js +1 -1
  45. package/dist/chunk-LIU4S3JA.cjs +1 -1
  46. package/dist/chunk-NREACG6M.cjs +1 -1
  47. package/dist/chunk-OFBFGFVH.js +1 -1
  48. package/dist/chunk-ONZFBJVW.js +1 -1
  49. package/dist/chunk-OS5OT5JA.cjs +1 -1
  50. package/dist/chunk-PZQC3FZY.js +1 -1
  51. package/dist/chunk-QAPYHLHC.cjs +1 -1
  52. package/dist/chunk-QNKGP5DY.js +1 -1
  53. package/dist/chunk-QUITZ3GP.js +1 -1
  54. package/dist/{chunk-H5NWBTHW.cjs → chunk-R3PBF6F7.cjs} +11 -11
  55. package/dist/chunk-RMJC3B5P.cjs +1 -1
  56. package/dist/chunk-SZJ7OI4S.js +1 -1
  57. package/dist/chunk-TDPYR5JY.js +1 -1
  58. package/dist/chunk-TDYGYHSH.js +1 -1
  59. package/dist/chunk-TFDXRT6D.cjs +1 -1
  60. package/dist/{chunk-SN6YRDLG.js → chunk-U5VR4TJN.js} +1 -1
  61. package/dist/chunk-UDA26MCU.cjs +1 -1
  62. package/dist/chunk-UKAUXY2U.cjs +1 -1
  63. package/dist/chunk-VCVND6CH.js +1 -1
  64. package/dist/chunk-VJDDGRIK.cjs +1 -1
  65. package/dist/chunk-VJVCXEH7.cjs +1997 -0
  66. package/dist/chunk-VNADVWSJ.js +1 -1
  67. package/dist/chunk-WNO3EPYT.js +170 -0
  68. package/dist/chunk-WVSPXFTY.js +1 -1
  69. package/dist/chunk-XFTUHS4Y.js +1 -1
  70. package/dist/chunk-YC7AK3KX.cjs +1 -1
  71. package/dist/chunk-YGB2BQPB.cjs +1 -1
  72. package/dist/chunk-YS27V6LS.js +1994 -0
  73. package/dist/chunk-YWHHVDT4.js +1 -1
  74. package/dist/chunk-ZN53RM3R.js +1 -1
  75. package/dist/conversions/index.cjs +1 -1
  76. package/dist/conversions/index.d.ts +1 -1
  77. package/dist/conversions/index.js +1 -1
  78. package/dist/events/index.cjs +1 -1
  79. package/dist/events/index.d.ts +1 -1
  80. package/dist/events/index.js +1 -1
  81. package/dist/formatters/index.cjs +1 -1
  82. package/dist/formatters/index.d.ts +1 -1
  83. package/dist/formatters/index.js +1 -1
  84. package/dist/generators/index.cjs +1 -1
  85. package/dist/generators/index.d.ts +1 -1
  86. package/dist/generators/index.js +1 -1
  87. package/dist/index.d.ts +1 -1
  88. package/dist/isPlainObject-FWmcJF6k.d.ts +1 -1
  89. package/dist/next/index.cjs +9 -8
  90. package/dist/next/index.d.ts +1 -1
  91. package/dist/next/index.js +3 -2
  92. package/dist/next/server/index.cjs +1 -1
  93. package/dist/next/server/index.d.ts +1 -1
  94. package/dist/next/server/index.js +1 -1
  95. package/dist/operations/index.cjs +1 -1
  96. package/dist/operations/index.d.ts +1 -1
  97. package/dist/operations/index.js +1 -1
  98. package/dist/parsers/index.cjs +1 -1
  99. package/dist/parsers/index.d.ts +1 -1
  100. package/dist/parsers/index.js +1 -1
  101. package/dist/predicates/index.cjs +33 -28
  102. package/dist/predicates/index.d.ts +142 -2
  103. package/dist/predicates/index.js +3 -2
  104. package/dist/promises/index.cjs +1 -1
  105. package/dist/promises/index.d.ts +1 -1
  106. package/dist/promises/index.js +1 -1
  107. package/dist/rzl-utils.global.js +2 -2
  108. package/dist/strings/index.cjs +1 -1
  109. package/dist/strings/index.d.ts +1 -1
  110. package/dist/strings/index.js +1 -1
  111. package/dist/tailwind/index.cjs +13 -9
  112. package/dist/tailwind/index.d.ts +124 -19
  113. package/dist/tailwind/index.js +2 -2
  114. package/dist/urls/index.cjs +14 -9
  115. package/dist/urls/index.d.ts +268 -19
  116. package/dist/urls/index.js +4 -3
  117. package/package.json +11 -3
  118. package/dist/chunk-LBNOZIZ6.js +0 -90
  119. package/dist/chunk-URDI3IMY.cjs +0 -93
@@ -2,7 +2,7 @@
2
2
  * ====================================================
3
3
  * Rzl Utils-JS.
4
4
  * ----------------------------------------------------
5
- * Version: 3.5.7.
5
+ * Version: 3.7.0.
6
6
  * Author: Rizalvin Dwiky.
7
7
  * Repository: https://github.com/rzl-zone/utils-js.
8
8
  * ====================================================
@@ -347,39 +347,192 @@ removeDuplicates?:boolean;};
347
347
  * ```
348
348
  */
349
349
  declare const getPrefixPathname:(url:string|string[],base?:string|string[]|null,options?:GetPrefixPathnameOptions)=>string|string[]|null;
350
+ /** Options when `keepNullable` is false (default).
351
+ *
352
+ * Returns `defaultPath` if `pathname` is empty or invalid.
353
+ */
354
+ type UnKeepNullableOptions={
355
+ /** * ***Fallback value returned if `pathname` is empty-string or invalid.***
356
+ *
357
+ * Must be a **`non-empty string`**, defaultValue: `"/"`.
358
+ *
359
+ * @defaultValue `"/"`.
360
+ */
361
+ defaultPath?:string;
362
+ /** * ***Whether to preserve `null` or `undefined`, defaultValue: `false`.***
363
+ *
364
+ * @defaultValue `false`.
365
+ */
366
+ keepNullable?:false;};
367
+ /** Options when `keepNullable` is true.
368
+ *
369
+ * Preserves `null` or `undefined` instead of returning `defaultPath`.
370
+ */
371
+ type KeepNullableOptions={
372
+ /** * ***Fallback path is ignored when `keepNullable` is true **(except if
373
+ * `pathname` is empty-string or invalid, even this `true`)**,
374
+ * defaultValue: `"/"`.***
375
+ *
376
+ * @defaultValue `"/"`.
377
+ */
378
+ defaultPath?:string;
379
+ /** * ***Preserve `null` or `undefined` as-is if `true` (defaultValue: `false`).***
380
+ *
381
+ * - ***⚠️ Notes:***
382
+ * - Keep returning `defaultPath` if `pathname` is empty-string, even this `true`.
383
+ *
384
+ * **Must be `true` in this type.**
385
+ */
386
+ keepNullable?:true;};type MainNormalizePathnameOptions={
387
+ /** * ***Preserve trailing slash at the end of the normalized pathname, defaultValue: `false`.***
388
+ *
389
+ * @defaultValue `false`
390
+ */
391
+ keepTrailingSlash?:boolean;};type NormalizePathnameOptionsKeepNullableTrue=MainNormalizePathnameOptions & KeepNullableOptions;type NormalizePathnameOptionsKeepNullableFalse=MainNormalizePathnameOptions & UnKeepNullableOptions;type ResUnKeepNullable<T>=T extends undefined?string:T extends null?string:T extends null|undefined?string:string;type ResKeepNullable<T>=T extends string?string:T extends undefined?undefined:T extends null?null:T extends null|undefined?null|undefined:string|null|undefined;
350
392
  /** --------------------------------------------------------
351
393
  * * ***Utility: `normalizePathname`.***
352
394
  * --------------------------------------------------------
353
- * **This function processes and normalizes a given pathname.**
354
- * - **Behavior:**
355
- * - If `pathname` is `null`, `undefined`, empty, or only whitespace, the `defaultPath` will be returned instead.
356
- * - If `pathname` is a full URL (starting with `http://` or `https://`), it extracts and returns the pathname along
357
- * with any search parameters and hash.
358
- * - Example: `"https://site.com/foo/bar?x=1#sec"` becomes `"/foo/bar?x=1#sec"`.
359
- * - All spaces inside the pathname are removed.
360
- * - Multiple consecutive slashes (like `"//"` or `"///"`) are collapsed into a single slash `"/"`.
361
- * - Ensures the returned string always starts with exactly one `/`.
362
- * @param {string | null | undefined} pathname - The pathname to normalize.
363
- * @param {string} [defaultPath="/"] - A fallback value returned if `pathname` is empty or invalid, must be a string and non-empty string, default `"/"`.
364
- * @returns {string} A properly normalized pathname starting with a single `/`,
365
- * or the `defaultPath` if the input is invalid or empty.
366
- * @throws {TypeError} If `defaultPath` is not a string or empty-string.
367
- * @throws {NormalizePathnameError} If an unexpected error occurs during normalization (e.g., URL parsing failure).
395
+ * - **Description:**
396
+ * - Normalizes a given pathname string for consistent routing, URL handling, and string hygiene.
397
+ * - It trims whitespace, collapses redundant slashes, handles full URLs, query strings, hash fragments,
398
+ * - Unicode characters, emojis, and optionally preserves `null` or `undefined`.
399
+ * - Trailing slash behavior can be controlled via `keepTrailingSlash`.
400
+ *
401
+ * - **Behavior Details:**
402
+ * - Trims leading and trailing whitespace.
403
+ * - Removes all internal spaces.
404
+ * - Collapses multiple consecutive slashes into a single `/`.
405
+ * - Prepends a leading slash if missing.
406
+ * - Preserves trailing slash only if `keepTrailingSlash` is `true`.
407
+ * - Supports full URLs (`http://` or `https://`) and relative paths only also detect valid domain and
408
+ * subdomain (with support handle wildcard eg: *.example.com) (with optional with port) eg (localhost, localhost:3000, example.com, sub.domain.com, *.domain.test, etc).
409
+ * - Preserves query strings (`?key=value`) and hash fragments (`#anchor`) intact.
410
+ * - Handles emojis and Unicode safely.
411
+ * - Returns `string`, `null` or `undefined` as-is if `keepNullable` is true.
412
+ * - Returns `undefined` if pathname is not a string and `keepNullable` is `true`.
413
+ * - Returns `defaultPath` if pathname is empty-string even when `keepNullable` is true.
414
+ * - Returns `defaultPath` if pathname is empty/invalid and `keepNullable` is `false`.
415
+ *
416
+ * - **Options (`options`)**:
417
+ * - `defaultPath` (***`string`***, default: **`"/"`**)
418
+ * - Fallback path if the input is invalid (**empty-string**, **null**, **undefined**) and
419
+ * `keepNullable` is **false**, if `keepNullable` is true, used only when pathname is empty-string.
420
+ * - `keepNullable` (***`boolean`***, default: **`false`**)
421
+ * - If **true**, preserves `null` or `undefined` as-is instead of returning
422
+ * `defaultPath` (except if `pathname` is **empty-string**).
423
+ * - `keepTrailingSlash` (***`boolean`***, default: **`false`**)
424
+ * - If **true**, preserves a trailing slash at the end of the normalized pathname.
425
+ *
426
+ * @param {string | null | undefined} pathname - ***The pathname to normalize.***
427
+ * @param {NormalizePathnameOptions} [options] - ***Configuration options.***
428
+ *
429
+ * @returns {string | null | undefined} ***Normalized pathname, or original nullable value if `keepNullable` is `true`
430
+ * _(except if `pathname` is empty-string, will keep returning `defaultPath`)_.***
431
+ *
432
+ * @throws {TypeError} If `defaultPath` is invalid when `keepNullable` is false.
433
+ * @throws {NormalizePathnameError} If normalization fails (e.g., invalid URL).
434
+ *
368
435
  * @example
436
+ * // Basic normalization
369
437
  * normalizePathname(" /foo//bar ");
370
438
  * // ➔ "/foo/bar"
439
+ *
440
+ * // Full URL with query and hash
371
441
  * normalizePathname("https://example.com//path///to/resource?x=1#hash");
372
442
  * // ➔ "/path/to/resource?x=1#hash"
443
+ *
444
+ * // Empty string returns defaultPath
373
445
  * normalizePathname(" ");
374
446
  * // ➔ "/"
375
- * normalizePathname(null, "/home");
447
+ *
448
+ * // Return defaultPath if isn't valid pathname and keepNullable is `undefined` or `false`.
449
+ * normalizePathname(null, { defaultPath: "/home" });
450
+ * // ➔ "/home"
451
+ *
452
+ * // Preserve null
453
+ * normalizePathname(null, { keepNullable: true });
454
+ * // ➔ null
455
+ *
456
+ * // Preserve undefined
457
+ * normalizePathname(undefined, { keepNullable: true });
458
+ * // ➔ undefined
459
+ *
460
+ * // Return defaultPath if pathname is empty-string even with keepNullable
461
+ * normalizePathname(" ", { keepNullable: true, defaultPath:"/home" });
376
462
  * // ➔ "/home"
463
+ *
464
+ * // Return undefined if pathname is not a valid-string.
465
+ * normalizePathname(true, { keepNullable: true, defaultPath:"/home" });
466
+ * // ➔ undefined
467
+ *
468
+ * // Collapse multiple slashes
377
469
  * normalizePathname("/double//slashes");
378
470
  * // ➔ "/double/slashes"
471
+ *
472
+ * // Handles emoji and Unicode
379
473
  * normalizePathname(" nested / path / 🚀 ");
380
474
  * // ➔ "/nested/path/🚀"
475
+ *
476
+ * // Query and hash preserved
477
+ * normalizePathname("/dashboard///stats?view=all#top");
478
+ * // ➔ "/dashboard/stats?view=all#top"
479
+ *
480
+ * // Leading/trailing slashes normalized
481
+ * normalizePathname("///api//v1///user/");
482
+ * // ➔ "/api/v1/user"
483
+ *
484
+ * // Keep trailing slash if option enabled
485
+ * normalizePathname("///api//v1///user//", { keepTrailingSlash: true });
486
+ * // ➔ "/api/v1/user/"
487
+ *
488
+ * // Relative-like paths handled safely
489
+ * normalizePathname("path/to/page");
490
+ * // ➔ "/path/to/page"
491
+ *
492
+ * // Query-only path
493
+ * normalizePathname("?page=2");
494
+ * // ➔ "/?page=2"
495
+ *
496
+ * // Hash-only path
497
+ * normalizePathname("#section3");
498
+ * // ➔ "/#section3"
499
+ *
500
+ * // URL parsing failure triggers custom error
501
+ * try {
502
+ * normalizePathname("http://");
503
+ * } catch (e) {
504
+ * // ➔ console.log(e);
505
+ * }
506
+ *
507
+ * // Internal encoded spaces preserved
508
+ * normalizePathname("/search/%20item%20");
509
+ * // ➔ "/search/%20item%20"
510
+ *
511
+ * // Edge case: relative URL-like input
512
+ * normalizePathname("localhost/path");
513
+ * // ➔ "/path"
514
+ * normalizePathname("localhost:3000/path");
515
+ * // ➔ "/path"
516
+ * normalizePathname("example.com/path");
517
+ * // ➔ "/path"
518
+ * normalizePathname("sub.domain.com/path");
519
+ * // ➔ "/path"
520
+ * normalizePathname("*.domain.com/path");
521
+ * // ➔ "/path"
522
+ *
523
+ * // Deeply nested messy path
524
+ * normalizePathname(" /🔥//deep//path///🚀 ");
525
+ * // ➔ "/🔥/deep/path/🚀"
526
+ *
527
+ * // Edge case: root slash
528
+ * normalizePathname("/");
529
+ * // ➔ "/"
530
+ *
531
+ * // Edge case: multiple spaces only
532
+ * normalizePathname(" ");
533
+ * // ➔ "/"
381
534
  */
382
- declare const normalizePathname:(pathname:string|null|undefined,defaultPath?:string)=>string;type FormatEnvPortOptions={
535
+ declare function normalizePathname<T>(pathname:T,options?:NormalizePathnameOptionsKeepNullableFalse):ResUnKeepNullable<T>;declare function normalizePathname<T>(pathname:T,options?:NormalizePathnameOptionsKeepNullableTrue):ResKeepNullable<T>;type FormatEnvPortOptions={
383
536
  /** Add prefix with a colon, defaultValue: `false`.
384
537
  *
385
538
  * @default false
@@ -404,4 +557,100 @@ prefixColon?:boolean;};
404
557
  * formatEnvPort("port:8080", { prefixColon: true });
405
558
  * // ➔ ":8080"
406
559
  */
407
- declare const formatEnvPort:(envVar:string|null|undefined,options?:FormatEnvPortOptions)=>string;export{type QueryParamPairs,constructURL,extractURLs,formatEnvPort,getFirstPrefixPathname,getPrefixPathname,normalizePathname};
560
+ declare const formatEnvPort:(envVar:string|null|undefined,options?:FormatEnvPortOptions)=>string;
561
+ /** ---------------------------------------------------------
562
+ * * ***Constants for `Punycode-UtilsJS` algorithm.***
563
+ * ---------------------------------------------------------
564
+ * These constants are used internally for encoding and decoding.
565
+ *
566
+ * Unicode domain names to ASCII (`Punycode-UtilsJS`) and vice versa.
567
+ */
568
+ type PunycodeUtilsJS={
569
+ /** ---------------------------------------------------------
570
+ * * ***Version of the `Punycode-UtilsJS` implementation.***
571
+ * ---------------------------------------------------------
572
+ *
573
+ * @example
574
+ * console.log(punycodeUtilsJS.version); // "1.0.0"
575
+ */
576
+ version:string;
577
+ /** ---------------------------------------------------------
578
+ * * ***UCS-2 utility functions.***
579
+ * ---------------------------------------------------------
580
+ */
581
+ ucs2:{
582
+ /** ---------------------------------------------------------
583
+ * * ***Decodes a UCS-2 encoded string to an array of Unicode code points.***
584
+ * ---------------------------------------------------------
585
+ *
586
+ * @param input - The UCS-2 string to decode.
587
+ * @returns Array of Unicode code points.
588
+ * @example
589
+ * punycodeUtilsJS.ucs2.decode("𐍈");
590
+ * // ➔ [66376]
591
+ */
592
+ decode:(input:string)=>number[];
593
+ /** ---------------------------------------------------------
594
+ * * ***Encodes an array of Unicode code points to a UCS-2 string.***
595
+ * ---------------------------------------------------------
596
+ *
597
+ * @param points - Array of Unicode code points.
598
+ * @returns Encoded string.
599
+ * @example
600
+ * punycodeUtilsJS.ucs2.encode([66376]);
601
+ * // ➔ "𐍈"
602
+ */
603
+ encode:(points:number[])=>string;};
604
+ /** ---------------------------------------------------------
605
+ * * ***Decodes a `Punycode-UtilsJS` string to a Unicode string.***
606
+ * ---------------------------------------------------------
607
+ *
608
+ * @param input - The `Punycode-UtilsJS` string to decode.
609
+ * @returns Decoded Unicode string.
610
+ * @example
611
+ * punycodeUtilsJS.decode("xn--fsq");
612
+ * // ➔ "ü"
613
+ */
614
+ decode:(input:string)=>string;
615
+ /** ---------------------------------------------------------
616
+ * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***
617
+ * ---------------------------------------------------------
618
+ *
619
+ * @param input - Unicode string to encode.
620
+ * @returns `Punycode-UtilsJS` string.
621
+ * @example
622
+ * punycodeUtilsJS.encode("ü");
623
+ * // ➔ "xn--fsq"
624
+ */
625
+ encode:(input:string)=>string;
626
+ /** ---------------------------------------------------------
627
+ * * ***Converts a Unicode domain or label to ASCII (`Punycode-UtilsJS`).***
628
+ * ---------------------------------------------------------
629
+ *
630
+ * @param input - Domain or label string.
631
+ * @returns ASCII string suitable for DNS.
632
+ * @example
633
+ * punycodeUtilsJS.toASCII("пример.рф");
634
+ * // ➔ "xn--e1afmkfd.xn--p1ai"
635
+ */
636
+ toASCII:(input:string)=>string;
637
+ /** ---------------------------------------------------------
638
+ * * ***Converts an ASCII (`Punycode-UtilsJS`) domain or label to Unicode.***
639
+ * ---------------------------------------------------------
640
+ *
641
+ * @param input - ASCII string (with xn-- prefix if needed).
642
+ * @returns Unicode string.
643
+ * @example
644
+ * punycodeUtilsJS.toUnicode("xn--e1afmkfd.xn--p1ai");
645
+ * // ➔ "пример.рф"
646
+ */
647
+ toUnicode:(input:string)=>string;};
648
+ /** ---------------------------------------------------------
649
+ * * ***`Punycode-UtilsJS` object exposing all API functions and version.***
650
+ * ---------------------------------------------------------
651
+ * Provides encoding and decoding of Unicode domain names to ASCII (`Punycode-UtilsJS`)
652
+ * and vice versa.
653
+ *
654
+ * - Useful for IDN (Internationalized Domain Names) support.
655
+ */
656
+ declare const punycodeUtilsJS:PunycodeUtilsJS;export{type QueryParamPairs,constructURL,extractURLs,formatEnvPort,getFirstPrefixPathname,getPrefixPathname,normalizePathname,punycodeUtilsJS};
@@ -2,19 +2,20 @@
2
2
  * ====================================================
3
3
  * Rzl Utils-JS.
4
4
  * ----------------------------------------------------
5
- * Version: 3.5.7.
5
+ * Version: 3.7.0.
6
6
  * Author: Rizalvin Dwiky.
7
7
  * Repository: https://github.com/rzl-zone/utils-js.
8
8
  * ====================================================
9
9
  */
10
- export { constructURL, extractURLs, getFirstPrefixPathname, getPrefixPathname } from '../chunk-6DSPJA5U.js';
10
+ export { constructURL, extractURLs, getFirstPrefixPathname, getPrefixPathname } from '../chunk-6PKW4WCT.js';
11
11
  import '../chunk-ONZFBJVW.js';
12
12
  import '../chunk-GAJBF6DR.js';
13
13
  import '../chunk-TDYGYHSH.js';
14
14
  import '../chunk-PZQC3FZY.js';
15
15
  import '../chunk-7ZNEUWYP.js';
16
16
  import '../chunk-WVSPXFTY.js';
17
- export { formatEnvPort, normalizePathname } from '../chunk-LBNOZIZ6.js';
17
+ export { formatEnvPort, normalizePathname } from '../chunk-WNO3EPYT.js';
18
+ export { punycodeUtilsJS } from '../chunk-YS27V6LS.js';
18
19
  import '../chunk-4ACKNPL5.js';
19
20
  import '../chunk-JY4HLZ4W.js';
20
21
  import '../chunk-VCVND6CH.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rzl-zone/utils-js",
3
- "version": "3.5.7",
3
+ "version": "3.7.0",
4
4
  "sideEffects": false,
5
5
  "engineStrict": true,
6
6
  "license": "MIT",
@@ -19,7 +19,6 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@rzl-zone/ts-types-plus": "latest",
22
- "clsx": "^2.1.1",
23
22
  "date-fns": "^4.1.0",
24
23
  "libphonenumber-js": "^1.12.17",
25
24
  "server-only": "^0.0.1",
@@ -191,16 +190,25 @@
191
190
  "keywords": [
192
191
  "javascript",
193
192
  "typescript",
193
+ "js",
194
+ "ts",
195
+ "util",
194
196
  "utils",
197
+ "helper",
195
198
  "helpers",
196
199
  "library",
197
200
  "@rzl-zone/utils-js",
198
201
  "rzl",
199
202
  "rzl-zone",
203
+ "rzl zone",
204
+ "util js",
205
+ "util-js",
200
206
  "utils-js",
207
+ "utils js",
201
208
  "utility",
209
+ "utility js",
202
210
  "rzl-utils",
203
- "helper",
211
+ "rzl utils",
204
212
  "functions"
205
213
  ],
206
214
  "publishConfig": {
@@ -1,90 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.5.7.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- import { removeSpaces } from './chunk-4ACKNPL5.js';
11
- import { isEmptyString } from './chunk-JY4HLZ4W.js';
12
- import { safeStableStringify } from './chunk-2VO2CBTU.js';
13
- import { isNonEmptyString, getPreciseType, isError, assertIsPlainObject, hasOwnProp, isBoolean, isFunction } from './chunk-3KTD3QDI.js';
14
-
15
- var NormalizePathnameError = class _NormalizePathnameError extends Error {
16
- /** * ***The original error that triggered this normalization failure.***
17
- *
18
- * **Always available for backward compatibility.**
19
- */
20
- originalError;
21
- constructor(message, originalError) {
22
- super(message, isFunction(Error) ? { cause: originalError } : void 0);
23
- this.name = "NormalizePathnameError";
24
- this.originalError = originalError;
25
- if (isFunction(Error.captureStackTrace)) {
26
- Error.captureStackTrace(this, _NormalizePathnameError);
27
- } else {
28
- this.stack = new Error(message).stack;
29
- }
30
- }
31
- /** * ***Safe JSON representation for logging or IPC.*** */
32
- toJSON() {
33
- return {
34
- name: this.name,
35
- message: this.message,
36
- stack: this.stack,
37
- originalError: {
38
- name: this.originalError.name,
39
- message: this.originalError.message,
40
- stack: this.originalError.stack
41
- }
42
- };
43
- }
44
- };
45
-
46
- var normalizePathname = (pathname, defaultPath = "/") => {
47
- if (!isNonEmptyString(defaultPath)) {
48
- throw new TypeError(
49
- `Second parameter (\`defaultPath\`) must be of type \`string\` and not empty-string, but received: \`${getPreciseType(
50
- defaultPath
51
- )}\`, with value: \`${safeStableStringify(defaultPath)}\`.`
52
- );
53
- }
54
- if (!isNonEmptyString(pathname)) return defaultPath;
55
- try {
56
- pathname = removeSpaces(pathname, { trimOnly: true });
57
- pathname = pathname.replace(/\s+/g, "");
58
- if (pathname.startsWith("http://") || pathname.startsWith("https://")) {
59
- const url = new URL(pathname);
60
- return `${url.pathname}${url.search}${url.hash}`.replace(/^\/+/, "/");
61
- }
62
- return "/" + pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
63
- } catch (error) {
64
- const err = isError(error) ? error : new Error("Unknown error from function `normalizePathname()`.");
65
- throw new NormalizePathnameError(
66
- `Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`,
67
- err
68
- );
69
- }
70
- };
71
-
72
- var formatEnvPort = (envVar, options = {}) => {
73
- if (!isNonEmptyString(envVar)) return "";
74
- assertIsPlainObject(options, {
75
- message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
76
- });
77
- const prefixColon = hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
78
- if (!isBoolean(prefixColon)) {
79
- throw new TypeError(
80
- `Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${getPreciseType(
81
- prefixColon
82
- )}\`.`
83
- );
84
- }
85
- const digitsOnly = envVar.replace(/\D+/g, "");
86
- if (isEmptyString(digitsOnly)) return "";
87
- return prefixColon ? `:${digitsOnly}` : digitsOnly;
88
- };
89
-
90
- export { formatEnvPort, normalizePathname };
@@ -1,93 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.5.7.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkLIU4S3JA_cjs = require('./chunk-LIU4S3JA.cjs');
13
- var chunkNREACG6M_cjs = require('./chunk-NREACG6M.cjs');
14
- var chunkYC7AK3KX_cjs = require('./chunk-YC7AK3KX.cjs');
15
- var chunkF3WBQKRI_cjs = require('./chunk-F3WBQKRI.cjs');
16
-
17
- var NormalizePathnameError = class _NormalizePathnameError extends Error {
18
- /** * ***The original error that triggered this normalization failure.***
19
- *
20
- * **Always available for backward compatibility.**
21
- */
22
- originalError;
23
- constructor(message, originalError) {
24
- super(message, chunkF3WBQKRI_cjs.isFunction(Error) ? { cause: originalError } : void 0);
25
- this.name = "NormalizePathnameError";
26
- this.originalError = originalError;
27
- if (chunkF3WBQKRI_cjs.isFunction(Error.captureStackTrace)) {
28
- Error.captureStackTrace(this, _NormalizePathnameError);
29
- } else {
30
- this.stack = new Error(message).stack;
31
- }
32
- }
33
- /** * ***Safe JSON representation for logging or IPC.*** */
34
- toJSON() {
35
- return {
36
- name: this.name,
37
- message: this.message,
38
- stack: this.stack,
39
- originalError: {
40
- name: this.originalError.name,
41
- message: this.originalError.message,
42
- stack: this.originalError.stack
43
- }
44
- };
45
- }
46
- };
47
-
48
- var normalizePathname = (pathname, defaultPath = "/") => {
49
- if (!chunkF3WBQKRI_cjs.isNonEmptyString(defaultPath)) {
50
- throw new TypeError(
51
- `Second parameter (\`defaultPath\`) must be of type \`string\` and not empty-string, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
52
- defaultPath
53
- )}\`, with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(defaultPath)}\`.`
54
- );
55
- }
56
- if (!chunkF3WBQKRI_cjs.isNonEmptyString(pathname)) return defaultPath;
57
- try {
58
- pathname = chunkLIU4S3JA_cjs.removeSpaces(pathname, { trimOnly: true });
59
- pathname = pathname.replace(/\s+/g, "");
60
- if (pathname.startsWith("http://") || pathname.startsWith("https://")) {
61
- const url = new URL(pathname);
62
- return `${url.pathname}${url.search}${url.hash}`.replace(/^\/+/, "/");
63
- }
64
- return "/" + pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
65
- } catch (error) {
66
- const err = chunkF3WBQKRI_cjs.isError(error) ? error : new Error("Unknown error from function `normalizePathname()`.");
67
- throw new NormalizePathnameError(
68
- `Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`,
69
- err
70
- );
71
- }
72
- };
73
-
74
- var formatEnvPort = (envVar, options = {}) => {
75
- if (!chunkF3WBQKRI_cjs.isNonEmptyString(envVar)) return "";
76
- chunkF3WBQKRI_cjs.assertIsPlainObject(options, {
77
- message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
78
- });
79
- const prefixColon = chunkF3WBQKRI_cjs.hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
80
- if (!chunkF3WBQKRI_cjs.isBoolean(prefixColon)) {
81
- throw new TypeError(
82
- `Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
83
- prefixColon
84
- )}\`.`
85
- );
86
- }
87
- const digitsOnly = envVar.replace(/\D+/g, "");
88
- if (chunkNREACG6M_cjs.isEmptyString(digitsOnly)) return "";
89
- return prefixColon ? `:${digitsOnly}` : digitsOnly;
90
- };
91
-
92
- exports.formatEnvPort = formatEnvPort;
93
- exports.normalizePathname = normalizePathname;