@@ -11,7 +11,7 @@ import {InvalidArgumentsException} from './exception/invalid_arguments_exception
11
11
* @param ba2 - The second bytearray to check.
12
12
* @returns If the array are equal.
13
13
*/
14
- export function isEqual ( ba1 : Uint8Array , ba2 : Uint8Array ) : boolean {
14
+ export function isEqual ( ba1 : Uint8Array < ArrayBuffer > , ba2 : Uint8Array < ArrayBuffer > ) : boolean {
15
15
if ( ba1 . length !== ba2 . length ) {
16
16
return false ;
17
17
}
@@ -25,7 +25,7 @@ export function isEqual(ba1: Uint8Array, ba2: Uint8Array): boolean {
25
25
/**
26
26
* Returns a new array that is the result of joining the arguments.
27
27
*/
28
- export function concat ( ...var_args : Uint8Array [ ] ) : Uint8Array {
28
+ export function concat ( ...var_args : Uint8Array < ArrayBuffer > [ ] ) : Uint8Array < ArrayBuffer > {
29
29
let length = 0 ;
30
30
for ( let i = 0 ; i < arguments . length ; i ++ ) {
31
31
// eslint-disable-next-line prefer-rest-params
@@ -48,7 +48,7 @@ export function concat(...var_args: Uint8Array[]): Uint8Array {
48
48
* @returns The number as a big-endian byte array.
49
49
* @throws {@link InvalidArgumentsException }
50
50
*/
51
- export function fromNumber ( value : number ) : Uint8Array {
51
+ export function fromNumber ( value : number ) : Uint8Array < ArrayBuffer > {
52
52
if ( Number . isNaN ( value ) || value % 1 !== 0 ) {
53
53
throw new InvalidArgumentsException ( 'cannot convert non-integer value' ) ;
54
54
}
@@ -81,7 +81,7 @@ export function fromNumber(value: number): Uint8Array {
81
81
* @returns the byte array output
82
82
* @throws {@link InvalidArgumentsException }
83
83
*/
84
- export function fromHex ( hex : string ) : Uint8Array {
84
+ export function fromHex ( hex : string ) : Uint8Array < ArrayBuffer > {
85
85
if ( hex . length % 2 != 0 ) {
86
86
throw new InvalidArgumentsException (
87
87
'Hex string length must be multiple of 2' ) ;
@@ -99,7 +99,7 @@ export function fromHex(hex: string): Uint8Array {
99
99
* @param bytes - the byte array input
100
100
* @returns hex the output
101
101
*/
102
- export function toHex ( bytes : Uint8Array ) : string {
102
+ export function toHex ( bytes : Uint8Array < ArrayBuffer > ) : string {
103
103
let result = '' ;
104
104
for ( let i = 0 ; i < bytes . length ; i ++ ) {
105
105
const hexByte = bytes [ i ] . toString ( 16 ) ;
@@ -116,7 +116,7 @@ export function toHex(bytes: Uint8Array): string {
116
116
* alphabet, which does not require escaping for use in URLs.
117
117
* @returns the byte array output
118
118
*/
119
- export function fromBase64 ( encoded : string , opt_webSafe ?: boolean ) : Uint8Array {
119
+ export function fromBase64 ( encoded : string , opt_webSafe ?: boolean ) : Uint8Array < ArrayBuffer > {
120
120
if ( opt_webSafe ) {
121
121
const normalBase64 = encoded . replace ( / - / g, '+' ) . replace ( / _ / g, '/' ) ;
122
122
return fromByteString ( window . atob ( normalBase64 ) ) ;
@@ -132,7 +132,7 @@ export function fromBase64(encoded: string, opt_webSafe?: boolean): Uint8Array {
132
132
* alphabet, which does not require escaping for use in URLs.
133
133
* @returns base64 output
134
134
*/
135
- export function toBase64 ( bytes : Uint8Array , opt_webSafe ?: boolean ) : string {
135
+ export function toBase64 ( bytes : Uint8Array < ArrayBuffer > , opt_webSafe ?: boolean ) : string {
136
136
const encoded = window
137
137
. btoa (
138
138
/* padding */
@@ -151,7 +151,7 @@ export function toBase64(bytes: Uint8Array, opt_webSafe?: boolean): string {
151
151
* @param str - the input
152
152
* @returns the byte array output
153
153
*/
154
- export function fromByteString ( str : string ) : Uint8Array {
154
+ export function fromByteString ( str : string ) : Uint8Array < ArrayBuffer > {
155
155
const output = [ ] ;
156
156
let p = 0 ;
157
157
for ( let i = 0 ; i < str . length ; i ++ ) {
@@ -170,7 +170,7 @@ export function fromByteString(str: string): Uint8Array {
170
170
* characters.
171
171
* @returns Stringification of the array.
172
172
*/
173
- export function toByteString ( bytes : Uint8Array ) : string {
173
+ export function toByteString ( bytes : Uint8Array < ArrayBuffer > ) : string {
174
174
let str = '' ;
175
175
for ( let i = 0 ; i < bytes . length ; i += 1 ) {
176
176
str += String . fromCharCode ( bytes [ i ] ) ;
0 commit comments