@@ -23,9 +23,9 @@ export type DecoderOptions<ContextType = undefined> = Readonly<
2323 /**
2424 * By default, string values will be decoded as UTF-8 strings. However, if this option is true,
2525 * string values will be returned as Uint8Arrays without additional decoding.
26- *
26+ *
2727 * This is useful if the strings may contain invalid UTF-8 sequences.
28- *
28+ *
2929 * Note that this option only applies to string values, not map keys. Additionally, when
3030 * enabled, raw string length is limited by the maxBinLength option.
3131 */
@@ -196,9 +196,8 @@ try {
196196 ) ;
197197 }
198198}
199- export const DataViewIndexOutOfBoundsError = RangeError ;
200199
201- const MORE_DATA = new DataViewIndexOutOfBoundsError ( "Insufficient data" ) ;
200+ const MORE_DATA = new RangeError ( "Insufficient data" ) ;
202201
203202const sharedCachedKeyDecoder = new CachedKeyDecoder ( ) ;
204203
@@ -312,7 +311,7 @@ export class Decoder<ContextType = undefined> {
312311 object = this . doDecodeSync ( ) ;
313312 decoded = true ;
314313 } catch ( e ) {
315- if ( ! ( e instanceof DataViewIndexOutOfBoundsError ) ) {
314+ if ( ! ( e instanceof RangeError ) ) {
316315 throw e ; // rethrow
317316 }
318317 // fallthrough
@@ -368,7 +367,7 @@ export class Decoder<ContextType = undefined> {
368367 }
369368 }
370369 } catch ( e ) {
371- if ( ! ( e instanceof DataViewIndexOutOfBoundsError ) ) {
370+ if ( ! ( e instanceof RangeError ) ) {
372371 throw e ; // rethrow
373372 }
374373 // fallthrough
@@ -657,6 +656,9 @@ export class Decoder<ContextType = undefined> {
657656 return this . decodeBinary ( byteLength , headerOffset ) ;
658657 }
659658
659+ /**
660+ * @throws {@link RangeError }
661+ */
660662 private decodeUtf8String ( byteLength : number , headerOffset : number ) : string {
661663 if ( byteLength > this . maxStrLength ) {
662664 throw new DecodeError (
@@ -687,6 +689,9 @@ export class Decoder<ContextType = undefined> {
687689 return false ;
688690 }
689691
692+ /**
693+ * @throws {@link RangeError }
694+ */
690695 private decodeBinary ( byteLength : number , headOffset : number ) : Uint8Array {
691696 if ( byteLength > this . maxBinLength ) {
692697 throw new DecodeError ( `Max length exceeded: bin length (${ byteLength } ) > maxBinLength (${ this . maxBinLength } )` ) ;
0 commit comments