How to assign current document text to a JavaScript variable in an EmEditor macro?

Is there an easy way to assign the current document’s text to a JavaScript variable?

Ideally, a one-liner such as:

const sDocTxt = document.Text;

Or:

const sDocTxt = document.GetText();

My current approach is to retrieve each line with document.GetLine(iLine); and join them into an array.

function getDocumentText() {
  const nLines = document.GetLines();
  const asLines = [];
  let iLine = 0;
  do {
    iLine += 1;
    asLines.push(document.GetLine(iLine, eeGetLineWithNewLines));
  } while (iLine < nLines);
  return asLines.join("");
}

const sDocTxt = getDocumentText();

Constraint:
The command must not change the selection.
I.e. document.selection.SelectAll(); is not an option.