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| Parameter | Description |
|---|---|
readings | Glucose readings with ISO 8601 timestamps |
options | Interval, 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)
| Parameter | Description |
|---|---|
readings | Glucose readings with ISO 8601 timestamps |
options | Gap threshold |
splitDayNight
Import: @glucoseiq/core
splitDayNight(readings: GlucoseReading[], options?: DayNightOptions): DayNightSplitSplits 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
| Parameter | Description |
|---|---|
readings | Glucose readings with ISO 8601 timestamps |
options | Time zone and night window |