@kikiutils/shared 9.0.0 → 9.2.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 (103) hide show
  1. package/README.md +23 -3
  2. package/dist/clipboard.cjs +87 -0
  3. package/dist/clipboard.cjs.map +1 -0
  4. package/dist/clipboard.d.ts +60 -0
  5. package/dist/clipboard.d.ts.map +1 -0
  6. package/dist/clipboard.mjs +84 -0
  7. package/dist/clipboard.mjs.map +1 -0
  8. package/dist/consola.cjs +1 -1
  9. package/dist/consola.cjs.map +1 -1
  10. package/dist/consola.d.ts +1 -1
  11. package/dist/consola.mjs +1 -1
  12. package/dist/consola.mjs.map +1 -1
  13. package/dist/crypto-hash.cjs +1 -0
  14. package/dist/crypto-hash.cjs.map +1 -1
  15. package/dist/crypto-hash.d.ts +1 -0
  16. package/dist/crypto-hash.d.ts.map +1 -1
  17. package/dist/crypto-hash.mjs +1 -0
  18. package/dist/crypto-hash.mjs.map +1 -1
  19. package/dist/datetime.cjs +3 -0
  20. package/dist/datetime.cjs.map +1 -1
  21. package/dist/datetime.d.ts +3 -0
  22. package/dist/datetime.d.ts.map +1 -1
  23. package/dist/datetime.mjs +3 -0
  24. package/dist/datetime.mjs.map +1 -1
  25. package/dist/enum.cjs +2 -0
  26. package/dist/enum.cjs.map +1 -1
  27. package/dist/enum.d.ts +2 -0
  28. package/dist/enum.d.ts.map +1 -1
  29. package/dist/enum.mjs +2 -0
  30. package/dist/enum.mjs.map +1 -1
  31. package/dist/env.cjs +2 -0
  32. package/dist/env.cjs.map +1 -1
  33. package/dist/env.d.ts +2 -0
  34. package/dist/env.d.ts.map +1 -1
  35. package/dist/env.mjs +2 -0
  36. package/dist/env.mjs.map +1 -1
  37. package/dist/general.cjs.map +1 -1
  38. package/dist/general.d.ts +1 -0
  39. package/dist/general.d.ts.map +1 -1
  40. package/dist/general.mjs.map +1 -1
  41. package/dist/math.cjs +1 -0
  42. package/dist/math.cjs.map +1 -1
  43. package/dist/math.d.ts +3 -0
  44. package/dist/math.d.ts.map +1 -1
  45. package/dist/math.mjs +1 -0
  46. package/dist/math.mjs.map +1 -1
  47. package/dist/number.cjs +1 -0
  48. package/dist/number.cjs.map +1 -1
  49. package/dist/number.d.ts +1 -0
  50. package/dist/number.d.ts.map +1 -1
  51. package/dist/number.mjs +1 -0
  52. package/dist/number.mjs.map +1 -1
  53. package/dist/pino.cjs +1 -1
  54. package/dist/pino.cjs.map +1 -1
  55. package/dist/pino.d.ts +1 -1
  56. package/dist/pino.mjs +1 -1
  57. package/dist/pino.mjs.map +1 -1
  58. package/dist/random.cjs +8 -7
  59. package/dist/random.cjs.map +1 -1
  60. package/dist/random.d.ts +8 -7
  61. package/dist/random.d.ts.map +1 -1
  62. package/dist/random.mjs +8 -7
  63. package/dist/random.mjs.map +1 -1
  64. package/dist/string.cjs +1 -0
  65. package/dist/string.cjs.map +1 -1
  66. package/dist/string.d.ts +1 -0
  67. package/dist/string.d.ts.map +1 -1
  68. package/dist/string.mjs +1 -0
  69. package/dist/string.mjs.map +1 -1
  70. package/dist/url.cjs +21 -0
  71. package/dist/url.cjs.map +1 -0
  72. package/dist/url.d.ts +12 -0
  73. package/dist/url.d.ts.map +1 -0
  74. package/dist/url.mjs +19 -0
  75. package/dist/url.mjs.map +1 -0
  76. package/dist/vue.cjs +64 -0
  77. package/dist/vue.cjs.map +1 -0
  78. package/dist/vue.d.ts +31 -0
  79. package/dist/vue.d.ts.map +1 -0
  80. package/dist/vue.mjs +59 -0
  81. package/dist/vue.mjs.map +1 -0
  82. package/dist/web.cjs +18 -0
  83. package/dist/web.cjs.map +1 -0
  84. package/dist/web.d.ts +9 -0
  85. package/dist/web.d.ts.map +1 -0
  86. package/dist/web.mjs +16 -0
  87. package/dist/web.mjs.map +1 -0
  88. package/package.json +5 -2
  89. package/src/clipboard.ts +85 -0
  90. package/src/consola.ts +1 -1
  91. package/src/crypto-hash.ts +1 -0
  92. package/src/datetime.ts +3 -0
  93. package/src/enum.ts +2 -0
  94. package/src/env.ts +2 -0
  95. package/src/general.ts +1 -0
  96. package/src/math.ts +3 -0
  97. package/src/number.ts +1 -0
  98. package/src/pino.ts +1 -1
  99. package/src/random.ts +8 -7
  100. package/src/string.ts +1 -0
  101. package/src/url.ts +16 -0
  102. package/src/vue.ts +62 -0
  103. package/src/web.ts +13 -0
package/dist/enum.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"enum.cjs","sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts the numeric values from an enumeration-like object.\n *\n * @param {Record<number | string, number | string>} data - The enumeration-like object to extract numeric values from.\n * The keys can be numbers or strings, and the values can be numbers or strings.\n * @returns {number[]} An array of numeric values extracted from the object.\n *\n * @example\n * ```typescript\n * import { getEnumNumberValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumNumberValues(RecordType)); // [0, 1]\n * ```\n */\nexport function getEnumNumberValues(data: Record<number | string, number | string>) {\n return Object.values(data).filter((value) => typeof value === 'number');\n}\n\n/**\n * Extracts the string values from an enumeration-like object.\n *\n * @param {Record<number | string, number | string>} data - The enumeration-like object to extract string values from.\n * The keys can be numbers or strings, and the values can be numbers or strings.\n * @returns {string[]} An array of string values extracted from the object.\n *\n * @example\n * ```typescript\n * import { getEnumStringValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumStringValues(RecordType)); // ['unknown']\n * ```\n */\nexport function getEnumStringValues(data: Record<number | string, number | string>) {\n const keys: string[] = [];\n const keysCount: Record<string, number> = {};\n const values: any[] = [];\n Object.entries(data).forEach(([key, value]) => {\n keys.push(key);\n values.push(value);\n if (typeof value !== 'string') return;\n keysCount[key] = (keysCount[key] ?? 0) + 1;\n keysCount[value] = (keysCount[value] ?? 0) + 1;\n });\n\n return values.filter((value) => {\n return typeof value === 'string' && (!keys.includes(value) || (keysCount[value] && keysCount[value] > 1));\n });\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,mBAAmB,CAAC,IAA8C,EAAA;AAC9E,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC3E;AAEA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,mBAAmB,CAAC,IAA8C,EAAA;IAC9E,MAAM,IAAI,GAAa,EAAE;IACzB,MAAM,SAAS,GAA2B,EAAE;IAC5C,MAAM,MAAM,GAAU,EAAE;AACxB,IAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC1C,QAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAClB,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE;AAC/B,QAAA,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;AAC1C,QAAA,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;AAClD,KAAC,CAAC;AAEF,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAI;AAC3B,QAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7G,KAAC,CAAC;AACN;;;;;"}
1
+ {"version":3,"file":"enum.cjs","sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts the numeric values from an enumeration-like object.\n *\n * @param {Record<number | string, number | string>} data - The enumeration-like object to extract numeric values from.\n * The keys can be numbers or strings, and the values can be numbers or strings.\n *\n * @returns {number[]} An array of numeric values extracted from the object.\n *\n * @example\n * ```typescript\n * import { getEnumNumberValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumNumberValues(RecordType)); // [0, 1]\n * ```\n */\nexport function getEnumNumberValues(data: Record<number | string, number | string>) {\n return Object.values(data).filter((value) => typeof value === 'number');\n}\n\n/**\n * Extracts the string values from an enumeration-like object.\n *\n * @param {Record<number | string, number | string>} data - The enumeration-like object to extract string values from.\n * The keys can be numbers or strings, and the values can be numbers or strings.\n *\n * @returns {string[]} An array of string values extracted from the object.\n *\n * @example\n * ```typescript\n * import { getEnumStringValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumStringValues(RecordType)); // ['unknown']\n * ```\n */\nexport function getEnumStringValues(data: Record<number | string, number | string>) {\n const keys: string[] = [];\n const keysCount: Record<string, number> = {};\n const values: any[] = [];\n Object.entries(data).forEach(([key, value]) => {\n keys.push(key);\n values.push(value);\n if (typeof value !== 'string') return;\n keysCount[key] = (keysCount[key] ?? 0) + 1;\n keysCount[value] = (keysCount[value] ?? 0) + 1;\n });\n\n return values.filter((value) => {\n return typeof value === 'string' && (!keys.includes(value) || (keysCount[value] && keysCount[value] > 1));\n });\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAC,IAA8C,EAAA;AAC9E,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC3E;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAC,IAA8C,EAAA;IAC9E,MAAM,IAAI,GAAa,EAAE;IACzB,MAAM,SAAS,GAA2B,EAAE;IAC5C,MAAM,MAAM,GAAU,EAAE;AACxB,IAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC1C,QAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAClB,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE;AAC/B,QAAA,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;AAC1C,QAAA,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;AAClD,KAAC,CAAC;AAEF,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAI;AAC3B,QAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7G,KAAC,CAAC;AACN;;;;;"}
package/dist/enum.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @param {Record<number | string, number | string>} data - The enumeration-like object to extract numeric values from.
5
5
  * The keys can be numbers or strings, and the values can be numbers or strings.
6
+ *
6
7
  * @returns {number[]} An array of numeric values extracted from the object.
7
8
  *
8
9
  * @example
@@ -24,6 +25,7 @@ export declare function getEnumNumberValues(data: Record<number | string, number
24
25
  *
25
26
  * @param {Record<number | string, number | string>} data - The enumeration-like object to extract string values from.
26
27
  * The keys can be numbers or strings, and the values can be numbers or strings.
28
+ *
27
29
  * @returns {string[]} An array of string values extracted from the object.
28
30
  *
29
31
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../src/enum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,YAEjF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,SAejF"}
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../src/enum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,YAEjF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,SAejF"}
package/dist/enum.mjs CHANGED
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @param {Record<number | string, number | string>} data - The enumeration-like object to extract numeric values from.
5
5
  * The keys can be numbers or strings, and the values can be numbers or strings.
6
+ *
6
7
  * @returns {number[]} An array of numeric values extracted from the object.
7
8
  *
8
9
  * @example
@@ -26,6 +27,7 @@ function getEnumNumberValues(data) {
26
27
  *
27
28
  * @param {Record<number | string, number | string>} data - The enumeration-like object to extract string values from.
28
29
  * The keys can be numbers or strings, and the values can be numbers or strings.
30
+ *
29
31
  * @returns {string[]} An array of string values extracted from the object.
30
32
  *
31
33
  * @example
package/dist/enum.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"enum.mjs","sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts the numeric values from an enumeration-like object.\n *\n * @param {Record<number | string, number | string>} data - The enumeration-like object to extract numeric values from.\n * The keys can be numbers or strings, and the values can be numbers or strings.\n * @returns {number[]} An array of numeric values extracted from the object.\n *\n * @example\n * ```typescript\n * import { getEnumNumberValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumNumberValues(RecordType)); // [0, 1]\n * ```\n */\nexport function getEnumNumberValues(data: Record<number | string, number | string>) {\n return Object.values(data).filter((value) => typeof value === 'number');\n}\n\n/**\n * Extracts the string values from an enumeration-like object.\n *\n * @param {Record<number | string, number | string>} data - The enumeration-like object to extract string values from.\n * The keys can be numbers or strings, and the values can be numbers or strings.\n * @returns {string[]} An array of string values extracted from the object.\n *\n * @example\n * ```typescript\n * import { getEnumStringValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumStringValues(RecordType)); // ['unknown']\n * ```\n */\nexport function getEnumStringValues(data: Record<number | string, number | string>) {\n const keys: string[] = [];\n const keysCount: Record<string, number> = {};\n const values: any[] = [];\n Object.entries(data).forEach(([key, value]) => {\n keys.push(key);\n values.push(value);\n if (typeof value !== 'string') return;\n keysCount[key] = (keysCount[key] ?? 0) + 1;\n keysCount[value] = (keysCount[value] ?? 0) + 1;\n });\n\n return values.filter((value) => {\n return typeof value === 'string' && (!keys.includes(value) || (keysCount[value] && keysCount[value] > 1));\n });\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,mBAAmB,CAAC,IAA8C,EAAA;AAC9E,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC3E;AAEA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,mBAAmB,CAAC,IAA8C,EAAA;IAC9E,MAAM,IAAI,GAAa,EAAE;IACzB,MAAM,SAAS,GAA2B,EAAE;IAC5C,MAAM,MAAM,GAAU,EAAE;AACxB,IAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC1C,QAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAClB,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE;AAC/B,QAAA,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;AAC1C,QAAA,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;AAClD,KAAC,CAAC;AAEF,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAI;AAC3B,QAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7G,KAAC,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"enum.mjs","sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts the numeric values from an enumeration-like object.\n *\n * @param {Record<number | string, number | string>} data - The enumeration-like object to extract numeric values from.\n * The keys can be numbers or strings, and the values can be numbers or strings.\n *\n * @returns {number[]} An array of numeric values extracted from the object.\n *\n * @example\n * ```typescript\n * import { getEnumNumberValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumNumberValues(RecordType)); // [0, 1]\n * ```\n */\nexport function getEnumNumberValues(data: Record<number | string, number | string>) {\n return Object.values(data).filter((value) => typeof value === 'number');\n}\n\n/**\n * Extracts the string values from an enumeration-like object.\n *\n * @param {Record<number | string, number | string>} data - The enumeration-like object to extract string values from.\n * The keys can be numbers or strings, and the values can be numbers or strings.\n *\n * @returns {string[]} An array of string values extracted from the object.\n *\n * @example\n * ```typescript\n * import { getEnumStringValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumStringValues(RecordType)); // ['unknown']\n * ```\n */\nexport function getEnumStringValues(data: Record<number | string, number | string>) {\n const keys: string[] = [];\n const keysCount: Record<string, number> = {};\n const values: any[] = [];\n Object.entries(data).forEach(([key, value]) => {\n keys.push(key);\n values.push(value);\n if (typeof value !== 'string') return;\n keysCount[key] = (keysCount[key] ?? 0) + 1;\n keysCount[value] = (keysCount[value] ?? 0) + 1;\n });\n\n return values.filter((value) => {\n return typeof value === 'string' && (!keys.includes(value) || (keysCount[value] && keysCount[value] > 1));\n });\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAC,IAA8C,EAAA;AAC9E,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC3E;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAC,IAA8C,EAAA;IAC9E,MAAM,IAAI,GAAa,EAAE;IACzB,MAAM,SAAS,GAA2B,EAAE;IAC5C,MAAM,MAAM,GAAU,EAAE;AACxB,IAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC1C,QAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAClB,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE;AAC/B,QAAA,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;AAC1C,QAAA,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;AAClD,KAAC,CAAC;AAEF,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAI;AAC3B,QAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7G,KAAC,CAAC;AACN;;;;"}
package/dist/env.cjs CHANGED
@@ -25,7 +25,9 @@ class EnvironmentNotFoundError extends Error {
25
25
  * Retrieves the value of an environment variable, or throws an error if not set.
26
26
  *
27
27
  * @param {string} key - The environment variable key to check.
28
+ *
28
29
  * @returns {string} The value of the environment variable.
30
+ *
29
31
  * @throws {EnvironmentNotFoundError} If the environment variable is not defined.
30
32
  *
31
33
  * @example
package/dist/env.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.cjs","sources":["../src/env.ts"],"sourcesContent":["/**\n * Custom error class for handling missing environment variables.\n *\n * Extends the built-in `Error` class and includes the missing key.\n *\n * @extends {Error}\n */\nexport class EnvironmentNotFoundError extends Error {\n readonly key: string;\n\n /**\n * Creates a new EnvironmentNotFoundError.\n *\n * @param {string} key - The missing environment variable key.\n */\n constructor(key: string) {\n super(`Missing environment variable: ${key}`);\n this.key = key;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Retrieves the value of an environment variable, or throws an error if not set.\n *\n * @param {string} key - The environment variable key to check.\n * @returns {string} The value of the environment variable.\n * @throws {EnvironmentNotFoundError} If the environment variable is not defined.\n *\n * @example\n * ```typescript\n * import { checkAndGetEnvValue } from '@kikiutils/shared/env';\n *\n * // When the environment variable 'API_KEY' is set:\n * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY\n *\n * // When the environment variable 'API_KEY' is not set:\n * try {\n * const apiKey = checkAndGetEnvValue('API_KEY');\n * } catch (error) {\n * console.error(error); // Missing environment variable: API_KEY\n * }\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (!process.env[key]) throw new EnvironmentNotFoundError(key);\n return process.env[key];\n}\n"],"names":[],"mappings":";;AAAA;;;;;;AAMG;AACG,MAAO,wBAAyB,SAAQ,KAAK,CAAA;AACtC,IAAA,GAAG;AAEZ;;;;AAIG;AACH,IAAA,WAAA,CAAY,GAAW,EAAA;AACnB,QAAA,KAAK,CAAC,CAAA,8BAAA,EAAiC,GAAG,CAAA,CAAE,CAAC;AAC7C,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;QACjC,KAAK,CAAC,iBAAiB,GAAG,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;;AAExD;AAED;;;;;;;;;;;;;;;;;;;;;AAqBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC9D,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;;"}
1
+ {"version":3,"file":"env.cjs","sources":["../src/env.ts"],"sourcesContent":["/**\n * Custom error class for handling missing environment variables.\n *\n * Extends the built-in `Error` class and includes the missing key.\n *\n * @extends {Error}\n */\nexport class EnvironmentNotFoundError extends Error {\n readonly key: string;\n\n /**\n * Creates a new EnvironmentNotFoundError.\n *\n * @param {string} key - The missing environment variable key.\n */\n constructor(key: string) {\n super(`Missing environment variable: ${key}`);\n this.key = key;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Retrieves the value of an environment variable, or throws an error if not set.\n *\n * @param {string} key - The environment variable key to check.\n *\n * @returns {string} The value of the environment variable.\n *\n * @throws {EnvironmentNotFoundError} If the environment variable is not defined.\n *\n * @example\n * ```typescript\n * import { checkAndGetEnvValue } from '@kikiutils/shared/env';\n *\n * // When the environment variable 'API_KEY' is set:\n * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY\n *\n * // When the environment variable 'API_KEY' is not set:\n * try {\n * const apiKey = checkAndGetEnvValue('API_KEY');\n * } catch (error) {\n * console.error(error); // Missing environment variable: API_KEY\n * }\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (!process.env[key]) throw new EnvironmentNotFoundError(key);\n return process.env[key];\n}\n"],"names":[],"mappings":";;AAAA;;;;;;AAMG;AACG,MAAO,wBAAyB,SAAQ,KAAK,CAAA;AACtC,IAAA,GAAG;AAEZ;;;;AAIG;AACH,IAAA,WAAA,CAAY,GAAW,EAAA;AACnB,QAAA,KAAK,CAAC,CAAA,8BAAA,EAAiC,GAAG,CAAA,CAAE,CAAC;AAC7C,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;QACjC,KAAK,CAAC,iBAAiB,GAAG,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;;AAExD;AAED;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC9D,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;;"}
package/dist/env.d.ts CHANGED
@@ -18,7 +18,9 @@ export declare class EnvironmentNotFoundError extends Error {
18
18
  * Retrieves the value of an environment variable, or throws an error if not set.
19
19
  *
20
20
  * @param {string} key - The environment variable key to check.
21
+ *
21
22
  * @returns {string} The value of the environment variable.
23
+ *
22
24
  * @throws {EnvironmentNotFoundError} If the environment variable is not defined.
23
25
  *
24
26
  * @example
package/dist/env.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;;OAIG;gBACS,GAAG,EAAE,MAAM;CAM1B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGvD"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;;OAIG;gBACS,GAAG,EAAE,MAAM;CAM1B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGvD"}
package/dist/env.mjs CHANGED
@@ -23,7 +23,9 @@ class EnvironmentNotFoundError extends Error {
23
23
  * Retrieves the value of an environment variable, or throws an error if not set.
24
24
  *
25
25
  * @param {string} key - The environment variable key to check.
26
+ *
26
27
  * @returns {string} The value of the environment variable.
28
+ *
27
29
  * @throws {EnvironmentNotFoundError} If the environment variable is not defined.
28
30
  *
29
31
  * @example
package/dist/env.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.mjs","sources":["../src/env.ts"],"sourcesContent":["/**\n * Custom error class for handling missing environment variables.\n *\n * Extends the built-in `Error` class and includes the missing key.\n *\n * @extends {Error}\n */\nexport class EnvironmentNotFoundError extends Error {\n readonly key: string;\n\n /**\n * Creates a new EnvironmentNotFoundError.\n *\n * @param {string} key - The missing environment variable key.\n */\n constructor(key: string) {\n super(`Missing environment variable: ${key}`);\n this.key = key;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Retrieves the value of an environment variable, or throws an error if not set.\n *\n * @param {string} key - The environment variable key to check.\n * @returns {string} The value of the environment variable.\n * @throws {EnvironmentNotFoundError} If the environment variable is not defined.\n *\n * @example\n * ```typescript\n * import { checkAndGetEnvValue } from '@kikiutils/shared/env';\n *\n * // When the environment variable 'API_KEY' is set:\n * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY\n *\n * // When the environment variable 'API_KEY' is not set:\n * try {\n * const apiKey = checkAndGetEnvValue('API_KEY');\n * } catch (error) {\n * console.error(error); // Missing environment variable: API_KEY\n * }\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (!process.env[key]) throw new EnvironmentNotFoundError(key);\n return process.env[key];\n}\n"],"names":[],"mappings":"AAAA;;;;;;AAMG;AACG,MAAO,wBAAyB,SAAQ,KAAK,CAAA;AACtC,IAAA,GAAG;AAEZ;;;;AAIG;AACH,IAAA,WAAA,CAAY,GAAW,EAAA;AACnB,QAAA,KAAK,CAAC,CAAA,8BAAA,EAAiC,GAAG,CAAA,CAAE,CAAC;AAC7C,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;QACjC,KAAK,CAAC,iBAAiB,GAAG,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;;AAExD;AAED;;;;;;;;;;;;;;;;;;;;;AAqBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC9D,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;"}
1
+ {"version":3,"file":"env.mjs","sources":["../src/env.ts"],"sourcesContent":["/**\n * Custom error class for handling missing environment variables.\n *\n * Extends the built-in `Error` class and includes the missing key.\n *\n * @extends {Error}\n */\nexport class EnvironmentNotFoundError extends Error {\n readonly key: string;\n\n /**\n * Creates a new EnvironmentNotFoundError.\n *\n * @param {string} key - The missing environment variable key.\n */\n constructor(key: string) {\n super(`Missing environment variable: ${key}`);\n this.key = key;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Retrieves the value of an environment variable, or throws an error if not set.\n *\n * @param {string} key - The environment variable key to check.\n *\n * @returns {string} The value of the environment variable.\n *\n * @throws {EnvironmentNotFoundError} If the environment variable is not defined.\n *\n * @example\n * ```typescript\n * import { checkAndGetEnvValue } from '@kikiutils/shared/env';\n *\n * // When the environment variable 'API_KEY' is set:\n * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY\n *\n * // When the environment variable 'API_KEY' is not set:\n * try {\n * const apiKey = checkAndGetEnvValue('API_KEY');\n * } catch (error) {\n * console.error(error); // Missing environment variable: API_KEY\n * }\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (!process.env[key]) throw new EnvironmentNotFoundError(key);\n return process.env[key];\n}\n"],"names":[],"mappings":"AAAA;;;;;;AAMG;AACG,MAAO,wBAAyB,SAAQ,KAAK,CAAA;AACtC,IAAA,GAAG;AAEZ;;;;AAIG;AACH,IAAA,WAAA,CAAY,GAAW,EAAA;AACnB,QAAA,KAAK,CAAC,CAAA,8BAAA,EAAiC,GAAG,CAAA,CAAE,CAAC;AAC7C,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;QACjC,KAAK,CAAC,iBAAiB,GAAG,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;;AAExD;AAED;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC9D,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"general.cjs","sources":["../src/general.ts"],"sourcesContent":["/**\n * Extracts the first value from an array or returns the value itself if it's not an array.\n *\n * - If `value` is an array, returns the first element.\n * - If `value` is not an array, returns `value` directly.\n * - If the result is `null` or `undefined`, and `defaultValue` is provided, returns `defaultValue` instead.\n *\n * @template T - The type of the input value(s).\n * @template D - The type of the default value (if provided).\n *\n * @param {T | T[]} value - A single value or an array of values.\n * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`.\n * @returns {T | D | undefined} The first value or the fallback.\n *\n * @example\n * ```typescript\n * import { extractFirstValue } from '@kikiutils/shared/general';\n *\n * console.log(extractFirstValue([1, 2, 3])); // 1\n * console.log(extractFirstValue('hello')); // hello\n * console.log(extractFirstValue([], 'default')); // default\n * console.log(extractFirstValue(undefined, 'fallback')); // fallback\n * ```\n */\nexport function extractFirstValue<T>(value: T | T[]): T | undefined;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue: D): D | NonNullable<T>;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue?: D) {\n return (Array.isArray(value) ? value[0] : value) ?? defaultValue;\n}\n"],"names":[],"mappings":";;AA0BgB,SAAA,iBAAiB,CAAO,KAAc,EAAE,YAAgB,EAAA;IACpE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,YAAY;AACpE;;;;"}
1
+ {"version":3,"file":"general.cjs","sources":["../src/general.ts"],"sourcesContent":["/**\n * Extracts the first value from an array or returns the value itself if it's not an array.\n *\n * - If `value` is an array, returns the first element.\n * - If `value` is not an array, returns `value` directly.\n * - If the result is `null` or `undefined`, and `defaultValue` is provided, returns `defaultValue` instead.\n *\n * @template T - The type of the input value(s).\n * @template D - The type of the default value (if provided).\n *\n * @param {T | T[]} value - A single value or an array of values.\n * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`.\n *\n * @returns {T | D | undefined} The first value or the fallback.\n *\n * @example\n * ```typescript\n * import { extractFirstValue } from '@kikiutils/shared/general';\n *\n * console.log(extractFirstValue([1, 2, 3])); // 1\n * console.log(extractFirstValue('hello')); // hello\n * console.log(extractFirstValue([], 'default')); // default\n * console.log(extractFirstValue(undefined, 'fallback')); // fallback\n * ```\n */\nexport function extractFirstValue<T>(value: T | T[]): T | undefined;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue: D): D | NonNullable<T>;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue?: D) {\n return (Array.isArray(value) ? value[0] : value) ?? defaultValue;\n}\n"],"names":[],"mappings":";;AA2BgB,SAAA,iBAAiB,CAAO,KAAc,EAAE,YAAgB,EAAA;IACpE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,YAAY;AACpE;;;;"}
package/dist/general.d.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  *
11
11
  * @param {T | T[]} value - A single value or an array of values.
12
12
  * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`.
13
+ *
13
14
  * @returns {T | D | undefined} The first value or the fallback.
14
15
  *
15
16
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../src/general.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;AACpE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../src/general.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;AACpE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"general.mjs","sources":["../src/general.ts"],"sourcesContent":["/**\n * Extracts the first value from an array or returns the value itself if it's not an array.\n *\n * - If `value` is an array, returns the first element.\n * - If `value` is not an array, returns `value` directly.\n * - If the result is `null` or `undefined`, and `defaultValue` is provided, returns `defaultValue` instead.\n *\n * @template T - The type of the input value(s).\n * @template D - The type of the default value (if provided).\n *\n * @param {T | T[]} value - A single value or an array of values.\n * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`.\n * @returns {T | D | undefined} The first value or the fallback.\n *\n * @example\n * ```typescript\n * import { extractFirstValue } from '@kikiutils/shared/general';\n *\n * console.log(extractFirstValue([1, 2, 3])); // 1\n * console.log(extractFirstValue('hello')); // hello\n * console.log(extractFirstValue([], 'default')); // default\n * console.log(extractFirstValue(undefined, 'fallback')); // fallback\n * ```\n */\nexport function extractFirstValue<T>(value: T | T[]): T | undefined;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue: D): D | NonNullable<T>;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue?: D) {\n return (Array.isArray(value) ? value[0] : value) ?? defaultValue;\n}\n"],"names":[],"mappings":"AA0BgB,SAAA,iBAAiB,CAAO,KAAc,EAAE,YAAgB,EAAA;IACpE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,YAAY;AACpE;;;;"}
1
+ {"version":3,"file":"general.mjs","sources":["../src/general.ts"],"sourcesContent":["/**\n * Extracts the first value from an array or returns the value itself if it's not an array.\n *\n * - If `value` is an array, returns the first element.\n * - If `value` is not an array, returns `value` directly.\n * - If the result is `null` or `undefined`, and `defaultValue` is provided, returns `defaultValue` instead.\n *\n * @template T - The type of the input value(s).\n * @template D - The type of the default value (if provided).\n *\n * @param {T | T[]} value - A single value or an array of values.\n * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`.\n *\n * @returns {T | D | undefined} The first value or the fallback.\n *\n * @example\n * ```typescript\n * import { extractFirstValue } from '@kikiutils/shared/general';\n *\n * console.log(extractFirstValue([1, 2, 3])); // 1\n * console.log(extractFirstValue('hello')); // hello\n * console.log(extractFirstValue([], 'default')); // default\n * console.log(extractFirstValue(undefined, 'fallback')); // fallback\n * ```\n */\nexport function extractFirstValue<T>(value: T | T[]): T | undefined;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue: D): D | NonNullable<T>;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue?: D) {\n return (Array.isArray(value) ? value[0] : value) ?? defaultValue;\n}\n"],"names":[],"mappings":"AA2BgB,SAAA,iBAAiB,CAAO,KAAc,EAAE,YAAgB,EAAA;IACpE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,YAAY;AACpE;;;;"}
package/dist/math.cjs CHANGED
@@ -12,6 +12,7 @@ const decimal_js = require('decimal.js');
12
12
  * @param {CalculableValue} molecular - The numerator of the fraction.
13
13
  * @param {CalculableValue} denominator - The denominator of the fraction.
14
14
  * @param {ToPercentageStringOptions} [options] - Optional output settings.
15
+ *
15
16
  * @returns {string} Formatted percentage string.
16
17
  *
17
18
  * @example
package/dist/math.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"math.cjs","sources":["../src/math.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\n\ntype CalculableValue = Decimal.Value | { toString: () => string };\n\n/**\n * Options for configuring the output of `toPercentageString`.\n */\nexport interface ToPercentageStringOptions {\n /**\n * Number of decimal places to include in the result.\n * @default 2\n */\n decimalPlaces?: number;\n\n /**\n * Whether to include the '%' symbol in the result.\n * @default true\n */\n withSymbol?: boolean;\n}\n\n/**\n * Converts a fraction (numerator / denominator) into a percentage string.\n *\n * - Uses `decimal.js` for precise decimal calculations.\n * - Supports custom decimal places and optional percentage symbol.\n * - Returns `'0.00%'` if result is `NaN` or division is invalid.\n *\n * @param {CalculableValue} molecular - The numerator of the fraction.\n * @param {CalculableValue} denominator - The denominator of the fraction.\n * @param {ToPercentageStringOptions} [options] - Optional output settings.\n * @returns {string} Formatted percentage string.\n *\n * @example\n * ```typescript\n * import { toPercentageString } from '@kikiutils/shared/math';\n *\n * console.log(toPercentageString(50, 200)); // 25.00%\n * console.log(toPercentageString(50, 200, { withSymbol: false })); // 25.00\n * console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // 25.0%\n * ```\n */\nexport function toPercentageString(\n molecular: CalculableValue,\n denominator: CalculableValue,\n options?: ToPercentageStringOptions,\n) {\n const molecularDecimal = new Decimal(molecular.toString());\n const denominatorDecimal = new Decimal(denominator.toString());\n const calculationResult = molecularDecimal.div(denominatorDecimal);\n const result = calculationResult.isNaN()\n ? '0.00'\n : calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);\n\n return options?.withSymbol ?? true ? `${result}%` : result;\n}\n"],"names":["Decimal"],"mappings":";;;;AAqBA;;;;;;;;;;;;;;;;;;;;AAoBG;SACa,kBAAkB,CAC9B,SAA0B,EAC1B,WAA4B,EAC5B,OAAmC,EAAA;IAEnC,MAAM,gBAAgB,GAAG,IAAIA,kBAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,IAAIA,kBAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC9D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAClE,IAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK;AAClC,UAAE;AACF,UAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,CAAC;AAEvE,IAAA,OAAO,OAAO,EAAE,UAAU,IAAI,IAAI,GAAG,CAAA,EAAG,MAAM,CAAG,CAAA,CAAA,GAAG,MAAM;AAC9D;;;;"}
1
+ {"version":3,"file":"math.cjs","sources":["../src/math.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\n\ntype CalculableValue = Decimal.Value | { toString: () => string };\n\n/**\n * Options for configuring the output of `toPercentageString`.\n */\nexport interface ToPercentageStringOptions {\n /**\n * Number of decimal places to include in the result.\n *\n * @default 2\n */\n decimalPlaces?: number;\n\n /**\n * Whether to include the '%' symbol in the result.\n *\n * @default true\n */\n withSymbol?: boolean;\n}\n\n/**\n * Converts a fraction (numerator / denominator) into a percentage string.\n *\n * - Uses `decimal.js` for precise decimal calculations.\n * - Supports custom decimal places and optional percentage symbol.\n * - Returns `'0.00%'` if result is `NaN` or division is invalid.\n *\n * @param {CalculableValue} molecular - The numerator of the fraction.\n * @param {CalculableValue} denominator - The denominator of the fraction.\n * @param {ToPercentageStringOptions} [options] - Optional output settings.\n *\n * @returns {string} Formatted percentage string.\n *\n * @example\n * ```typescript\n * import { toPercentageString } from '@kikiutils/shared/math';\n *\n * console.log(toPercentageString(50, 200)); // 25.00%\n * console.log(toPercentageString(50, 200, { withSymbol: false })); // 25.00\n * console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // 25.0%\n * ```\n */\nexport function toPercentageString(\n molecular: CalculableValue,\n denominator: CalculableValue,\n options?: ToPercentageStringOptions,\n) {\n const molecularDecimal = new Decimal(molecular.toString());\n const denominatorDecimal = new Decimal(denominator.toString());\n const calculationResult = molecularDecimal.div(denominatorDecimal);\n const result = calculationResult.isNaN()\n ? '0.00'\n : calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);\n\n return options?.withSymbol ?? true ? `${result}%` : result;\n}\n"],"names":["Decimal"],"mappings":";;;;AAuBA;;;;;;;;;;;;;;;;;;;;;AAqBG;SACa,kBAAkB,CAC9B,SAA0B,EAC1B,WAA4B,EAC5B,OAAmC,EAAA;IAEnC,MAAM,gBAAgB,GAAG,IAAIA,kBAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,IAAIA,kBAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC9D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAClE,IAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK;AAClC,UAAE;AACF,UAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,CAAC;AAEvE,IAAA,OAAO,OAAO,EAAE,UAAU,IAAI,IAAI,GAAG,CAAA,EAAG,MAAM,CAAG,CAAA,CAAA,GAAG,MAAM;AAC9D;;;;"}
package/dist/math.d.ts CHANGED
@@ -8,11 +8,13 @@ type CalculableValue = Decimal.Value | {
8
8
  export interface ToPercentageStringOptions {
9
9
  /**
10
10
  * Number of decimal places to include in the result.
11
+ *
11
12
  * @default 2
12
13
  */
13
14
  decimalPlaces?: number;
14
15
  /**
15
16
  * Whether to include the '%' symbol in the result.
17
+ *
16
18
  * @default true
17
19
  */
18
20
  withSymbol?: boolean;
@@ -27,6 +29,7 @@ export interface ToPercentageStringOptions {
27
29
  * @param {CalculableValue} molecular - The numerator of the fraction.
28
30
  * @param {CalculableValue} denominator - The denominator of the fraction.
29
31
  * @param {ToPercentageStringOptions} [options] - Optional output settings.
32
+ *
30
33
  * @returns {string} Formatted percentage string.
31
34
  *
32
35
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,KAAK,eAAe,GAAG,OAAO,CAAC,KAAK,GAAG;IAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;CAAE,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAC9B,SAAS,EAAE,eAAe,EAC1B,WAAW,EAAE,eAAe,EAC5B,OAAO,CAAC,EAAE,yBAAyB,UAUtC"}
1
+ {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,KAAK,eAAe,GAAG,OAAO,CAAC,KAAK,GAAG;IAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;CAAE,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAC9B,SAAS,EAAE,eAAe,EAC1B,WAAW,EAAE,eAAe,EAC5B,OAAO,CAAC,EAAE,yBAAyB,UAUtC"}
package/dist/math.mjs CHANGED
@@ -10,6 +10,7 @@ import { Decimal } from 'decimal.js';
10
10
  * @param {CalculableValue} molecular - The numerator of the fraction.
11
11
  * @param {CalculableValue} denominator - The denominator of the fraction.
12
12
  * @param {ToPercentageStringOptions} [options] - Optional output settings.
13
+ *
13
14
  * @returns {string} Formatted percentage string.
14
15
  *
15
16
  * @example
package/dist/math.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"math.mjs","sources":["../src/math.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\n\ntype CalculableValue = Decimal.Value | { toString: () => string };\n\n/**\n * Options for configuring the output of `toPercentageString`.\n */\nexport interface ToPercentageStringOptions {\n /**\n * Number of decimal places to include in the result.\n * @default 2\n */\n decimalPlaces?: number;\n\n /**\n * Whether to include the '%' symbol in the result.\n * @default true\n */\n withSymbol?: boolean;\n}\n\n/**\n * Converts a fraction (numerator / denominator) into a percentage string.\n *\n * - Uses `decimal.js` for precise decimal calculations.\n * - Supports custom decimal places and optional percentage symbol.\n * - Returns `'0.00%'` if result is `NaN` or division is invalid.\n *\n * @param {CalculableValue} molecular - The numerator of the fraction.\n * @param {CalculableValue} denominator - The denominator of the fraction.\n * @param {ToPercentageStringOptions} [options] - Optional output settings.\n * @returns {string} Formatted percentage string.\n *\n * @example\n * ```typescript\n * import { toPercentageString } from '@kikiutils/shared/math';\n *\n * console.log(toPercentageString(50, 200)); // 25.00%\n * console.log(toPercentageString(50, 200, { withSymbol: false })); // 25.00\n * console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // 25.0%\n * ```\n */\nexport function toPercentageString(\n molecular: CalculableValue,\n denominator: CalculableValue,\n options?: ToPercentageStringOptions,\n) {\n const molecularDecimal = new Decimal(molecular.toString());\n const denominatorDecimal = new Decimal(denominator.toString());\n const calculationResult = molecularDecimal.div(denominatorDecimal);\n const result = calculationResult.isNaN()\n ? '0.00'\n : calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);\n\n return options?.withSymbol ?? true ? `${result}%` : result;\n}\n"],"names":[],"mappings":";;AAqBA;;;;;;;;;;;;;;;;;;;;AAoBG;SACa,kBAAkB,CAC9B,SAA0B,EAC1B,WAA4B,EAC5B,OAAmC,EAAA;IAEnC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC9D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAClE,IAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK;AAClC,UAAE;AACF,UAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,CAAC;AAEvE,IAAA,OAAO,OAAO,EAAE,UAAU,IAAI,IAAI,GAAG,CAAA,EAAG,MAAM,CAAG,CAAA,CAAA,GAAG,MAAM;AAC9D;;;;"}
1
+ {"version":3,"file":"math.mjs","sources":["../src/math.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\n\ntype CalculableValue = Decimal.Value | { toString: () => string };\n\n/**\n * Options for configuring the output of `toPercentageString`.\n */\nexport interface ToPercentageStringOptions {\n /**\n * Number of decimal places to include in the result.\n *\n * @default 2\n */\n decimalPlaces?: number;\n\n /**\n * Whether to include the '%' symbol in the result.\n *\n * @default true\n */\n withSymbol?: boolean;\n}\n\n/**\n * Converts a fraction (numerator / denominator) into a percentage string.\n *\n * - Uses `decimal.js` for precise decimal calculations.\n * - Supports custom decimal places and optional percentage symbol.\n * - Returns `'0.00%'` if result is `NaN` or division is invalid.\n *\n * @param {CalculableValue} molecular - The numerator of the fraction.\n * @param {CalculableValue} denominator - The denominator of the fraction.\n * @param {ToPercentageStringOptions} [options] - Optional output settings.\n *\n * @returns {string} Formatted percentage string.\n *\n * @example\n * ```typescript\n * import { toPercentageString } from '@kikiutils/shared/math';\n *\n * console.log(toPercentageString(50, 200)); // 25.00%\n * console.log(toPercentageString(50, 200, { withSymbol: false })); // 25.00\n * console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // 25.0%\n * ```\n */\nexport function toPercentageString(\n molecular: CalculableValue,\n denominator: CalculableValue,\n options?: ToPercentageStringOptions,\n) {\n const molecularDecimal = new Decimal(molecular.toString());\n const denominatorDecimal = new Decimal(denominator.toString());\n const calculationResult = molecularDecimal.div(denominatorDecimal);\n const result = calculationResult.isNaN()\n ? '0.00'\n : calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);\n\n return options?.withSymbol ?? true ? `${result}%` : result;\n}\n"],"names":[],"mappings":";;AAuBA;;;;;;;;;;;;;;;;;;;;;AAqBG;SACa,kBAAkB,CAC9B,SAA0B,EAC1B,WAA4B,EAC5B,OAAmC,EAAA;IAEnC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC9D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAClE,IAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK;AAClC,UAAE;AACF,UAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,CAAC;AAEvE,IAAA,OAAO,OAAO,EAAE,UAAU,IAAI,IAAI,GAAG,CAAA,EAAG,MAAM,CAAG,CAAA,CAAA,GAAG,MAAM;AAC9D;;;;"}
package/dist/number.cjs CHANGED
@@ -9,6 +9,7 @@ const millify = require('millify');
9
9
  *
10
10
  * @param {number} value - The number to format.
11
11
  * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`.
12
+ *
12
13
  * @returns {string} The compact number string.
13
14
  *
14
15
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"number.cjs","sources":["../src/number.ts"],"sourcesContent":["import { millify } from 'millify';\n\n/**\n * Converts a large number into a compact, human-readable string using `millify`.\n *\n * Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.\n *\n * @param {number} value - The number to format.\n * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`.\n * @returns {string} The compact number string.\n *\n * @example\n * ```typescript\n * import { toCompactNumberString } from '@kikiutils/shared/number';\n *\n * console.log(toCompactNumberString(1234567)); // 1.23m\n * console.log(toCompactNumberString(1234567, { precision: 3 })); // 1.235m\n * ```\n */\nexport function toCompactNumberString(value: number, options?: Parameters<typeof millify>[1]) {\n return millify(\n value,\n {\n lowercase: true,\n precision: 2,\n ...options,\n },\n );\n}\n"],"names":["millify"],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;AAgBG;AACa,SAAA,qBAAqB,CAAC,KAAa,EAAE,OAAuC,EAAA;IACxF,OAAOA,eAAO,CACV,KAAK,EACL;AACI,QAAA,SAAS,EAAE,IAAI;AACf,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,GAAG,OAAO;AACb,KAAA,CACJ;AACL;;;;"}
1
+ {"version":3,"file":"number.cjs","sources":["../src/number.ts"],"sourcesContent":["import { millify } from 'millify';\n\n/**\n * Converts a large number into a compact, human-readable string using `millify`.\n *\n * Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.\n *\n * @param {number} value - The number to format.\n * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`.\n *\n * @returns {string} The compact number string.\n *\n * @example\n * ```typescript\n * import { toCompactNumberString } from '@kikiutils/shared/number';\n *\n * console.log(toCompactNumberString(1234567)); // 1.23m\n * console.log(toCompactNumberString(1234567, { precision: 3 })); // 1.235m\n * ```\n */\nexport function toCompactNumberString(value: number, options?: Parameters<typeof millify>[1]) {\n return millify(\n value,\n {\n lowercase: true,\n precision: 2,\n ...options,\n },\n );\n}\n"],"names":["millify"],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACa,SAAA,qBAAqB,CAAC,KAAa,EAAE,OAAuC,EAAA;IACxF,OAAOA,eAAO,CACV,KAAK,EACL;AACI,QAAA,SAAS,EAAE,IAAI;AACf,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,GAAG,OAAO;AACb,KAAA,CACJ;AACL;;;;"}
package/dist/number.d.ts CHANGED
@@ -6,6 +6,7 @@ import { millify } from 'millify';
6
6
  *
7
7
  * @param {number} value - The number to format.
8
8
  * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`.
9
+ *
9
10
  * @returns {string} The compact number string.
10
11
  *
11
12
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,UAS3F"}
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,UAS3F"}
package/dist/number.mjs CHANGED
@@ -7,6 +7,7 @@ import { millify } from 'millify';
7
7
  *
8
8
  * @param {number} value - The number to format.
9
9
  * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`.
10
+ *
10
11
  * @returns {string} The compact number string.
11
12
  *
12
13
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"number.mjs","sources":["../src/number.ts"],"sourcesContent":["import { millify } from 'millify';\n\n/**\n * Converts a large number into a compact, human-readable string using `millify`.\n *\n * Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.\n *\n * @param {number} value - The number to format.\n * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`.\n * @returns {string} The compact number string.\n *\n * @example\n * ```typescript\n * import { toCompactNumberString } from '@kikiutils/shared/number';\n *\n * console.log(toCompactNumberString(1234567)); // 1.23m\n * console.log(toCompactNumberString(1234567, { precision: 3 })); // 1.235m\n * ```\n */\nexport function toCompactNumberString(value: number, options?: Parameters<typeof millify>[1]) {\n return millify(\n value,\n {\n lowercase: true,\n precision: 2,\n ...options,\n },\n );\n}\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;AAgBG;AACa,SAAA,qBAAqB,CAAC,KAAa,EAAE,OAAuC,EAAA;IACxF,OAAO,OAAO,CACV,KAAK,EACL;AACI,QAAA,SAAS,EAAE,IAAI;AACf,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,GAAG,OAAO;AACb,KAAA,CACJ;AACL;;;;"}
1
+ {"version":3,"file":"number.mjs","sources":["../src/number.ts"],"sourcesContent":["import { millify } from 'millify';\n\n/**\n * Converts a large number into a compact, human-readable string using `millify`.\n *\n * Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.\n *\n * @param {number} value - The number to format.\n * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`.\n *\n * @returns {string} The compact number string.\n *\n * @example\n * ```typescript\n * import { toCompactNumberString } from '@kikiutils/shared/number';\n *\n * console.log(toCompactNumberString(1234567)); // 1.23m\n * console.log(toCompactNumberString(1234567, { precision: 3 })); // 1.235m\n * ```\n */\nexport function toCompactNumberString(value: number, options?: Parameters<typeof millify>[1]) {\n return millify(\n value,\n {\n lowercase: true,\n precision: 2,\n ...options,\n },\n );\n}\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACa,SAAA,qBAAqB,CAAC,KAAa,EAAE,OAAuC,EAAA;IACxF,OAAO,OAAO,CACV,KAAK,EACL;AACI,QAAA,SAAS,EAAE,IAAI;AACf,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,GAAG,OAAO;AACb,KAAA,CACJ;AACL;;;;"}
package/dist/pino.cjs CHANGED
@@ -24,7 +24,7 @@ const stream = pinoPretty.PinoPretty({
24
24
  *
25
25
  * @example
26
26
  * ```typescript
27
- * import logger from '@kikiutils/shared/pino';
27
+ * import { logger } from '@kikiutils/shared/pino';
28
28
  *
29
29
  * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test
30
30
  *
package/dist/pino.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pino.cjs","sources":["../src/pino.ts"],"sourcesContent":["import { pino } from 'pino';\nimport { PinoPretty } from 'pino-pretty';\n\n/**\n * Configure pinoPretty to enhance the log output.\n */\nconst stream = PinoPretty({\n colorize: true, // Enable colored output for better readability\n ignore: 'hostname,pid', // Exclude 'hostname' and 'pid' fields from the logs\n translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l', // Format the timestamp in 'yyyy-mm-dd HH:MM:ss.l' format\n});\n\n/**\n * A pino logger instance with the configured stream.\n *\n * The logger's level is determined based on the `PINO_LOGGER_LEVEL` and `NODE_ENV` environment variables.\n * If `PINO_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,\n * the level will be set to `error`.\n *\n * To manually change the level, assign the desired level to `logger.level`.\n *\n * See available levels [here](https://getpino.io/#/docs/api?id=level-string).\n *\n * @example\n * ```typescript\n * import logger from '@kikiutils/shared/pino';\n *\n * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test\n *\n * // Manually change the level\n * logger.level = 'info';\n * ```\n */\nexport const pinoLogger = pino({}, stream);\nexport const logger = pinoLogger;\n// eslint-disable-next-line style/max-len\npinoLogger.level = process.env.PINO_LOGGER_LEVEL || (process.env.NODE_ENV === 'production' ? 'error' : pinoLogger.level);\n"],"names":["PinoPretty","pino"],"mappings":";;;;;AAGA;;AAEG;AACH,MAAM,MAAM,GAAGA,qBAAU,CAAC;IACtB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,cAAc;IACtB,aAAa,EAAE,2BAA2B;AAC7C,CAAA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;AAoBG;AACU,MAAA,UAAU,GAAGC,SAAI,CAAC,EAAE,EAAE,MAAM;AAClC,MAAM,MAAM,GAAG;AACtB;AACA,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC;;;;;"}
1
+ {"version":3,"file":"pino.cjs","sources":["../src/pino.ts"],"sourcesContent":["import { pino } from 'pino';\nimport { PinoPretty } from 'pino-pretty';\n\n/**\n * Configure pinoPretty to enhance the log output.\n */\nconst stream = PinoPretty({\n colorize: true, // Enable colored output for better readability\n ignore: 'hostname,pid', // Exclude 'hostname' and 'pid' fields from the logs\n translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l', // Format the timestamp in 'yyyy-mm-dd HH:MM:ss.l' format\n});\n\n/**\n * A pino logger instance with the configured stream.\n *\n * The logger's level is determined based on the `PINO_LOGGER_LEVEL` and `NODE_ENV` environment variables.\n * If `PINO_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,\n * the level will be set to `error`.\n *\n * To manually change the level, assign the desired level to `logger.level`.\n *\n * See available levels [here](https://getpino.io/#/docs/api?id=level-string).\n *\n * @example\n * ```typescript\n * import { logger } from '@kikiutils/shared/pino';\n *\n * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test\n *\n * // Manually change the level\n * logger.level = 'info';\n * ```\n */\nexport const pinoLogger = pino({}, stream);\nexport const logger = pinoLogger;\n// eslint-disable-next-line style/max-len\npinoLogger.level = process.env.PINO_LOGGER_LEVEL || (process.env.NODE_ENV === 'production' ? 'error' : pinoLogger.level);\n"],"names":["PinoPretty","pino"],"mappings":";;;;;AAGA;;AAEG;AACH,MAAM,MAAM,GAAGA,qBAAU,CAAC;IACtB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,cAAc;IACtB,aAAa,EAAE,2BAA2B;AAC7C,CAAA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;AAoBG;AACU,MAAA,UAAU,GAAGC,SAAI,CAAC,EAAE,EAAE,MAAM;AAClC,MAAM,MAAM,GAAG;AACtB;AACA,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC;;;;;"}
package/dist/pino.d.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @example
13
13
  * ```typescript
14
- * import logger from '@kikiutils/shared/pino';
14
+ * import { logger } from '@kikiutils/shared/pino';
15
15
  *
16
16
  * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test
17
17
  *
package/dist/pino.mjs CHANGED
@@ -22,7 +22,7 @@ const stream = PinoPretty({
22
22
  *
23
23
  * @example
24
24
  * ```typescript
25
- * import logger from '@kikiutils/shared/pino';
25
+ * import { logger } from '@kikiutils/shared/pino';
26
26
  *
27
27
  * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test
28
28
  *
package/dist/pino.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pino.mjs","sources":["../src/pino.ts"],"sourcesContent":["import { pino } from 'pino';\nimport { PinoPretty } from 'pino-pretty';\n\n/**\n * Configure pinoPretty to enhance the log output.\n */\nconst stream = PinoPretty({\n colorize: true, // Enable colored output for better readability\n ignore: 'hostname,pid', // Exclude 'hostname' and 'pid' fields from the logs\n translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l', // Format the timestamp in 'yyyy-mm-dd HH:MM:ss.l' format\n});\n\n/**\n * A pino logger instance with the configured stream.\n *\n * The logger's level is determined based on the `PINO_LOGGER_LEVEL` and `NODE_ENV` environment variables.\n * If `PINO_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,\n * the level will be set to `error`.\n *\n * To manually change the level, assign the desired level to `logger.level`.\n *\n * See available levels [here](https://getpino.io/#/docs/api?id=level-string).\n *\n * @example\n * ```typescript\n * import logger from '@kikiutils/shared/pino';\n *\n * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test\n *\n * // Manually change the level\n * logger.level = 'info';\n * ```\n */\nexport const pinoLogger = pino({}, stream);\nexport const logger = pinoLogger;\n// eslint-disable-next-line style/max-len\npinoLogger.level = process.env.PINO_LOGGER_LEVEL || (process.env.NODE_ENV === 'production' ? 'error' : pinoLogger.level);\n"],"names":[],"mappings":";;;AAGA;;AAEG;AACH,MAAM,MAAM,GAAG,UAAU,CAAC;IACtB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,cAAc;IACtB,aAAa,EAAE,2BAA2B;AAC7C,CAAA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;AAoBG;AACU,MAAA,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,MAAM;AAClC,MAAM,MAAM,GAAG;AACtB;AACA,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC;;;;"}
1
+ {"version":3,"file":"pino.mjs","sources":["../src/pino.ts"],"sourcesContent":["import { pino } from 'pino';\nimport { PinoPretty } from 'pino-pretty';\n\n/**\n * Configure pinoPretty to enhance the log output.\n */\nconst stream = PinoPretty({\n colorize: true, // Enable colored output for better readability\n ignore: 'hostname,pid', // Exclude 'hostname' and 'pid' fields from the logs\n translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l', // Format the timestamp in 'yyyy-mm-dd HH:MM:ss.l' format\n});\n\n/**\n * A pino logger instance with the configured stream.\n *\n * The logger's level is determined based on the `PINO_LOGGER_LEVEL` and `NODE_ENV` environment variables.\n * If `PINO_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,\n * the level will be set to `error`.\n *\n * To manually change the level, assign the desired level to `logger.level`.\n *\n * See available levels [here](https://getpino.io/#/docs/api?id=level-string).\n *\n * @example\n * ```typescript\n * import { logger } from '@kikiutils/shared/pino';\n *\n * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test\n *\n * // Manually change the level\n * logger.level = 'info';\n * ```\n */\nexport const pinoLogger = pino({}, stream);\nexport const logger = pinoLogger;\n// eslint-disable-next-line style/max-len\npinoLogger.level = process.env.PINO_LOGGER_LEVEL || (process.env.NODE_ENV === 'production' ? 'error' : pinoLogger.level);\n"],"names":[],"mappings":";;;AAGA;;AAEG;AACH,MAAM,MAAM,GAAG,UAAU,CAAC;IACtB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,cAAc;IACtB,aAAa,EAAE,2BAA2B;AAC7C,CAAA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;AAoBG;AACU,MAAA,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,MAAM;AAClC,MAAM,MAAM,GAAG;AACtB;AACA,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC;;;;"}
package/dist/random.cjs CHANGED
@@ -10,14 +10,15 @@
10
10
  *
11
11
  * This function supports any return type by using a generic type parameter.
12
12
  *
13
- * @typeParam T - The return type of the generator function.
13
+ * @template T - The return type of the generator function.
14
14
  *
15
- * @param generator - A function that accepts a length and returns a value of type T.
16
- * @param minMin - Lower bound of the first random range.
17
- * @param minMax - Upper bound of the first random range.
18
- * @param maxMin - Lower bound of the second random range.
19
- * @param maxMax - Upper bound of the second random range.
20
- * @returns The result of the generator function using the computed final length.
15
+ * @param {(length: number) => T} generator - A function that accepts a length and returns a value of type T.
16
+ * @param {number} minMin - Lower bound of the first random range.
17
+ * @param {number} minMax - Upper bound of the first random range.
18
+ * @param {number} maxMin - Lower bound of the second random range.
19
+ * @param {number} maxMax - Upper bound of the second random range.
20
+ *
21
+ * @returns {T} The result of the generator function using the computed final length.
21
22
  */
22
23
  function generateWithNestedRandomLength(generator, minMin, minMax, maxMin, maxMax) {
23
24
  const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
@@ -1 +1 @@
1
- {"version":3,"file":"random.cjs","sources":["../src/random.ts"],"sourcesContent":["/**\n * Generates a value using a provided generator function, where the input length\n * is determined by two levels of nested random ranges:\n *\n * 1. First, a random number (`innerMin`) is chosen between `minMin` and `minMax`.\n * 2. Then, a final length is chosen between `Math.max(innerMin, maxMin)` and `maxMax`.\n * 3. The generator is called with the final length and its result is returned.\n *\n * This function supports any return type by using a generic type parameter.\n *\n * @typeParam T - The return type of the generator function.\n *\n * @param generator - A function that accepts a length and returns a value of type T.\n * @param minMin - Lower bound of the first random range.\n * @param minMax - Upper bound of the first random range.\n * @param maxMin - Lower bound of the second random range.\n * @param maxMax - Upper bound of the second random range.\n * @returns The result of the generator function using the computed final length.\n */\nexport function generateWithNestedRandomLength<T = string>(\n generator: (length: number) => T,\n minMin: number,\n minMax: number,\n maxMin: number,\n maxMax: number,\n) {\n const random = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;\n const innerMin = random(minMin, minMax);\n const finalLength = random(Math.max(innerMin, maxMin), maxMax);\n return generator(finalLength);\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,8BAA8B,CAC1C,SAAgC,EAChC,MAAc,EACd,MAAc,EACd,MAAc,EACd,MAAc,EAAA;AAEd,IAAA,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,GAAW,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG;IAC9F,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;AACvC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;AAC9D,IAAA,OAAO,SAAS,CAAC,WAAW,CAAC;AACjC;;;;"}
1
+ {"version":3,"file":"random.cjs","sources":["../src/random.ts"],"sourcesContent":["/**\n * Generates a value using a provided generator function, where the input length\n * is determined by two levels of nested random ranges:\n *\n * 1. First, a random number (`innerMin`) is chosen between `minMin` and `minMax`.\n * 2. Then, a final length is chosen between `Math.max(innerMin, maxMin)` and `maxMax`.\n * 3. The generator is called with the final length and its result is returned.\n *\n * This function supports any return type by using a generic type parameter.\n *\n * @template T - The return type of the generator function.\n *\n * @param {(length: number) => T} generator - A function that accepts a length and returns a value of type T.\n * @param {number} minMin - Lower bound of the first random range.\n * @param {number} minMax - Upper bound of the first random range.\n * @param {number} maxMin - Lower bound of the second random range.\n * @param {number} maxMax - Upper bound of the second random range.\n *\n * @returns {T} The result of the generator function using the computed final length.\n */\nexport function generateWithNestedRandomLength<T = string>(\n generator: (length: number) => T,\n minMin: number,\n minMax: number,\n maxMin: number,\n maxMax: number,\n) {\n const random = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;\n const innerMin = random(minMin, minMax);\n const finalLength = random(Math.max(innerMin, maxMin), maxMax);\n return generator(finalLength);\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,8BAA8B,CAC1C,SAAgC,EAChC,MAAc,EACd,MAAc,EACd,MAAc,EACd,MAAc,EAAA;AAEd,IAAA,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,GAAW,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG;IAC9F,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;AACvC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;AAC9D,IAAA,OAAO,SAAS,CAAC,WAAW,CAAC;AACjC;;;;"}
package/dist/random.d.ts CHANGED
@@ -8,14 +8,15 @@
8
8
  *
9
9
  * This function supports any return type by using a generic type parameter.
10
10
  *
11
- * @typeParam T - The return type of the generator function.
11
+ * @template T - The return type of the generator function.
12
12
  *
13
- * @param generator - A function that accepts a length and returns a value of type T.
14
- * @param minMin - Lower bound of the first random range.
15
- * @param minMax - Upper bound of the first random range.
16
- * @param maxMin - Lower bound of the second random range.
17
- * @param maxMax - Upper bound of the second random range.
18
- * @returns The result of the generator function using the computed final length.
13
+ * @param {(length: number) => T} generator - A function that accepts a length and returns a value of type T.
14
+ * @param {number} minMin - Lower bound of the first random range.
15
+ * @param {number} minMax - Upper bound of the first random range.
16
+ * @param {number} maxMin - Lower bound of the second random range.
17
+ * @param {number} maxMax - Upper bound of the second random range.
18
+ *
19
+ * @returns {T} The result of the generator function using the computed final length.
19
20
  */
20
21
  export declare function generateWithNestedRandomLength<T = string>(generator: (length: number) => T, minMin: number, minMax: number, maxMin: number, maxMax: number): T;
21
22
  //# sourceMappingURL=random.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,GAAG,MAAM,EACrD,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,KAMjB"}
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,GAAG,MAAM,EACrD,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,KAMjB"}
package/dist/random.mjs CHANGED
@@ -8,14 +8,15 @@
8
8
  *
9
9
  * This function supports any return type by using a generic type parameter.
10
10
  *
11
- * @typeParam T - The return type of the generator function.
11
+ * @template T - The return type of the generator function.
12
12
  *
13
- * @param generator - A function that accepts a length and returns a value of type T.
14
- * @param minMin - Lower bound of the first random range.
15
- * @param minMax - Upper bound of the first random range.
16
- * @param maxMin - Lower bound of the second random range.
17
- * @param maxMax - Upper bound of the second random range.
18
- * @returns The result of the generator function using the computed final length.
13
+ * @param {(length: number) => T} generator - A function that accepts a length and returns a value of type T.
14
+ * @param {number} minMin - Lower bound of the first random range.
15
+ * @param {number} minMax - Upper bound of the first random range.
16
+ * @param {number} maxMin - Lower bound of the second random range.
17
+ * @param {number} maxMax - Upper bound of the second random range.
18
+ *
19
+ * @returns {T} The result of the generator function using the computed final length.
19
20
  */
20
21
  function generateWithNestedRandomLength(generator, minMin, minMax, maxMin, maxMax) {
21
22
  const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
@@ -1 +1 @@
1
- {"version":3,"file":"random.mjs","sources":["../src/random.ts"],"sourcesContent":["/**\n * Generates a value using a provided generator function, where the input length\n * is determined by two levels of nested random ranges:\n *\n * 1. First, a random number (`innerMin`) is chosen between `minMin` and `minMax`.\n * 2. Then, a final length is chosen between `Math.max(innerMin, maxMin)` and `maxMax`.\n * 3. The generator is called with the final length and its result is returned.\n *\n * This function supports any return type by using a generic type parameter.\n *\n * @typeParam T - The return type of the generator function.\n *\n * @param generator - A function that accepts a length and returns a value of type T.\n * @param minMin - Lower bound of the first random range.\n * @param minMax - Upper bound of the first random range.\n * @param maxMin - Lower bound of the second random range.\n * @param maxMax - Upper bound of the second random range.\n * @returns The result of the generator function using the computed final length.\n */\nexport function generateWithNestedRandomLength<T = string>(\n generator: (length: number) => T,\n minMin: number,\n minMax: number,\n maxMin: number,\n maxMax: number,\n) {\n const random = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;\n const innerMin = random(minMin, minMax);\n const finalLength = random(Math.max(innerMin, maxMin), maxMax);\n return generator(finalLength);\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,8BAA8B,CAC1C,SAAgC,EAChC,MAAc,EACd,MAAc,EACd,MAAc,EACd,MAAc,EAAA;AAEd,IAAA,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,GAAW,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG;IAC9F,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;AACvC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;AAC9D,IAAA,OAAO,SAAS,CAAC,WAAW,CAAC;AACjC;;;;"}
1
+ {"version":3,"file":"random.mjs","sources":["../src/random.ts"],"sourcesContent":["/**\n * Generates a value using a provided generator function, where the input length\n * is determined by two levels of nested random ranges:\n *\n * 1. First, a random number (`innerMin`) is chosen between `minMin` and `minMax`.\n * 2. Then, a final length is chosen between `Math.max(innerMin, maxMin)` and `maxMax`.\n * 3. The generator is called with the final length and its result is returned.\n *\n * This function supports any return type by using a generic type parameter.\n *\n * @template T - The return type of the generator function.\n *\n * @param {(length: number) => T} generator - A function that accepts a length and returns a value of type T.\n * @param {number} minMin - Lower bound of the first random range.\n * @param {number} minMax - Upper bound of the first random range.\n * @param {number} maxMin - Lower bound of the second random range.\n * @param {number} maxMax - Upper bound of the second random range.\n *\n * @returns {T} The result of the generator function using the computed final length.\n */\nexport function generateWithNestedRandomLength<T = string>(\n generator: (length: number) => T,\n minMin: number,\n minMax: number,\n maxMin: number,\n maxMax: number,\n) {\n const random = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;\n const innerMin = random(minMin, minMax);\n const finalLength = random(Math.max(innerMin, maxMin), maxMax);\n return generator(finalLength);\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,8BAA8B,CAC1C,SAAgC,EAChC,MAAc,EACd,MAAc,EACd,MAAc,EACd,MAAc,EAAA;AAEd,IAAA,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,GAAW,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG;IAC9F,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;AACvC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;AAC9D,IAAA,OAAO,SAAS,CAAC,WAAW,CAAC;AACjC;;;;"}
package/dist/string.cjs CHANGED
@@ -17,6 +17,7 @@ const CHARSETS = {
17
17
  *
18
18
  * @param {number} length - The length of the string to generate. Must be a positive integer.
19
19
  * @param {RandomStringMode} [mode] - The character set to use.
20
+ *
20
21
  * @returns {string} The generated random string.
21
22
  *
22
23
  * @throws {Error} If the length is not a positive integer or the mode is unsupported.
@@ -1 +1 @@
1
- {"version":3,"file":"string.cjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer.\n * @param {RandomStringMode} [mode] - The character set to use.\n * @returns {string} The generated random string.\n *\n * @throws {Error} If the length is not a positive integer or the mode is unsupported.\n *\n * @example\n * ```typescript\n * import { randomString } from '@kikiutils/shared/string';\n *\n * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)\n * console.log(randomString(6, 'numeric')); // e.g. '402398'\n * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'\n * ```\n */\nexport function randomString(length: number, mode: RandomStringMode = 'alphabetic') {\n if (!Number.isInteger(length) || length <= 0) {\n throw new Error(`Invalid length: ${length}. Must be a positive integer.`);\n }\n\n const charset = CHARSETS[mode];\n if (!charset) throw new Error(`Unsupported mode: ${mode}`);\n return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');\n}\n"],"names":[],"mappings":";;AASA,MAAM,MAAM,GAAG,YAAY;AAC3B,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,QAAQ,GAAqC;IAC/C,YAAY,EAAE,SAAS,GAAG,SAAS;AACnC,IAAA,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;AAC9C,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;AACvC,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;CAC1C;AAED;;;;;;;;;;;;;;;;;AAiBG;SACa,YAAY,CAAC,MAAc,EAAE,OAAyB,YAAY,EAAA;AAC9E,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAA,6BAAA,CAA+B,CAAC;;AAG7E,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC9B,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAA,CAAE,CAAC;AAC1D,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACrG;;;;"}
1
+ {"version":3,"file":"string.cjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer.\n * @param {RandomStringMode} [mode] - The character set to use.\n *\n * @returns {string} The generated random string.\n *\n * @throws {Error} If the length is not a positive integer or the mode is unsupported.\n *\n * @example\n * ```typescript\n * import { randomString } from '@kikiutils/shared/string';\n *\n * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)\n * console.log(randomString(6, 'numeric')); // e.g. '402398'\n * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'\n * ```\n */\nexport function randomString(length: number, mode: RandomStringMode = 'alphabetic') {\n if (!Number.isInteger(length) || length <= 0) {\n throw new Error(`Invalid length: ${length}. Must be a positive integer.`);\n }\n\n const charset = CHARSETS[mode];\n if (!charset) throw new Error(`Unsupported mode: ${mode}`);\n return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');\n}\n"],"names":[],"mappings":";;AASA,MAAM,MAAM,GAAG,YAAY;AAC3B,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,QAAQ,GAAqC;IAC/C,YAAY,EAAE,SAAS,GAAG,SAAS;AACnC,IAAA,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;AAC9C,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;AACvC,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;CAC1C;AAED;;;;;;;;;;;;;;;;;;AAkBG;SACa,YAAY,CAAC,MAAc,EAAE,OAAyB,YAAY,EAAA;AAC9E,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAA,6BAAA,CAA+B,CAAC;;AAG7E,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC9B,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAA,CAAE,CAAC;AAC1D,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACrG;;;;"}
package/dist/string.d.ts CHANGED
@@ -4,6 +4,7 @@ export type RandomStringMode = 'alphabetic' | 'alphanumeric' | 'lowercase' | 'lo
4
4
  *
5
5
  * @param {number} length - The length of the string to generate. Must be a positive integer.
6
6
  * @param {RandomStringMode} [mode] - The character set to use.
7
+ *
7
8
  * @returns {string} The generated random string.
8
9
  *
9
10
  * @throws {Error} If the length is not a positive integer or the mode is unsupported.
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,cAAc,GACd,WAAW,GACX,mBAAmB,GACnB,SAAS,GACT,WAAW,GACX,mBAAmB,CAAC;AAexB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,gBAA+B,UAQjF"}
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,cAAc,GACd,WAAW,GACX,mBAAmB,GACnB,SAAS,GACT,WAAW,GACX,mBAAmB,CAAC;AAexB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,gBAA+B,UAQjF"}
package/dist/string.mjs CHANGED
@@ -15,6 +15,7 @@ const CHARSETS = {
15
15
  *
16
16
  * @param {number} length - The length of the string to generate. Must be a positive integer.
17
17
  * @param {RandomStringMode} [mode] - The character set to use.
18
+ *
18
19
  * @returns {string} The generated random string.
19
20
  *
20
21
  * @throws {Error} If the length is not a positive integer or the mode is unsupported.
@@ -1 +1 @@
1
- {"version":3,"file":"string.mjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer.\n * @param {RandomStringMode} [mode] - The character set to use.\n * @returns {string} The generated random string.\n *\n * @throws {Error} If the length is not a positive integer or the mode is unsupported.\n *\n * @example\n * ```typescript\n * import { randomString } from '@kikiutils/shared/string';\n *\n * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)\n * console.log(randomString(6, 'numeric')); // e.g. '402398'\n * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'\n * ```\n */\nexport function randomString(length: number, mode: RandomStringMode = 'alphabetic') {\n if (!Number.isInteger(length) || length <= 0) {\n throw new Error(`Invalid length: ${length}. Must be a positive integer.`);\n }\n\n const charset = CHARSETS[mode];\n if (!charset) throw new Error(`Unsupported mode: ${mode}`);\n return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');\n}\n"],"names":[],"mappings":"AASA,MAAM,MAAM,GAAG,YAAY;AAC3B,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,QAAQ,GAAqC;IAC/C,YAAY,EAAE,SAAS,GAAG,SAAS;AACnC,IAAA,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;AAC9C,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;AACvC,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;CAC1C;AAED;;;;;;;;;;;;;;;;;AAiBG;SACa,YAAY,CAAC,MAAc,EAAE,OAAyB,YAAY,EAAA;AAC9E,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAA,6BAAA,CAA+B,CAAC;;AAG7E,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC9B,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAA,CAAE,CAAC;AAC1D,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACrG;;;;"}
1
+ {"version":3,"file":"string.mjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer.\n * @param {RandomStringMode} [mode] - The character set to use.\n *\n * @returns {string} The generated random string.\n *\n * @throws {Error} If the length is not a positive integer or the mode is unsupported.\n *\n * @example\n * ```typescript\n * import { randomString } from '@kikiutils/shared/string';\n *\n * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)\n * console.log(randomString(6, 'numeric')); // e.g. '402398'\n * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'\n * ```\n */\nexport function randomString(length: number, mode: RandomStringMode = 'alphabetic') {\n if (!Number.isInteger(length) || length <= 0) {\n throw new Error(`Invalid length: ${length}. Must be a positive integer.`);\n }\n\n const charset = CHARSETS[mode];\n if (!charset) throw new Error(`Unsupported mode: ${mode}`);\n return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');\n}\n"],"names":[],"mappings":"AASA,MAAM,MAAM,GAAG,YAAY;AAC3B,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,QAAQ,GAAqC;IAC/C,YAAY,EAAE,SAAS,GAAG,SAAS;AACnC,IAAA,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;AAC9C,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;AACvC,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;CAC1C;AAED;;;;;;;;;;;;;;;;;;AAkBG;SACa,YAAY,CAAC,MAAc,EAAE,OAAyB,YAAY,EAAA;AAC9E,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAA,6BAAA,CAA+B,CAAC;;AAG7E,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC9B,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAA,CAAE,CAAC;AAC1D,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACrG;;;;"}
package/dist/url.cjs ADDED
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Appends or updates the `redirect` query parameter on a given URL.
5
+ *
6
+ * Typically used to preserve the user's current path for post-login navigation.
7
+ *
8
+ * @param {string} url - The target URL to modify.
9
+ * @param {string} redirectPath - The path to use as the redirect destination.
10
+ *
11
+ * @returns {string} A new URL string with the `redirect` query parameter.
12
+ */
13
+ function appendRedirectParamToUrl(url, redirectPath) {
14
+ const [base, rawQuery = ''] = url.split('?');
15
+ const searchParams = new URLSearchParams(rawQuery);
16
+ searchParams.set('redirect', redirectPath);
17
+ return `${base}?${searchParams.toString()}`;
18
+ }
19
+
20
+ exports.appendRedirectParamToUrl = appendRedirectParamToUrl;
21
+ //# sourceMappingURL=url.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.cjs","sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param {string} url - The target URL to modify.\n * @param {string} redirectPath - The path to use as the redirect destination.\n *\n * @returns {string} A new URL string with the `redirect` query parameter.\n */\nexport function appendRedirectParamToUrl(url: string, redirectPath: string) {\n const [base, rawQuery = ''] = url.split('?');\n const searchParams = new URLSearchParams(rawQuery);\n searchParams.set('redirect', redirectPath);\n return `${base}?${searchParams.toString()}`;\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;AASG;AACa,SAAA,wBAAwB,CAAC,GAAW,EAAE,YAAoB,EAAA;AACtE,IAAA,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,IAAA,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC;AAClD,IAAA,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1C,OAAO,CAAA,EAAG,IAAI,CAAI,CAAA,EAAA,YAAY,CAAC,QAAQ,EAAE,EAAE;AAC/C;;;;"}
package/dist/url.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Appends or updates the `redirect` query parameter on a given URL.
3
+ *
4
+ * Typically used to preserve the user's current path for post-login navigation.
5
+ *
6
+ * @param {string} url - The target URL to modify.
7
+ * @param {string} redirectPath - The path to use as the redirect destination.
8
+ *
9
+ * @returns {string} A new URL string with the `redirect` query parameter.
10
+ */
11
+ export declare function appendRedirectParamToUrl(url: string, redirectPath: string): string;
12
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAKzE"}