GlucoseIQ
API Reference@glucoseiq/core

Time-Series Primitives

Gap detection, day/night splitting, and grid alignment.

alignToGrid

Import: @glucoseiq/core

alignToGrid(readings: GlucoseReading[], options?: AlignOptions): GridPoint[]

Resamples readings onto a fixed time grid.

Returns: Grid points from the first to the last reading; genuine gaps are holes

import { alignToGrid, type GlucoseReading } from '@glucoseiq/core'

const readings: GlucoseReading[] = [
  { value: 110, unit: 'mg/dL', timestamp: '2024-01-01T08:00:00Z' },
  { value: 120, unit: 'mg/dL', timestamp: '2024-01-01T08:10:00Z' },
]
const grid = alignToGrid(readings) // 5-min slots, gaps ≤15 min interpolated
ParameterDescription
readingsGlucose readings with ISO 8601 timestamps
optionsInterval, interpolation window, and output unit

detectGaps

Import: @glucoseiq/core

detectGaps(readings: GlucoseReading[], options?: GapDetectionOptions): GlucoseGap[]

Finds gaps (sensor dropouts) between consecutive readings.

Returns: Gaps in chronological order (empty if none)

ParameterDescription
readingsGlucose readings with ISO 8601 timestamps
optionsGap threshold

splitDayNight

Import: @glucoseiq/core

splitDayNight(readings: GlucoseReading[], options?: DayNightOptions): DayNightSplit

Splits readings into daytime and nighttime by local hour. The night window may wrap past midnight (e.g. 22:00–06:00).

Returns: Readings partitioned into day and night

Throws: If the time zone is invalid

ParameterDescription
readingsGlucose readings with ISO 8601 timestamps
optionsTime zone and night window

On this page