intervalXorAllUnix
Signature
Section titled “Signature”intervalXorAllUnix(intervals: { start: string | number; end: string | number; }[]): { start: number; end: number; }[]import { intervalXorAllUnix } from "@northguild/gmt/unix/interval";Return the symmetric difference across a list of Unix epoch intervals — the set of epoch
- values covered by an odd number of the input intervals.
- List-form generalization of
intervalXorUnix, which is pairwise only. - Implemented as a coverage sweep: each interval contributes a
+1at its start and a-1one epoch unit after its end; the result is every maximal run where the running coverage count is odd. For two intervals this reduces to exactlyintervalXorUnix’s pairwise result. - Order of the input list does not matter; the result is sorted by start.
- Returns
[]for an empty list, and[]when every value is covered an even number of times (e.g. two identical intervals cancel out). - Returns
[]whenintervalsis not an array, when any element is not a{ start, end }record of finite numeric (or numeric-string) values, or when any element hasstart > end.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
intervals |
{ start: string | number; end: string | number; }[] |
array of { start, end } records |
Returns
Section titled “Returns”array of { start, end } records covered an odd number of times, or [] on invalid input
Examples
Section titled “Examples”intervalXorAllUnix([{ start: 0, end: 1500000000 }, { start: 1400000000, end: 1700000000 }]) // [{ start: 0, end: 1399999999 }, { start: 1500000001, end: 1700000000 }]intervalXorAllUnix([]) // []