This particular line and the comment, does the comment tell what the code is actually doing?
// If times are equal, an endpoint that starts an interval comes first.
return isStart && !e.isStart ? -1 : !isStart && e.isStart ? 1 : 0;
If we are to return an endpoint that starts an interval comes first, then “isStart && !e.isStart ?” should be 1 not -1, isn’t it, if this object (isStart) is true.
To what I understand, based on the comment that would be
return isStart && !e.isStart ? 1 : !isStart && e.isStart ? -1 : 0;