hardlounge/client/js/helpers/ircmessageparser/anyIntersection.ts

16 lines
424 B
TypeScript
Raw Permalink Normal View History

// Return true if any section of "a" or "b" parts (defined by their start/end
import {Part} from "./merge";
// markers) intersect each other, false otherwise.
function anyIntersection(a: Part, b: Part) {
2019-07-17 09:33:59 +00:00
return (
(a.start <= b.start && b.start < a.end) ||
(a.start < b.end && b.end <= a.end) ||
(b.start <= a.start && a.start < b.end) ||
(b.start < a.end && a.end <= b.end)
);
}
2019-11-16 17:24:03 +00:00
export default anyIntersection;