@@ -23,9 +23,9 @@ export type DecoderOptions<ContextType = undefined> = Readonly<
23
23
/**
24
24
* By default, string values will be decoded as UTF-8 strings. However, if this option is true,
25
25
* string values will be returned as Uint8Arrays without additional decoding.
26
- *
26
+ *
27
27
* This is useful if the strings may contain invalid UTF-8 sequences.
28
- *
28
+ *
29
29
* Note that this option only applies to string values, not map keys. Additionally, when
30
30
* enabled, raw string length is limited by the maxBinLength option.
31
31
*/
@@ -196,9 +196,8 @@ try {
196
196
) ;
197
197
}
198
198
}
199
- export const DataViewIndexOutOfBoundsError = RangeError ;
200
199
201
- const MORE_DATA = new DataViewIndexOutOfBoundsError ( "Insufficient data" ) ;
200
+ const MORE_DATA = new RangeError ( "Insufficient data" ) ;
202
201
203
202
const sharedCachedKeyDecoder = new CachedKeyDecoder ( ) ;
204
203
@@ -312,7 +311,7 @@ export class Decoder<ContextType = undefined> {
312
311
object = this . doDecodeSync ( ) ;
313
312
decoded = true ;
314
313
} catch ( e ) {
315
- if ( ! ( e instanceof DataViewIndexOutOfBoundsError ) ) {
314
+ if ( ! ( e instanceof RangeError ) ) {
316
315
throw e ; // rethrow
317
316
}
318
317
// fallthrough
@@ -368,7 +367,7 @@ export class Decoder<ContextType = undefined> {
368
367
}
369
368
}
370
369
} catch ( e ) {
371
- if ( ! ( e instanceof DataViewIndexOutOfBoundsError ) ) {
370
+ if ( ! ( e instanceof RangeError ) ) {
372
371
throw e ; // rethrow
373
372
}
374
373
// fallthrough
@@ -657,6 +656,9 @@ export class Decoder<ContextType = undefined> {
657
656
return this . decodeBinary ( byteLength , headerOffset ) ;
658
657
}
659
658
659
+ /**
660
+ * @throws {@link RangeError }
661
+ */
660
662
private decodeUtf8String ( byteLength : number , headerOffset : number ) : string {
661
663
if ( byteLength > this . maxStrLength ) {
662
664
throw new DecodeError (
@@ -687,6 +689,9 @@ export class Decoder<ContextType = undefined> {
687
689
return false ;
688
690
}
689
691
692
+ /**
693
+ * @throws {@link RangeError }
694
+ */
690
695
private decodeBinary ( byteLength : number , headOffset : number ) : Uint8Array {
691
696
if ( byteLength > this . maxBinLength ) {
692
697
throw new DecodeError ( `Max length exceeded: bin length (${ byteLength } ) > maxBinLength (${ this . maxBinLength } )` ) ;
0 commit comments