encodeVarint static method
Implementation
static List<int> encodeVarint(int i) {
if (i < 253) {
return [i];
} else if (i < 0x10000) {
final bytes = List<int>.filled(3, 0);
bytes[0] = 0xfd;
BinaryOps.writeUint16LE(i, bytes, 1);
return bytes;
} else if (i < 0x100000000) {
final bytes = List<int>.filled(5, 0);
bytes[0] = 0xfe;
BinaryOps.writeUint32LE(i, bytes, 1);
return bytes;
} else {
throw LayoutException("Failed to encode value as varint.");
}
}