function encode(value: number, buffer: Buffer, position: number): number {
  let vlq = toVLQSigned(value);
  let digit;
  do {
    digit = vlq & VLQ_BASE_MASK;
    vlq = vlq >>> VLQ_BASE_SHIFT;
    if (vlq > 0) {
      // There are still more digits in this value, so we must make sure the
      // continuation bit is marked.
      digit = digit | VLQ_CONTINUATION_BIT;
    }
    buffer[position++] = CHAR_MAP[digit];
  } while (vlq > 0);

  return position;
}
Encodes a number to base64 VLQ format and appends it to the passed-in buffer

DON'T USE COMPOUND OPERATORS (eg `>>>=`) ON `let`-DECLARED VARIABLES!
V8 WILL DEOPTIMIZE THIS FUNCTION AND MAP CREATION WILL BE 25% SLOWER!

DON'T ADD MORE COMMENTS TO THIS FUNCTION TO KEEP ITS LENGTH SHORT ENOUGH FOR
V8 OPTIMIZATION!