Skip to content

intervalXorAllUnix

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 own start or end; none is stepped by an epoch unit. For two intervals this is exactly intervalXorUnix’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 [] when intervals is 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 has start > end.
ParameterTypeDescription
intervals{ start: string | number; end: string | number; }[]array of { start, end } records

array of { start, end } records covered an odd number of times, or [] on invalid input

Members of each item

MemberTypeDescription
startnumberThe instant the interval begins at, as a Unix epoch number in the unit the arguments share.
endnumberThe 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.
import { intervalXorAllUnix } from "@northguild/gmt/unix/interval";
intervalXorAllUnix([{ start: 0, end: 1500000000 }, { start: 1400000000, end: 1700000000 }]) // [{ start: 0, end: 1400000000 }, { start: 1500000000, end: 1700000000 }]
intervals
output 

unix/interval/intervalXorAllUnix.ts