|
1 | 1 | //inspired by oslo implementation by pilcrowonpaper: https://github.com/pilcrowonpaper/oslo/blob/main/src/encoding/base32.ts |
2 | 2 |
|
3 | | -import type { TypedArray } from "./type"; |
| 3 | +import type { TypedArray, Uint8Array_ } from "./type"; |
4 | 4 |
|
5 | 5 | /** |
6 | 6 | * Returns the Base32 alphabet based on the encoding type. |
@@ -34,7 +34,7 @@ function createDecodeMap(alphabet: string): Map<string, number> { |
34 | 34 | * @returns The Base32 encoded string. |
35 | 35 | */ |
36 | 36 | function base32Encode( |
37 | | - data: Uint8Array, |
| 37 | + data: Uint8Array_, |
38 | 38 | alphabet: string, |
39 | 39 | padding: boolean, |
40 | 40 | ): string { |
@@ -69,7 +69,7 @@ function base32Encode( |
69 | 69 | * @param alphabet - The Base32 alphabet to use. |
70 | 70 | * @returns The decoded Uint8Array. |
71 | 71 | */ |
72 | | -function base32Decode(data: string, alphabet: string): Uint8Array { |
| 72 | +function base32Decode(data: string, alphabet: string): Uint8Array_ { |
73 | 73 | const decodeMap = createDecodeMap(alphabet); |
74 | 74 | const result: number[] = []; |
75 | 75 | let buffer = 0; |
@@ -120,7 +120,7 @@ export const base32 = { |
120 | 120 | * @param data - The Base32 encoded string or ArrayBuffer/TypedArray. |
121 | 121 | * @returns The decoded Uint8Array. |
122 | 122 | */ |
123 | | - decode(data: string | ArrayBuffer | TypedArray): Uint8Array { |
| 123 | + decode(data: string | ArrayBuffer | TypedArray): Uint8Array_ { |
124 | 124 | if (typeof data !== "string") { |
125 | 125 | data = new TextDecoder().decode(data); |
126 | 126 | } |
@@ -156,7 +156,7 @@ export const base32hex = { |
156 | 156 | * @param data - The Base32hex encoded string. |
157 | 157 | * @returns The decoded Uint8Array. |
158 | 158 | */ |
159 | | - decode(data: string): Uint8Array { |
| 159 | + decode(data: string): Uint8Array_ { |
160 | 160 | const alphabet = getAlphabet(true); |
161 | 161 | return base32Decode(data, alphabet); |
162 | 162 | }, |
|
0 commit comments