I wanted to find the built-in function for this to no avail so I had to write it in script:
function squeeze(range) {
return [].concat(...range).filter(n => n)
}
This JS function flattens the 2D array range
and returns it.
Note that it filters out empty cells with uneven columns.