| 104 | |
| 105 | /** Return true if int1 is a subset of int2 */ |
| 106 | export function intervalSubset(int1: Interval, int2: Interval): boolean { |
| 107 | // Start side: int2's lower bound must be at or below int1's. The only case |
| 108 | // needing a strict comparison is when int1 is closed but int2 is open — then |
| 109 | // int1.start must be strictly greater (int2 excludes its own start point). |
| 110 | // When both are open, equal starts are fine (same excluded point). |
| 111 | if (!int1.openStart && int2.openStart) { |
| 112 | if (int1.start <= int2.start) return false; |
| 113 | } else { |
| 114 | if (int1.start < int2.start) return false; |
| 115 | } |
| 116 | // End side: symmetric. |
| 117 | if (!int1.openEnd && int2.openEnd) { |
| 118 | if (int1.end >= int2.end) return false; |
| 119 | } else { |
| 120 | if (int1.end > int2.end) return false; |
| 121 | } |
| 122 | return true; |
| 123 | } |