code: function splitWithSingleSpace(text) {
    const parts = [];
  
    let lastPart = undefined;
    for (const part of text.split(/( +)/g)) {
      if (part !== " ") {
        if (lastPart === " ") {
          parts.push(part);
        } else {
          parts.push((parts.pop() || "") + part);
        }
      } else if (lastPart === undefined) {
        parts.unshift("");
      }
  
      lastPart = part;
    }
  
    if (lastPart === " ") {
      parts.push((parts.pop() || "") + " ");
    }
  
    if (parts[0] === "") {
      parts.shift();
      parts.unshift(" " + (parts.shift() || ""));
    }
  
    return parts;
  }
docs: " a   b c   d e   f " -> [" a   b", "c   d", "e   f "]