@kikiutils/shared 10.3.0 → 10.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buffer.cjs +43 -0
- package/dist/buffer.cjs.map +1 -0
- package/dist/buffer.d.ts +35 -0
- package/dist/buffer.d.ts.map +1 -0
- package/dist/buffer.mjs +41 -0
- package/dist/buffer.mjs.map +1 -0
- package/dist/clipboard.cjs +4 -4
- package/dist/clipboard.cjs.map +1 -1
- package/dist/clipboard.d.ts +3 -3
- package/dist/clipboard.mjs +4 -4
- package/dist/clipboard.mjs.map +1 -1
- package/dist/datetime.cjs +13 -13
- package/dist/datetime.cjs.map +1 -1
- package/dist/datetime.d.ts +12 -12
- package/dist/datetime.mjs +13 -13
- package/dist/datetime.mjs.map +1 -1
- package/dist/element-plus.cjs +6 -6
- package/dist/element-plus.cjs.map +1 -1
- package/dist/element-plus.d.ts +6 -6
- package/dist/element-plus.mjs +6 -6
- package/dist/element-plus.mjs.map +1 -1
- package/dist/enum.cjs +12 -12
- package/dist/enum.cjs.map +1 -1
- package/dist/enum.d.ts +12 -12
- package/dist/enum.mjs +12 -12
- package/dist/enum.mjs.map +1 -1
- package/dist/env.cjs +4 -4
- package/dist/env.cjs.map +1 -1
- package/dist/env.d.ts +4 -4
- package/dist/env.mjs +4 -4
- package/dist/env.mjs.map +1 -1
- package/dist/general.cjs.map +1 -1
- package/dist/general.d.ts +5 -5
- package/dist/general.mjs.map +1 -1
- package/dist/math.cjs +4 -4
- package/dist/math.cjs.map +1 -1
- package/dist/math.d.ts +4 -4
- package/dist/math.mjs +4 -4
- package/dist/math.mjs.map +1 -1
- package/dist/number.cjs +3 -3
- package/dist/number.cjs.map +1 -1
- package/dist/number.d.ts +3 -3
- package/dist/number.mjs +3 -3
- package/dist/number.mjs.map +1 -1
- package/dist/object.cjs +4 -4
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.ts +4 -4
- package/dist/object.mjs +4 -4
- package/dist/object.mjs.map +1 -1
- package/dist/random.cjs +7 -7
- package/dist/random.cjs.map +1 -1
- package/dist/random.d.ts +7 -7
- package/dist/random.mjs +7 -7
- package/dist/random.mjs.map +1 -1
- package/dist/storage/enhanced/local/core.cjs +11 -11
- package/dist/storage/enhanced/local/core.cjs.map +1 -1
- package/dist/storage/enhanced/local/core.d.ts +9 -9
- package/dist/storage/enhanced/local/core.mjs +11 -11
- package/dist/storage/enhanced/local/core.mjs.map +1 -1
- package/dist/storage/enhanced/local/keyed-store.cjs +3 -3
- package/dist/storage/enhanced/local/keyed-store.cjs.map +1 -1
- package/dist/storage/enhanced/local/keyed-store.d.ts +3 -3
- package/dist/storage/enhanced/local/keyed-store.mjs +3 -3
- package/dist/storage/enhanced/local/keyed-store.mjs.map +1 -1
- package/dist/storage/enhanced/redis/core.cjs +18 -18
- package/dist/storage/enhanced/redis/core.cjs.map +1 -1
- package/dist/storage/enhanced/redis/core.d.ts +16 -16
- package/dist/storage/enhanced/redis/core.mjs +18 -18
- package/dist/storage/enhanced/redis/core.mjs.map +1 -1
- package/dist/storage/enhanced/redis/keyed-store.cjs +4 -4
- package/dist/storage/enhanced/redis/keyed-store.cjs.map +1 -1
- package/dist/storage/enhanced/redis/keyed-store.d.ts +4 -4
- package/dist/storage/enhanced/redis/keyed-store.mjs +4 -4
- package/dist/storage/enhanced/redis/keyed-store.mjs.map +1 -1
- package/dist/storage/lru/keyed-store.cjs +3 -3
- package/dist/storage/lru/keyed-store.cjs.map +1 -1
- package/dist/storage/lru/keyed-store.d.ts +3 -3
- package/dist/storage/lru/keyed-store.mjs +3 -3
- package/dist/storage/lru/keyed-store.mjs.map +1 -1
- package/dist/string.cjs +5 -5
- package/dist/string.cjs.map +1 -1
- package/dist/string.d.ts +4 -4
- package/dist/string.mjs +5 -5
- package/dist/string.mjs.map +1 -1
- package/dist/url.cjs +3 -3
- package/dist/url.cjs.map +1 -1
- package/dist/url.d.ts +3 -3
- package/dist/url.mjs +3 -3
- package/dist/url.mjs.map +1 -1
- package/dist/vue.cjs +6 -6
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.ts +6 -6
- package/dist/vue.mjs +6 -6
- package/dist/vue.mjs.map +1 -1
- package/dist/web.cjs +4 -4
- package/dist/web.cjs.map +1 -1
- package/dist/web.d.ts +4 -4
- package/dist/web.mjs +4 -4
- package/dist/web.mjs.map +1 -1
- package/package.json +2 -2
- package/src/buffer.ts +41 -0
- package/src/clipboard.ts +4 -4
- package/src/datetime.ts +13 -13
- package/src/element-plus.ts +6 -6
- package/src/enum.ts +12 -12
- package/src/env.ts +4 -4
- package/src/general.ts +5 -5
- package/src/math.ts +4 -4
- package/src/number.ts +3 -3
- package/src/object.ts +4 -4
- package/src/random.ts +7 -7
- package/src/storage/enhanced/local/core.ts +11 -11
- package/src/storage/enhanced/local/keyed-store.ts +3 -3
- package/src/storage/enhanced/redis/core.ts +18 -18
- package/src/storage/enhanced/redis/keyed-store.ts +4 -4
- package/src/storage/lru/keyed-store.ts +3 -3
- package/src/string.ts +5 -5
- package/src/url.ts +3 -3
- package/src/vue.ts +6 -6
- package/src/web.ts +4 -4
package/dist/enum.cjs
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Extracts only the numeric values from an enumeration-like object.
|
|
5
5
|
*
|
|
6
|
-
* @template T - The type of the enum object
|
|
6
|
+
* @template T - The type of the enum object
|
|
7
7
|
*
|
|
8
|
-
* @param {T} enumObject - The enumeration-like object to extract numeric values from
|
|
9
|
-
*
|
|
8
|
+
* @param {T} enumObject - The enumeration-like object to extract numeric values from,
|
|
9
|
+
* the object can contain numeric values, string values, or both.
|
|
10
10
|
*
|
|
11
|
-
* @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object
|
|
11
|
+
* @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
@@ -29,12 +29,12 @@ function getEnumNumberValues(enumObject) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Extracts only the string values from an enumeration-like object.
|
|
31
31
|
*
|
|
32
|
-
* @template T - The type of the enum object
|
|
32
|
+
* @template T - The type of the enum object
|
|
33
33
|
*
|
|
34
|
-
* @param {T} enumObject - The enumeration-like object to extract string values from
|
|
35
|
-
*
|
|
34
|
+
* @param {T} enumObject - The enumeration-like object to extract string values from,
|
|
35
|
+
* the object can contain numeric values, string values, or both.
|
|
36
36
|
*
|
|
37
|
-
* @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object
|
|
37
|
+
* @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* ```typescript
|
|
@@ -59,12 +59,12 @@ function getEnumStringValues(enumObject) {
|
|
|
59
59
|
* that occurs with numeric enums. It works with pure numeric enums, pure string enums,
|
|
60
60
|
* and mixed enums.
|
|
61
61
|
*
|
|
62
|
-
* @template T - The type of the enum object
|
|
62
|
+
* @template T - The type of the enum object
|
|
63
63
|
*
|
|
64
|
-
* @param {T} enumObject - The enumeration-like object to extract values from
|
|
65
|
-
*
|
|
64
|
+
* @param {T} enumObject - The enumeration-like object to extract values from,
|
|
65
|
+
* the object can contain numeric values, string values, or both.
|
|
66
66
|
*
|
|
67
|
-
* @returns {(T[keyof T])[]} An array containing all the values from the enum object
|
|
67
|
+
* @returns {(T[keyof T])[]} An array containing all the values from the enum object
|
|
68
68
|
*
|
|
69
69
|
* @example
|
|
70
70
|
* ```typescript
|
package/dist/enum.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.cjs","sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts only the numeric values from an enumeration-like object.\n *\n * @template T - The type of the enum object
|
|
1
|
+
{"version":3,"file":"enum.cjs","sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts only the numeric values from an enumeration-like object.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract numeric values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum 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<T extends Record<string, any>>(enumObject: T): Extract<T[keyof T], number>[] {\n return getEnumValues(enumObject).filter((value) => typeof value === 'number');\n}\n\n/**\n * Extracts only the string values from an enumeration-like object.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract string values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum 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<T extends Record<string, any>>(enumObject: T): Extract<T[keyof T], string>[] {\n return getEnumValues(enumObject).filter((value) => typeof value === 'string');\n}\n\n/**\n * Extracts all values from an enumeration-like object.\n *\n * This function handles TypeScript enums correctly by accounting for the reverse mapping\n * that occurs with numeric enums. It works with pure numeric enums, pure string enums,\n * and mixed enums.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {(T[keyof T])[]} An array containing all the values from the enum object\n *\n * @example\n * ```typescript\n * import { getEnumValues } from '@kikiutils/shared/enum';\n *\n * // Numeric enum\n * enum Status {\n * Active = 0,\n * Inactive = 1,\n * Pending = 2\n * }\n *\n * console.log(getEnumValues(Status)); // [0, 1, 2]\n *\n * // String enum\n * enum Color {\n * Red = 'RED',\n * Green = 'GREEN',\n * Blue = 'BLUE'\n * }\n *\n * console.log(getEnumValues(Color)); // ['RED', 'GREEN', 'BLUE']\n *\n * // Mixed enum\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumValues(RecordType)); // [0, 1, 'unknown']\n * ```\n */\nexport function getEnumValues<T extends Record<string, any>>(enumObject: T): (T[keyof T])[] {\n const values = Object.values(enumObject);\n const hasNumberValues = values.some((value) => typeof value === 'number');\n if (!hasNumberValues) return values;\n return Object.keys(enumObject).filter((key) => Number.isNaN(Number(key))).map((key) => enumObject[key]);\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,mBAAmB,CAAgC,UAAa,EAAA;AAC5E,IAAA,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AACjF;AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,mBAAmB,CAAgC,UAAa,EAAA;AAC5E,IAAA,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AACjF;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CG;AACG,SAAU,aAAa,CAAgC,UAAa,EAAA;IACtE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;AACxC,IAAA,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AACzE,IAAA,IAAI,CAAC,eAAe;AAAE,QAAA,OAAO,MAAM;AACnC,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,UAAU,CAAC,GAAG,CAAC,CAAC;AAC3G;;;;;;"}
|
package/dist/enum.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Extracts only the numeric values from an enumeration-like object.
|
|
3
3
|
*
|
|
4
|
-
* @template T - The type of the enum object
|
|
4
|
+
* @template T - The type of the enum object
|
|
5
5
|
*
|
|
6
|
-
* @param {T} enumObject - The enumeration-like object to extract numeric values from
|
|
7
|
-
*
|
|
6
|
+
* @param {T} enumObject - The enumeration-like object to extract numeric values from,
|
|
7
|
+
* the object can contain numeric values, string values, or both.
|
|
8
8
|
*
|
|
9
|
-
* @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object
|
|
9
|
+
* @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
@@ -25,12 +25,12 @@ export declare function getEnumNumberValues<T extends Record<string, any>>(enumO
|
|
|
25
25
|
/**
|
|
26
26
|
* Extracts only the string values from an enumeration-like object.
|
|
27
27
|
*
|
|
28
|
-
* @template T - The type of the enum object
|
|
28
|
+
* @template T - The type of the enum object
|
|
29
29
|
*
|
|
30
|
-
* @param {T} enumObject - The enumeration-like object to extract string values from
|
|
31
|
-
*
|
|
30
|
+
* @param {T} enumObject - The enumeration-like object to extract string values from,
|
|
31
|
+
* the object can contain numeric values, string values, or both.
|
|
32
32
|
*
|
|
33
|
-
* @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object
|
|
33
|
+
* @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
36
|
* ```typescript
|
|
@@ -53,12 +53,12 @@ export declare function getEnumStringValues<T extends Record<string, any>>(enumO
|
|
|
53
53
|
* that occurs with numeric enums. It works with pure numeric enums, pure string enums,
|
|
54
54
|
* and mixed enums.
|
|
55
55
|
*
|
|
56
|
-
* @template T - The type of the enum object
|
|
56
|
+
* @template T - The type of the enum object
|
|
57
57
|
*
|
|
58
|
-
* @param {T} enumObject - The enumeration-like object to extract values from
|
|
59
|
-
*
|
|
58
|
+
* @param {T} enumObject - The enumeration-like object to extract values from,
|
|
59
|
+
* the object can contain numeric values, string values, or both.
|
|
60
60
|
*
|
|
61
|
-
* @returns {(T[keyof T])[]} An array containing all the values from the enum object
|
|
61
|
+
* @returns {(T[keyof T])[]} An array containing all the values from the enum object
|
|
62
62
|
*
|
|
63
63
|
* @example
|
|
64
64
|
* ```typescript
|
package/dist/enum.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Extracts only the numeric values from an enumeration-like object.
|
|
3
3
|
*
|
|
4
|
-
* @template T - The type of the enum object
|
|
4
|
+
* @template T - The type of the enum object
|
|
5
5
|
*
|
|
6
|
-
* @param {T} enumObject - The enumeration-like object to extract numeric values from
|
|
7
|
-
*
|
|
6
|
+
* @param {T} enumObject - The enumeration-like object to extract numeric values from,
|
|
7
|
+
* the object can contain numeric values, string values, or both.
|
|
8
8
|
*
|
|
9
|
-
* @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object
|
|
9
|
+
* @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
@@ -27,12 +27,12 @@ function getEnumNumberValues(enumObject) {
|
|
|
27
27
|
/**
|
|
28
28
|
* Extracts only the string values from an enumeration-like object.
|
|
29
29
|
*
|
|
30
|
-
* @template T - The type of the enum object
|
|
30
|
+
* @template T - The type of the enum object
|
|
31
31
|
*
|
|
32
|
-
* @param {T} enumObject - The enumeration-like object to extract string values from
|
|
33
|
-
*
|
|
32
|
+
* @param {T} enumObject - The enumeration-like object to extract string values from,
|
|
33
|
+
* the object can contain numeric values, string values, or both.
|
|
34
34
|
*
|
|
35
|
-
* @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object
|
|
35
|
+
* @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
38
|
* ```typescript
|
|
@@ -57,12 +57,12 @@ function getEnumStringValues(enumObject) {
|
|
|
57
57
|
* that occurs with numeric enums. It works with pure numeric enums, pure string enums,
|
|
58
58
|
* and mixed enums.
|
|
59
59
|
*
|
|
60
|
-
* @template T - The type of the enum object
|
|
60
|
+
* @template T - The type of the enum object
|
|
61
61
|
*
|
|
62
|
-
* @param {T} enumObject - The enumeration-like object to extract values from
|
|
63
|
-
*
|
|
62
|
+
* @param {T} enumObject - The enumeration-like object to extract values from,
|
|
63
|
+
* the object can contain numeric values, string values, or both.
|
|
64
64
|
*
|
|
65
|
-
* @returns {(T[keyof T])[]} An array containing all the values from the enum object
|
|
65
|
+
* @returns {(T[keyof T])[]} An array containing all the values from the enum object
|
|
66
66
|
*
|
|
67
67
|
* @example
|
|
68
68
|
* ```typescript
|
package/dist/enum.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.mjs","sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts only the numeric values from an enumeration-like object.\n *\n * @template T - The type of the enum object
|
|
1
|
+
{"version":3,"file":"enum.mjs","sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts only the numeric values from an enumeration-like object.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract numeric values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum 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<T extends Record<string, any>>(enumObject: T): Extract<T[keyof T], number>[] {\n return getEnumValues(enumObject).filter((value) => typeof value === 'number');\n}\n\n/**\n * Extracts only the string values from an enumeration-like object.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract string values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum 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<T extends Record<string, any>>(enumObject: T): Extract<T[keyof T], string>[] {\n return getEnumValues(enumObject).filter((value) => typeof value === 'string');\n}\n\n/**\n * Extracts all values from an enumeration-like object.\n *\n * This function handles TypeScript enums correctly by accounting for the reverse mapping\n * that occurs with numeric enums. It works with pure numeric enums, pure string enums,\n * and mixed enums.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {(T[keyof T])[]} An array containing all the values from the enum object\n *\n * @example\n * ```typescript\n * import { getEnumValues } from '@kikiutils/shared/enum';\n *\n * // Numeric enum\n * enum Status {\n * Active = 0,\n * Inactive = 1,\n * Pending = 2\n * }\n *\n * console.log(getEnumValues(Status)); // [0, 1, 2]\n *\n * // String enum\n * enum Color {\n * Red = 'RED',\n * Green = 'GREEN',\n * Blue = 'BLUE'\n * }\n *\n * console.log(getEnumValues(Color)); // ['RED', 'GREEN', 'BLUE']\n *\n * // Mixed enum\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumValues(RecordType)); // [0, 1, 'unknown']\n * ```\n */\nexport function getEnumValues<T extends Record<string, any>>(enumObject: T): (T[keyof T])[] {\n const values = Object.values(enumObject);\n const hasNumberValues = values.some((value) => typeof value === 'number');\n if (!hasNumberValues) return values;\n return Object.keys(enumObject).filter((key) => Number.isNaN(Number(key))).map((key) => enumObject[key]);\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,mBAAmB,CAAgC,UAAa,EAAA;AAC5E,IAAA,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AACjF;AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,mBAAmB,CAAgC,UAAa,EAAA;AAC5E,IAAA,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AACjF;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CG;AACG,SAAU,aAAa,CAAgC,UAAa,EAAA;IACtE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;AACxC,IAAA,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,QAAQ,CAAC;AACzE,IAAA,IAAI,CAAC,eAAe;AAAE,QAAA,OAAO,MAAM;AACnC,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,UAAU,CAAC,GAAG,CAAC,CAAC;AAC3G;;;;"}
|
package/dist/env.cjs
CHANGED
|
@@ -12,7 +12,7 @@ class EnvironmentNotFoundError extends Error {
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new EnvironmentNotFoundError.
|
|
14
14
|
*
|
|
15
|
-
* @param {string} key - The missing environment variable key
|
|
15
|
+
* @param {string} key - The missing environment variable key
|
|
16
16
|
*/
|
|
17
17
|
constructor(key) {
|
|
18
18
|
super(`Missing environment variable: ${key}`);
|
|
@@ -27,11 +27,11 @@ class EnvironmentNotFoundError extends Error {
|
|
|
27
27
|
* Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
|
|
28
28
|
* value like `'0'` or `'false'` is considered a valid (defined) value.
|
|
29
29
|
*
|
|
30
|
-
* @param {string} key - The environment variable key to retrieve
|
|
30
|
+
* @param {string} key - The environment variable key to retrieve
|
|
31
31
|
*
|
|
32
|
-
* @returns {string} The value of the environment variable
|
|
32
|
+
* @returns {string} The value of the environment variable
|
|
33
33
|
*
|
|
34
|
-
* @throws {EnvironmentNotFoundError} If the environment variable is not defined
|
|
34
|
+
* @throws {EnvironmentNotFoundError} If the environment variable is not defined
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* ```typescript
|
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
|
|
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 it is not defined.\n *\n * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string\n * value like `'0'` or `'false'` is considered a valid (defined) value.\n *\n * @param {string} key - The environment variable key to retrieve\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 * process.env.API_KEY = '';\n * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered \"defined\")\n *\n * delete process.env.API_KEY;\n * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (process.env[key] === undefined) 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;IACrD;AACH;AAED;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC3E,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;;"}
|
package/dist/env.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class EnvironmentNotFoundError extends Error {
|
|
|
10
10
|
/**
|
|
11
11
|
* Creates a new EnvironmentNotFoundError.
|
|
12
12
|
*
|
|
13
|
-
* @param {string} key - The missing environment variable key
|
|
13
|
+
* @param {string} key - The missing environment variable key
|
|
14
14
|
*/
|
|
15
15
|
constructor(key: string);
|
|
16
16
|
}
|
|
@@ -20,11 +20,11 @@ export declare class EnvironmentNotFoundError extends Error {
|
|
|
20
20
|
* Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
|
|
21
21
|
* value like `'0'` or `'false'` is considered a valid (defined) value.
|
|
22
22
|
*
|
|
23
|
-
* @param {string} key - The environment variable key to retrieve
|
|
23
|
+
* @param {string} key - The environment variable key to retrieve
|
|
24
24
|
*
|
|
25
|
-
* @returns {string} The value of the environment variable
|
|
25
|
+
* @returns {string} The value of the environment variable
|
|
26
26
|
*
|
|
27
|
-
* @throws {EnvironmentNotFoundError} If the environment variable is not defined
|
|
27
|
+
* @throws {EnvironmentNotFoundError} If the environment variable is not defined
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
30
|
* ```typescript
|
package/dist/env.mjs
CHANGED
|
@@ -10,7 +10,7 @@ class EnvironmentNotFoundError extends Error {
|
|
|
10
10
|
/**
|
|
11
11
|
* Creates a new EnvironmentNotFoundError.
|
|
12
12
|
*
|
|
13
|
-
* @param {string} key - The missing environment variable key
|
|
13
|
+
* @param {string} key - The missing environment variable key
|
|
14
14
|
*/
|
|
15
15
|
constructor(key) {
|
|
16
16
|
super(`Missing environment variable: ${key}`);
|
|
@@ -25,11 +25,11 @@ class EnvironmentNotFoundError extends Error {
|
|
|
25
25
|
* Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
|
|
26
26
|
* value like `'0'` or `'false'` is considered a valid (defined) value.
|
|
27
27
|
*
|
|
28
|
-
* @param {string} key - The environment variable key to retrieve
|
|
28
|
+
* @param {string} key - The environment variable key to retrieve
|
|
29
29
|
*
|
|
30
|
-
* @returns {string} The value of the environment variable
|
|
30
|
+
* @returns {string} The value of the environment variable
|
|
31
31
|
*
|
|
32
|
-
* @throws {EnvironmentNotFoundError} If the environment variable is not defined
|
|
32
|
+
* @throws {EnvironmentNotFoundError} If the environment variable is not defined
|
|
33
33
|
*
|
|
34
34
|
* @example
|
|
35
35
|
* ```typescript
|
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
|
|
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 it is not defined.\n *\n * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string\n * value like `'0'` or `'false'` is considered a valid (defined) value.\n *\n * @param {string} key - The environment variable key to retrieve\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 * process.env.API_KEY = '';\n * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered \"defined\")\n *\n * delete process.env.API_KEY;\n * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (process.env[key] === undefined) 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;IACrD;AACH;AAED;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC3E,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;"}
|
package/dist/general.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.cjs","sources":["../src/general.ts"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n\n/**\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)
|
|
1
|
+
{"version":3,"file":"general.cjs","sources":["../src/general.ts"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n\n/**\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\n/* eslint-enable jsdoc/check-param-names */\n"],"names":[],"mappings":";;AAAA;AA6BM,SAAU,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;AAEA;;;;"}
|
package/dist/general.d.ts
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* - If `value` is not an array, returns `value` directly.
|
|
6
6
|
* - If the result is `null` or `undefined`, and `defaultValue` is provided, returns `defaultValue` instead.
|
|
7
7
|
*
|
|
8
|
-
* @template T - The type of the input value(s)
|
|
9
|
-
* @template D - The type of the default value (if provided)
|
|
8
|
+
* @template T - The type of the input value(s)
|
|
9
|
+
* @template D - The type of the default value (if provided)
|
|
10
10
|
*
|
|
11
|
-
* @param {T | T[]} value - A single value or an array of values
|
|
12
|
-
* @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined
|
|
11
|
+
* @param {T | T[]} value - A single value or an array of values
|
|
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
|
+
* @returns {T | D | undefined} The first value or the fallback
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
package/dist/general.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.mjs","sources":["../src/general.ts"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n\n/**\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)
|
|
1
|
+
{"version":3,"file":"general.mjs","sources":["../src/general.ts"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n\n/**\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\n/* eslint-enable jsdoc/check-param-names */\n"],"names":[],"mappings":"AAAA;AA6BM,SAAU,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;AAEA;;;;"}
|
package/dist/math.cjs
CHANGED
|
@@ -9,11 +9,11 @@ const decimal_js = require('decimal.js');
|
|
|
9
9
|
* - Supports custom decimal places and optional percentage symbol.
|
|
10
10
|
* - Returns `'0.00%'` if result is `NaN` or division is invalid.
|
|
11
11
|
*
|
|
12
|
-
* @param {CalculableValue} molecular - The numerator of the fraction
|
|
13
|
-
* @param {CalculableValue} denominator - The denominator of the fraction
|
|
14
|
-
* @param {ToPercentageStringOptions} [options] - Optional output settings
|
|
12
|
+
* @param {CalculableValue} molecular - The numerator of the fraction
|
|
13
|
+
* @param {CalculableValue} denominator - The denominator of the fraction
|
|
14
|
+
* @param {ToPercentageStringOptions} [options] - Optional output settings
|
|
15
15
|
*
|
|
16
|
-
* @returns {string} Formatted percentage string
|
|
16
|
+
* @returns {string} Formatted percentage string
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```typescript
|
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 *\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
|
|
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,CAAA,CAAA,CAAG,GAAG,MAAM;AAC9D;;;;"}
|
package/dist/math.d.ts
CHANGED
|
@@ -26,11 +26,11 @@ export interface ToPercentageStringOptions {
|
|
|
26
26
|
* - Supports custom decimal places and optional percentage symbol.
|
|
27
27
|
* - Returns `'0.00%'` if result is `NaN` or division is invalid.
|
|
28
28
|
*
|
|
29
|
-
* @param {CalculableValue} molecular - The numerator of the fraction
|
|
30
|
-
* @param {CalculableValue} denominator - The denominator of the fraction
|
|
31
|
-
* @param {ToPercentageStringOptions} [options] - Optional output settings
|
|
29
|
+
* @param {CalculableValue} molecular - The numerator of the fraction
|
|
30
|
+
* @param {CalculableValue} denominator - The denominator of the fraction
|
|
31
|
+
* @param {ToPercentageStringOptions} [options] - Optional output settings
|
|
32
32
|
*
|
|
33
|
-
* @returns {string} Formatted percentage string
|
|
33
|
+
* @returns {string} Formatted percentage string
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
36
|
* ```typescript
|
package/dist/math.mjs
CHANGED
|
@@ -7,11 +7,11 @@ import { Decimal } from 'decimal.js';
|
|
|
7
7
|
* - Supports custom decimal places and optional percentage symbol.
|
|
8
8
|
* - Returns `'0.00%'` if result is `NaN` or division is invalid.
|
|
9
9
|
*
|
|
10
|
-
* @param {CalculableValue} molecular - The numerator of the fraction
|
|
11
|
-
* @param {CalculableValue} denominator - The denominator of the fraction
|
|
12
|
-
* @param {ToPercentageStringOptions} [options] - Optional output settings
|
|
10
|
+
* @param {CalculableValue} molecular - The numerator of the fraction
|
|
11
|
+
* @param {CalculableValue} denominator - The denominator of the fraction
|
|
12
|
+
* @param {ToPercentageStringOptions} [options] - Optional output settings
|
|
13
13
|
*
|
|
14
|
-
* @returns {string} Formatted percentage string
|
|
14
|
+
* @returns {string} Formatted percentage string
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
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 *\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
|
|
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,CAAA,CAAA,CAAG,GAAG,MAAM;AAC9D;;;;"}
|
package/dist/number.cjs
CHANGED
|
@@ -7,10 +7,10 @@ const millify = require('millify');
|
|
|
7
7
|
*
|
|
8
8
|
* Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.
|
|
9
9
|
*
|
|
10
|
-
* @param {number} value - The number to format
|
|
11
|
-
* @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify
|
|
10
|
+
* @param {number} value - The number to format
|
|
11
|
+
* @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`
|
|
12
12
|
*
|
|
13
|
-
* @returns {string} The compact number string
|
|
13
|
+
* @returns {string} The compact number string
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
package/dist/number.cjs.map
CHANGED
|
@@ -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
|
|
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;AACG,SAAU,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
|
@@ -4,10 +4,10 @@ import { millify } from 'millify';
|
|
|
4
4
|
*
|
|
5
5
|
* Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.
|
|
6
6
|
*
|
|
7
|
-
* @param {number} value - The number to format
|
|
8
|
-
* @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify
|
|
7
|
+
* @param {number} value - The number to format
|
|
8
|
+
* @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`
|
|
9
9
|
*
|
|
10
|
-
* @returns {string} The compact number string
|
|
10
|
+
* @returns {string} The compact number string
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
package/dist/number.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import { millify } from 'millify';
|
|
|
5
5
|
*
|
|
6
6
|
* Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.
|
|
7
7
|
*
|
|
8
|
-
* @param {number} value - The number to format
|
|
9
|
-
* @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify
|
|
8
|
+
* @param {number} value - The number to format
|
|
9
|
+
* @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`
|
|
10
10
|
*
|
|
11
|
-
* @returns {string} The compact number string
|
|
11
|
+
* @returns {string} The compact number string
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
package/dist/number.mjs.map
CHANGED
|
@@ -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
|
|
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;AACG,SAAU,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/object.cjs
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* It is designed for use cases such as signature generation, cache key construction,
|
|
11
11
|
* or any context requiring consistent and predictable object serialization.
|
|
12
12
|
*
|
|
13
|
-
* @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
14
|
-
* @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
|
|
15
|
-
* @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
|
|
16
|
-
* @returns {string} A deterministic string representation of the input object
|
|
13
|
+
* @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
14
|
+
* @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
|
|
15
|
+
* @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
|
|
16
|
+
* @returns {string} A deterministic string representation of the input object
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```typescript
|
package/dist/object.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.cjs","sources":["../src/object.ts"],"sourcesContent":["/**\n * Serializes a nested object into a deterministic, flat string format.\n *\n * This function recursively traverses the input object (including nested objects and arrays),\n * flattens it into key paths using dot notation (e.g. \"a.b.0.c\"), sorts all keys,\n * and joins each key-value pair into a string with customizable separators.\n *\n * It is designed for use cases such as signature generation, cache key construction,\n * or any context requiring consistent and predictable object serialization.\n *\n * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
1
|
+
{"version":3,"file":"object.cjs","sources":["../src/object.ts"],"sourcesContent":["/**\n * Serializes a nested object into a deterministic, flat string format.\n *\n * This function recursively traverses the input object (including nested objects and arrays),\n * flattens it into key paths using dot notation (e.g. \"a.b.0.c\"), sorts all keys,\n * and joins each key-value pair into a string with customizable separators.\n *\n * It is designed for use cases such as signature generation, cache key construction,\n * or any context requiring consistent and predictable object serialization.\n *\n * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays\n * @param {string} kvSeparator - The string used to separate each key from its value (default: '=')\n * @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')\n * @returns {string} A deterministic string representation of the input object\n *\n * @example\n * ```typescript\n * import { stringifyObjectDeterministically } from '@kikiutils/shared/object';\n *\n * console.log(stringifyObjectDeterministically({ b: 2, a: { x: 1, y: [3, 4] } })); // a.x=1&a.y.0=3&a.y.1=4&b=2\n * console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // foo:bar\n * ```\n */\nexport function stringifyObjectDeterministically(\n input: Record<string, any>,\n kvSeparator: string = '=',\n pairSeparator: string = '&',\n) {\n const entries: string[] = [];\n\n function walk(object: any, path: string[] = []) {\n if (Array.isArray(object)) {\n object.forEach((value, index) => {\n walk(\n value,\n [\n ...path,\n index.toString(),\n ],\n );\n });\n } else if (\n object !== null\n && typeof object === 'object'\n && Object.prototype.toString.call(object) === '[object Object]'\n ) {\n Object.keys(object).sort().forEach((key) => {\n walk(\n object[key],\n [\n ...path,\n key,\n ],\n );\n });\n } else entries.push(`${path.join('.')}${kvSeparator}${String(object)}`);\n }\n\n walk(input);\n return entries.sort().join(pairSeparator);\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,gCAAgC,CAC5C,KAA0B,EAC1B,WAAA,GAAsB,GAAG,EACzB,aAAA,GAAwB,GAAG,EAAA;IAE3B,MAAM,OAAO,GAAa,EAAE;AAE5B,IAAA,SAAS,IAAI,CAAC,MAAW,EAAE,OAAiB,EAAE,EAAA;AAC1C,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAI;gBAC5B,IAAI,CACA,KAAK,EACL;AACI,oBAAA,GAAG,IAAI;oBACP,KAAK,CAAC,QAAQ,EAAE;AACnB,iBAAA,CACJ;AACL,YAAA,CAAC,CAAC;QACN;aAAO,IACH,MAAM,KAAK;eACR,OAAO,MAAM,KAAK;AAClB,eAAA,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,iBAAiB,EACjE;AACE,YAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;AACvC,gBAAA,IAAI,CACA,MAAM,CAAC,GAAG,CAAC,EACX;AACI,oBAAA,GAAG,IAAI;oBACP,GAAG;AACN,iBAAA,CACJ;AACL,YAAA,CAAC,CAAC;QACN;;AAAO,YAAA,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,EAAG,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA,CAAE,CAAC;IAC3E;IAEA,IAAI,CAAC,KAAK,CAAC;IACX,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;AAC7C;;;;"}
|
package/dist/object.d.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* It is designed for use cases such as signature generation, cache key construction,
|
|
9
9
|
* or any context requiring consistent and predictable object serialization.
|
|
10
10
|
*
|
|
11
|
-
* @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
12
|
-
* @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
|
|
13
|
-
* @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
|
|
14
|
-
* @returns {string} A deterministic string representation of the input object
|
|
11
|
+
* @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
12
|
+
* @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
|
|
13
|
+
* @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
|
|
14
|
+
* @returns {string} A deterministic string representation of the input object
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
package/dist/object.mjs
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* It is designed for use cases such as signature generation, cache key construction,
|
|
9
9
|
* or any context requiring consistent and predictable object serialization.
|
|
10
10
|
*
|
|
11
|
-
* @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
12
|
-
* @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
|
|
13
|
-
* @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
|
|
14
|
-
* @returns {string} A deterministic string representation of the input object
|
|
11
|
+
* @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
12
|
+
* @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
|
|
13
|
+
* @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
|
|
14
|
+
* @returns {string} A deterministic string representation of the input object
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
package/dist/object.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.mjs","sources":["../src/object.ts"],"sourcesContent":["/**\n * Serializes a nested object into a deterministic, flat string format.\n *\n * This function recursively traverses the input object (including nested objects and arrays),\n * flattens it into key paths using dot notation (e.g. \"a.b.0.c\"), sorts all keys,\n * and joins each key-value pair into a string with customizable separators.\n *\n * It is designed for use cases such as signature generation, cache key construction,\n * or any context requiring consistent and predictable object serialization.\n *\n * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
1
|
+
{"version":3,"file":"object.mjs","sources":["../src/object.ts"],"sourcesContent":["/**\n * Serializes a nested object into a deterministic, flat string format.\n *\n * This function recursively traverses the input object (including nested objects and arrays),\n * flattens it into key paths using dot notation (e.g. \"a.b.0.c\"), sorts all keys,\n * and joins each key-value pair into a string with customizable separators.\n *\n * It is designed for use cases such as signature generation, cache key construction,\n * or any context requiring consistent and predictable object serialization.\n *\n * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays\n * @param {string} kvSeparator - The string used to separate each key from its value (default: '=')\n * @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')\n * @returns {string} A deterministic string representation of the input object\n *\n * @example\n * ```typescript\n * import { stringifyObjectDeterministically } from '@kikiutils/shared/object';\n *\n * console.log(stringifyObjectDeterministically({ b: 2, a: { x: 1, y: [3, 4] } })); // a.x=1&a.y.0=3&a.y.1=4&b=2\n * console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // foo:bar\n * ```\n */\nexport function stringifyObjectDeterministically(\n input: Record<string, any>,\n kvSeparator: string = '=',\n pairSeparator: string = '&',\n) {\n const entries: string[] = [];\n\n function walk(object: any, path: string[] = []) {\n if (Array.isArray(object)) {\n object.forEach((value, index) => {\n walk(\n value,\n [\n ...path,\n index.toString(),\n ],\n );\n });\n } else if (\n object !== null\n && typeof object === 'object'\n && Object.prototype.toString.call(object) === '[object Object]'\n ) {\n Object.keys(object).sort().forEach((key) => {\n walk(\n object[key],\n [\n ...path,\n key,\n ],\n );\n });\n } else entries.push(`${path.join('.')}${kvSeparator}${String(object)}`);\n }\n\n walk(input);\n return entries.sort().join(pairSeparator);\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,gCAAgC,CAC5C,KAA0B,EAC1B,WAAA,GAAsB,GAAG,EACzB,aAAA,GAAwB,GAAG,EAAA;IAE3B,MAAM,OAAO,GAAa,EAAE;AAE5B,IAAA,SAAS,IAAI,CAAC,MAAW,EAAE,OAAiB,EAAE,EAAA;AAC1C,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAI;gBAC5B,IAAI,CACA,KAAK,EACL;AACI,oBAAA,GAAG,IAAI;oBACP,KAAK,CAAC,QAAQ,EAAE;AACnB,iBAAA,CACJ;AACL,YAAA,CAAC,CAAC;QACN;aAAO,IACH,MAAM,KAAK;eACR,OAAO,MAAM,KAAK;AAClB,eAAA,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,iBAAiB,EACjE;AACE,YAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;AACvC,gBAAA,IAAI,CACA,MAAM,CAAC,GAAG,CAAC,EACX;AACI,oBAAA,GAAG,IAAI;oBACP,GAAG;AACN,iBAAA,CACJ;AACL,YAAA,CAAC,CAAC;QACN;;AAAO,YAAA,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,EAAG,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA,CAAE,CAAC;IAC3E;IAEA,IAAI,CAAC,KAAK,CAAC;IACX,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;AAC7C;;;;"}
|
package/dist/random.cjs
CHANGED
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
*
|
|
11
11
|
* This function supports any return type by using a generic type parameter.
|
|
12
12
|
*
|
|
13
|
-
* @template T - The return type of the generator function
|
|
13
|
+
* @template T - The return type of the generator function
|
|
14
14
|
*
|
|
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
|
|
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
20
|
*
|
|
21
|
-
* @returns {T} The result of the generator function using the computed final length
|
|
21
|
+
* @returns {T} The result of the generator function using the computed final length
|
|
22
22
|
*/
|
|
23
23
|
function generateWithNestedRandomLength(generator, minMin, minMax, maxMin, maxMax) {
|
|
24
24
|
const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
|