Walking between points
This condition

else if (direction.x % 1 !== 0 || direction.y % 1 !== 0)


Doesn't check for integer and is (almost) always false, since direction.x is the result of Math.sign(), which returns an integer (1, 0, or -1) or NaN, which is the only time the condition can be true.

Use point.x instead. I would also use Number.isInteger() to check for integers. This check should also be at the start of your loop, since the first point of the input is currently not getting checked.



I'm not sure what this code is supposed to accomplish.

else if (direction.x === 0 &amp;&amp; direction.y === 0) {
  return;
}


What is the desires behavior when you get two identical point after each other? Is it illegal? Throw an error. Should it keep both points? Don't do anything. Should duplicates be deleted? Replace return with continue so it won't get added to the result.