lib0
lib0 copied to clipboard
Throw when reading past end of array
Putting this up as an (untested) fix for #42. This isn't duck-typing but, instead, enforces the known array length. Has the additional benefit of catching other cases where the same infinite-loop problem may occur, such as this:
import { createDecoder, readVarUint } from 'lib0/decoding';
const decoder = createDecoder(new Uint8Array([200, 200, 200, 200]));
readVarUint(decoder);