code: def encode(i, *, width=-1):
          
          if i < 0:
              raise ValueError("value is negative")
          assert width != 0
          data = bytearray()
          while i:
              data.append(i & 127)
              i >>= 7
          if width > 0 and len(data) > width:
              raise ValueError("Integer too large")
          if len(data) < abs(width):
              data.extend([0] * (abs(width) - len(data)))
          data.reverse()
          return data
docs: Encodes a nonnegative integer into syncsafe format
  
          When width > 0, then len(result) == width
          When width < 0, then len(result) >= abs(width)