intervalXorAllUnix
Signature
Section titled “Signature”intervalXorAllUnix(intervals: { start: string | number; end: string | number; }[]): { start: number; end: number; }[]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. - Intervals are half-open
[start, end). The result is every maximal run where the coverage count is odd, so touching runs join and an empty interval (start === end) changes nothing. Every boundary is an input’s ownstartorend; none is stepped by an epoch unit. For two intervals this is 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 safe-integer (or numeric-string) values — fractions, empty strings and values beyond ±(2^53 − 1) are invalid — 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
Members of each item
| Member | Type | Description |
|---|---|---|
start | number | The instant the interval begins at, as a Unix epoch number in the unit the arguments share. |
end | number | The first instant after the interval, in the same unit as start. It is exclusive: the interval holds everything from start up to but not including this value. It is always later than start. |
Examples
Section titled “Examples”import { intervalXorAllUnix } from "@northguild/gmt/unix/interval";
intervalXorAllUnix([{ start: 0, end: 1500000000 }, { start: 1400000000, end: 1700000000 }]) // [{ start: 0, end: 1400000000 }, { start: 1500000000, end: 1700000000 }]