@tmlmobilidade/utils 20260616.2238.2 → 20260617.1318.33
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/numbers/index.d.ts
CHANGED
package/dist/numbers/index.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to convert a hexadecimal string to a uint64 string.
|
|
3
|
+
* @param hex The hexadecimal string to convert to a uint64 string.
|
|
4
|
+
* @returns The uint64 string.
|
|
5
|
+
* @example
|
|
6
|
+
* toUInt64('1234567890'); // returns '1234567890'
|
|
7
|
+
*/
|
|
8
|
+
export declare function toUInt64(hex: string): null | string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* * */
|
|
2
|
+
/**
|
|
3
|
+
* Utility function to convert a hexadecimal string to a uint64 string.
|
|
4
|
+
* @param hex The hexadecimal string to convert to a uint64 string.
|
|
5
|
+
* @returns The uint64 string.
|
|
6
|
+
* @example
|
|
7
|
+
* toUInt64('1234567890'); // returns '1234567890'
|
|
8
|
+
*/
|
|
9
|
+
export function toUInt64(hex) {
|
|
10
|
+
if (!hex)
|
|
11
|
+
return null;
|
|
12
|
+
if (typeof hex !== 'string')
|
|
13
|
+
return null;
|
|
14
|
+
if (hex.startsWith('0x'))
|
|
15
|
+
return hex;
|
|
16
|
+
return BigInt(`0x${hex}`).toString();
|
|
17
|
+
}
|