code: def wrap(self, width):
          
          res = []
          prev_state = set()
          part = []
          cwidth = 0
          for char, _width, state in zip(self._string, self._width, self._state):
              if cwidth + _width > width:
                  if prev_state:
                      part.append(self.ANSI_RESET)
                  res.append("".join(part))
                  prev_state = set()
                  part = []
                  cwidth = 0
              cwidth += _width
              if prev_state == state:
                  pass
              elif prev_state <= state:
                  part.extend(state - prev_state)
              else:
                  part.append(self.ANSI_RESET)
                  part.extend(state)
              prev_state = state
              part.append(char)
          if prev_state:
              part.append(self.ANSI_RESET)
          if part:
              res.append("".join(part))
          return res
docs: Returns a partition of the string based on `width`