Skip to main content

Sequence

classpond-tssource

An unbounded fixed-step grid definition used for alignment or aggregation.

Sequence defines where buckets fall. Call bounded(...) to realize a finite BoundedSequence over a specific range.

Important distinction:

  • the sequence anchor defines where the unbounded grid starts
  • the caller-supplied range defines which finite slice is realized

The default anchor is Unix epoch 0.

Constructor

new Sequence(input: FixedSequenceInput | CalendarSequenceInput)

Static methods

calendarstatic

calendar(unit: CalendarUnit, options?: CalendarOptions): Sequence

Creates an unbounded calendar-aware sequence.

Calendar sequences step by local calendar boundaries in an IANA time zone instead of by a fixed millisecond duration. Supported units are "day", "week", and "month".

Defaults:

  • timeZone: "UTC"

dailystatic

daily(options?: { anchor?: TimestampInput }): Sequence
Sequence.daily()

Creates a daily fixed-step sequence.

everystatic

every(every: DurationInput, options?: { anchor?: TimestampInput }): Sequence

Creates an unbounded fixed-step sequence.

The returned sequence is a grid definition, not a finite bucket list. By default the grid is anchored at Unix epoch 0, which makes independently-created sequences line up by default. Use bounded(...) or series operations like align(...) / aggregate(...) to realize a finite slice of the grid over a concrete range.

hourlystatic

hourly(options?: { anchor?: TimestampInput }): Sequence
Sequence.hourly()

Creates an hourly fixed-step sequence.

Methods

anchor

anchor(): number
sequence.anchor()

Returns the millisecond anchor used by this grid definition.

bounded

bounded(range: TemporalLike, options?: { sample?: SequenceSample }): BoundedSequence
sequence.bounded(new TimeRange({ start, end }))

Realizes a finite BoundedSequence over the supplied range.

Sample position controls which intervals are selected:

  • 'begin' (default) — sample point is the interval's start. Includes buckets where sample ∈ [range.begin, range.end].
  • 'center' — sample point is the interval's midpoint. Same inclusive range as 'begin'.
  • 'end' — sample point is the interval's exclusive end (i.e. the start of the next bucket). Inclusion is left-exclusive: sample ∈ (range.begin, range.end]. This keeps the boundary case symmetric — an end-sample at exactly range.begin() would otherwise pull in an interval whose extent sits entirely before the range.

kind

kind(): 'fixed' | 'calendar'
sequence.kind()

Returns whether this sequence is fixed-step or calendar-aware.

stepMs

stepMs(): number
sequence.stepMs()

Returns the fixed interval size in milliseconds.

timeZone

timeZone(): string | undefined
sequence.timeZone()

Returns the IANA time zone for calendar-aware sequences, if any.