Skip to content

Commit f4f5906

Browse files
committed
Add comment to hex encoding util
1 parent 60a476f commit f4f5906

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

packages/delegation-core/src/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* Converts a numeric value to a hexadecimal string with zero-padding, without 0x prefix.
3+
*
4+
* @param options - The options for the conversion.
5+
* @param options.value - The numeric value to convert to hex (bigint or number).
6+
* @param options.size - The size in bytes for the resulting hex string (each byte = 2 hex characters).
7+
* @returns A hexadecimal string prefixed with zeros to match the specified size.
8+
* @example
9+
* ```typescript
10+
* toHexString({ value: 255, size: 2 }) // Returns "00ff"
11+
* toHexString({ value: 16n, size: 1 }) // Returns "10"
12+
* ```
13+
*/
114
export const toHexString = ({
215
value,
316
size,

0 commit comments

Comments
 (0)