decode does not work well.
lili21 opened this issue · comments
vlq.decode(vlq.encode(123456789123456789))
the result should be [ 123456789123456789]
. right ?
If you look at this library's implementation, you can see that internally it is using javascript's bit shift operators. In your example, the issue actually arises in the encoding, not the decoding. Anything outside of +/- 2^30 is going to fail. As part of the encoding, all integers are mapped to the (non-negative) whole numbers, so everything gets its absolute value effectively doubled. Starting at +/- 2^30, you hit the 2^31 limit of 32-bit signed integers. If the intended use of this library is for sourcemaps, I doubt fixing this limitation would be a high priority.
@Conduitry thanks for the explaining.