( input: string | Uint8Array_ | ArrayBuffer, output: Uint8Array_, )
| 106 | * ``` |
| 107 | */ |
| 108 | export function encodeIntoHex( |
| 109 | input: string | Uint8Array_ | ArrayBuffer, |
| 110 | output: Uint8Array_, |
| 111 | ): number { |
| 112 | if (typeof input === "string") { |
| 113 | input = new TextEncoder().encode(input) as Uint8Array_; |
| 114 | } else if (input instanceof ArrayBuffer) { |
| 115 | input = new Uint8Array(input); |
| 116 | } |
| 117 | const min = calcSizeHex((input as Uint8Array_).length); |
| 118 | if (output.length < min) { |
| 119 | throw new RangeError("Cannot encode input as hex: Output too small"); |
| 120 | } |
| 121 | output = output.subarray(0, min); |
| 122 | const i = min - (input as Uint8Array_).length; |
| 123 | output.set(input as Uint8Array_, i); |
| 124 | return encode(output, i, 0, alphabet); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * `decodeHex` takes an input source and decodes it into a |
no test coverage detected