@@ -576,10 +576,13 @@ class AbortException extends BaseException {
576
576
}
577
577
578
578
function bytesToString ( bytes ) {
579
- assert (
580
- bytes !== null && typeof bytes === "object" && bytes . length !== undefined ,
581
- "Invalid argument for bytesToString"
582
- ) ;
579
+ if (
580
+ typeof bytes !== "object" ||
581
+ bytes === null ||
582
+ bytes . length === undefined
583
+ ) {
584
+ unreachable ( "Invalid argument for bytesToString" ) ;
585
+ }
583
586
const length = bytes . length ;
584
587
const MAX_ARGUMENT_COUNT = 8192 ;
585
588
if ( length < MAX_ARGUMENT_COUNT ) {
@@ -595,7 +598,9 @@ function bytesToString(bytes) {
595
598
}
596
599
597
600
function stringToBytes ( str ) {
598
- assert ( typeof str === "string" , "Invalid argument for stringToBytes" ) ;
601
+ if ( typeof str !== "string" ) {
602
+ unreachable ( "Invalid argument for stringToBytes" ) ;
603
+ }
599
604
const length = str . length ;
600
605
const bytes = new Uint8Array ( length ) ;
601
606
for ( let i = 0 ; i < length ; ++ i ) {
@@ -609,12 +614,15 @@ function stringToBytes(str) {
609
614
* @param {Array<any>|Uint8Array|string } arr
610
615
* @returns {number }
611
616
*/
617
+ // eslint-disable-next-line consistent-return
612
618
function arrayByteLength ( arr ) {
613
619
if ( arr . length !== undefined ) {
614
620
return arr . length ;
615
621
}
616
- assert ( arr . byteLength !== undefined , "arrayByteLength - invalid argument." ) ;
617
- return arr . byteLength ;
622
+ if ( arr . byteLength !== undefined ) {
623
+ return arr . byteLength ;
624
+ }
625
+ unreachable ( "Invalid argument for arrayByteLength" ) ;
618
626
}
619
627
620
628
/**
0 commit comments