Iterable encodeVlq()

in lib/src/vlq.dart [40:60]


Iterable<String> encodeVlq(int value) {
  if (value < minInt32 || value > maxInt32) {
    throw ArgumentError('expected 32 bit int, got: $value');
  }
  var res = <String>[];
  var signBit = 0;
  if (value < 0) {
    signBit = 1;
    value = -value;
  }
  value = (value << 1) | signBit;
  do {
    var digit = value & vlqBaseMask;
    value >>= vlqBaseShift;
    if (value > 0) {
      digit |= vlqContinuationBit;
    }
    res.add(base64Digits[digit]);
  } while (value > 0);
  return res;
}