@@ -15,3 +15,73 @@ interface ArrayConstructor {
1515 */
1616 fromAsync < T , U > ( iterableOrArrayLike : AsyncIterable < T > | Iterable < T > | ArrayLike < T > , mapFn : ( value : Awaited < T > , index : number ) => U , thisArg ?: any ) : Promise < Awaited < U > [ ] > ;
1717}
18+
19+ interface Uint8ArrayConstructor {
20+ /**
21+ * Creates a new `Uint8Array` from a base64-encoded string.
22+ * @param string The base64-encoded string.
23+ * @param options If provided, specifies the alphabet and handling of the last chunk.
24+ * @returns A new `Uint8Array` instance.
25+ * @throws {SyntaxError } If the input string contains characters outside the specified alphabet, or if the last
26+ * chunk is inconsistent with the `lastChunkHandling` option.
27+ */
28+ fromBase64 : (
29+ string : string ,
30+ options ?: {
31+ alphabet ?: "base64" | "base64url" ;
32+ lastChunkHandling ?: "loose" | "strict" | "stop-before-partial" ;
33+ } ,
34+ ) => Uint8Array ;
35+
36+ /**
37+ * Creates a new `Uint8Array` from a base16-encoded string.
38+ * @returns A new `Uint8Array` instance.
39+ */
40+ fromHex : (
41+ string : string ,
42+ ) => Uint8Array ;
43+ }
44+
45+ interface Uint8Array < TArrayBuffer extends ArrayBufferLike > {
46+ /**
47+ * Converts the `Uint8Array` to a base64-encoded string.
48+ * @param options If provided, sets the alphabet and padding behavior used.
49+ * @returns A base64-encoded string.
50+ */
51+ toBase64 : ( options ?: {
52+ alphabet ?: "base64" | "base64url" ;
53+ omitPadding ?: boolean ;
54+ } ) => string ;
55+
56+ /**
57+ * Sets the `Uint8Array` from a base64-encoded string.
58+ * @param string The base64-encoded string.
59+ * @param options If provided, specifies the alphabet and handling of the last chunk.
60+ * @returns An object containing the number of bytes read and written.
61+ * @throws {SyntaxError } If the input string contains characters outside the specified alphabet, or if the last
62+ * chunk is inconsistent with the `lastChunkHandling` option.
63+ */
64+ setFromBase64 : ( string : string , options ?: {
65+ alphabet ?: "base64" | "base64url" ;
66+ lastChunkHandling ?: "loose" | "strict" | "stop-before-partial" ;
67+ } ) => {
68+ read : number ;
69+ written : number ;
70+ } ;
71+
72+ /**
73+ * Converts the `Uint8Array` to a base16-encoded string.
74+ * @returns A base16-encoded string.
75+ */
76+ toHex : ( ) => string ;
77+
78+ /**
79+ * Sets the `Uint8Array` from a base16-encoded string.
80+ * @param string The base16-encoded string.
81+ * @returns An object containing the number of bytes read and written.
82+ */
83+ setFromHex : ( string : string ) => {
84+ read : number ;
85+ written : number ;
86+ } ;
87+ }
0 commit comments