Classes
Public classes exported from timescope.
Timescope
Constructor
new Timescope(options?: TimescopeOptionsInitial)Properties
timenull follows the clock. Assignments use setTime(). - Get
Decimal | null
timeChanging- Get
Decimal | null
timeAnimating- Get
Decimal | null
timeRangeundefined is unbounded and null follows the clock. - Get
TimescopeRange<Decimal | null | undefined>
zoomsetZoom(). - Get
number
zoomChanging- Get
number
zoomAnimating- Get
number
zoomRangeundefined is unbounded. - Get
TimescopeRange<number | undefined>
selectionRangenull when cleared. - Get
TimescopeRange<Decimal> | null
selectionRangeChanging- Get
TimescopeRange<Decimal> | null
sizedisabledtrue; initially false. - Get
boolean- Set
boolean
animating- Get
boolean
editing- Get
boolean
optionscanvasnull while unmounted. - Get
TimescopeCanvas | null
Methods
setTime(value, animation?)
Methodnull follows the clock.valueTimescopeTimeLikeanimation?TimescopeAnimationInput
- Defaults
animation:'out', 500 ms.
booleanfalse for invalid input. setZoom(value, animation?)
MethodvalueTimescopeNumberLikeanimation?TimescopeAnimationInput
- Defaults
animation:'linear', 200 ms; lazy commit when zooming in.
booleanfalse for invalid input. setTimeRange(range?)
Methodrange?TimescopeRange<TimescopeTimeLike | undefined>
- Defaults
range:[undefined, null].
voidsetZoomRange(range?)
Methodrange?TimescopeRange<TimescopeNumberLike | undefined>
- Defaults
range:[undefined, undefined].
voidfitTo(range, options?)
MethodrangeTimescopeRange<TimescopeTimeLike<never>>options?TimescopeFitOptions
- Defaults
options.animation:true;options.padding:0CSS px.
booleanfalse for invalid range or padding; requires start < end and finite, nonnegative padding. setPlaybackTime(value)
Methodtime is null; null restores wall-clock time. valueTimescopeTimeLike
voidsetSelectionRange(range)
MethodrangeTimescopeRange<TimescopeTimeLike<never>> | null
voidclearSelectionRange()
MethodvoidsetOptions(next)
MethodnextTimescopeOptions
- Defaults
- Omitted settings use their defaults.
voidupdateOptions(patch)
Methodnull removes named entries.- Defaults
- Omitted settings retain their values.
voidreload(sources?)
Methodsources?string[]
- Defaults
sources: all sources.
Promise<boolean>false if unavailable or failed; does not wait for replacement data or drawing. prepareView()
Methodresize(width, height, dpr?)
Methodwidthnumberheightnumberdpr?number
- Defaults
dpr:1.
Promise<boolean>false for automatically sized targets or failure. redraw()
MethodPromise<void>nextFrame()
MethodPromise<void>mount(target?)
Methodtarget?TimescopeBackendTarget
thisunmount()
Methodvoiddispose()
Methodvoidon(event, handler)
Methodeventstringhandler(event: object | string) => void
() => voidun(event, handler)
Methodeventstringhandler(event: object | string) => void
voiddispose() also removes instance event listeners; unmount() retains them for a later mount. The unsubscribe function returned by on() ends an individual subscription while keeping the instance alive.
View control · Data refresh · Node.js · Cleanup
Events
timechanging- Payload
{ type: 'timechanging', value: Decimal | null, origin?: string }
timechanged- Payload
{ type: 'timechanged', value: Decimal | null, origin?: string }
timeanimating- Payload
{ type: 'timeanimating', value: Decimal | null, origin?: string }
timeanimated- Payload
{ type: 'timeanimated', value: Decimal | null, origin?: string }
zoomchanging- Payload
{ type: 'zoomchanging', value: number, origin?: string }
zoomchanged- Payload
{ type: 'zoomchanged', value: number, origin?: string }
zoomanimating- Payload
{ type: 'zoomanimating', value: number, origin?: string }
zoomanimated- Payload
{ type: 'zoomanimated', value: number, origin?: string }
selectionrangechanging- Payload
{ type: 'selectionrangechanging', value: TimescopeRange<Decimal> | null, origin?: string }
selectionrangechanged- Payload
{ type: 'selectionrangechanged', value: TimescopeRange<Decimal> | null, origin?: string }
error- Payload
{ type: 'error', value: Error, origin?: string }
ready- Payload
'ready'
mount- Payload
'mount'
unmount- Payload
'unmount'
resize- Payload
'resize'
change- Payload
'change'
Navigation values have committed (time, zoom), interaction (timeChanging, zoomChanging), and animation (timeAnimating, zoomAnimating) phases. Value events contain { type, value, origin? }; lifecycle events carry their event-name string. Mount readiness does not imply data acquisition or drawing completion; use a prepared view and nextFrame() when reading pixels.
TimescopeDataLoader
Constructor
new TimescopeDataLoader(options: TimescopeDataLoaderOptions)Each load() performs acquisition again; a DataLoader does not cache results. Sharing an instance shares acquisition and conversion settings, not DataSource caches or invalidation state. Configure transforms on the loader, not on a DataSource receiving it.
ranged is true for templated URLs or function loaders without chunked: false. A snapshot DataLoader requires chunked: false when supplied to a DataSource.
Properties
rangedload() requires a range request. - Type
boolean
Methods
load()
MethodPromise<readonly TimescopeDataRow[]>- Rejects
Error: range loader called without a request.
Acquisition or conversion error: input could not be loaded or normalized.
load(request)
MethodrequestTimescopeLoadRequest
Promise<readonly TimescopeDataRow[]>- Rejects
Error: snapshot loader called with a request, or unknown alphabetic URL placeholder.RangeError: reversed range or nonpositive resolution.
Acquisition or conversion error: input could not be loaded or normalized.
TimescopeDataSourceBase
abstract class TimescopeDataSourceBase implements TimescopeDataSourceConstructor
constructor(options?: TimescopeSourceCommonOptions)Properties
revision- Type
number- Initial value
0
invalidation- Type
TimescopeDataSourceInvalidation | undefined- Initial value
undefined
Methods
query(request)
MethodrequestTimescopeDataSourceQuery
invalidate(range?)
Methodchange and invalidate, without acquiring data; omitted range affects all data.range?TimescopeRange<TimescopeTimeLike<undefined>>
void- Throws
RangeError: reversed range.
on(event, handler)
Methodevent'change' | 'invalidate'handler(event: object | string) => void
() => voidun(event, handler)
Methodevent'change' | 'invalidate'handler(event: object | string) => void
voiddispose()
MethodvoidEvents
change- Payload
'change'
invalidate- Payload
{ type: 'invalidate', value: TimescopeDataSourceInvalidation }
Decimal
Constructor
Decimal(value: DecimalLike): Decimal
Decimal(value: null): null
Decimal(value: undefined): undefinedAccepts decimal and scientific-notation strings, numbers, bigint, Decimal values, and coefficient/scale objects. For example, { coeff: 123n, digits: 2 } represents 1.23. digits may be negative. Nullish inputs are preserved.
Properties
coeffcoeff × 10⁻ᵈⁱᵍⁱᵗˢ. - Type
bigint
digits- Type
number
Methods
Numeric methods return new values; their $ variants mutate the receiver. Use non-mutating methods on values received from Timescope.
| Operation | Semantics |
|---|---|
round, floor, ceil, trunc | Decimal places, default 0; negative places round to powers of ten. Nearest ties round away from zero; floor and ceil round toward negative and positive infinity; trunc rounds toward zero. force: true preserves scale, including trailing zeros. |
roundBy, floorBy, ceilBy, truncBy | Round to a multiple of the supplied step. roundBy defaults to nearest rounding. |
div, divExact | precision counts significant digits and must be a positive safe integer. div is exact for terminating results when precision is omitted; otherwise it rounds, defaulting to 18. divExact throws for non-terminating results without a fallback precision. |
divRound, divFloor, divCeil, divTrunc | Round division results to decimal places. |
pow, sqrt, root | Exact when possible with precision omitted; otherwise precision 18. Fractional exponents are supported. |
log, inverse | log defaults to precision 18; inverse follows division precision rules. |
mod, modPositive | JavaScript remainder sign rules, or a nonnegative remainder respectively. |
between, isCloseTo | Inclusive bounds, or absolute-difference tolerance respectively. |
split, splitBy | Return the rounded part and remainder; default mode 'floor'. split defaults to digits: 0; splitBy uses step multiples. |
rescale, toFixed, number, integer | Set decimal scale (omitting scale removes trailing fractional zeros), format rounded fixed decimal places, convert with possible precision loss, or truncate toward zero respectively. |
neg | Negates by default; false preserves the sign. |
add(v)
MethodDecimalsub(v)
MethodDecimalmul(v, digits?)
Methoddigits?number | bigint
Decimaldiv(v, precision?, mode?)
Methodprecision?number | bigintmode?'round' | 'floor' | 'ceil' | 'trunc'
DecimaldivExact(v, fallbackPrecision?, mode?)
MethodfallbackPrecision?number | bigintmode?'round' | 'floor' | 'ceil' | 'trunc'
DecimaldivRound(v, digits?, mode?)
Methoddigits?number | bigintmode?'round' | 'floor' | 'ceil' | 'trunc'
DecimaldivFloor(v, digits?)
Methoddigits?number | bigint
DecimaldivCeil(v, digits?)
Methoddigits?number | bigint
DecimaldivTrunc(v, digits?)
Methoddigits?number | bigint
Decimalmod(v)
MethodDecimalmodPositive(v)
MethodDecimalneg(flag?)
Methodflag?boolean
Decimalabs()
MethodDecimalsign()
Methodnumbereq(v)neq(v)
Methodbooleanlt(v)le(v)
Methodbooleangt(v)ge(v)
Methodbooleancmp(v)
Methodnumberbetween(min, max)
MethodminDecimalLike | undefinedmaxDecimalLike | undefined
booleanisCloseTo(v, tolerance)
MethodtoleranceDecimalLike
booleanisZero()isPositive()isNegative()
Methodbooleanround(digits?, force?)
Methoddigits?number | bigintforce?boolean
Decimalfloor(digits?, force?)
Methoddigits?number | bigintforce?boolean
Decimalceil(digits?, force?)
Methoddigits?number | bigintforce?boolean
Decimaltrunc(digits?, force?)
Methoddigits?number | bigintforce?boolean
DecimalroundBy(step, mode?)
MethodstepDecimalLikemode?'round' | 'floor' | 'ceil' | 'trunc'
DecimalfloorBy(step)ceilBy(step)truncBy(step)
MethodstepDecimalLike
Decimalrescale(digits?, mode?)
Methoddigits?number | bigintmode?'round' | 'floor' | 'ceil' | 'trunc'
DecimaltoString()
MethodstringtoFixed(digits)
Methoddigitsnumber | bigint
stringnumber()
Methodnumberinteger()
Methodbigintpow(exponent, precision?)
MethodexponentDecimalLikeprecision?number | bigint
Decimalsqrt(precision?)
Methodprecision?number | bigint
Decimalroot(degree, precision?)
Methoddegreenumber | bigintprecision?number | bigint
Decimallog(base, precision?)
MethodbaseDecimalLikeprecision?number | bigint
Decimalinverse(precision?)
Methodprecision?number | bigint
Decimalclamp(min, max)
MethodminDecimalLike | undefinedmaxDecimalLike | undefined
Decimalshift10(exponent)
Methodexponentnumber | bigint
Decimalorder()
Methodbigintfrac()
MethodDecimalsplit(digits?, mode?)
MethodsplitBy(step, mode?)
MethodstepDecimalLikemode?'round' | 'floor' | 'ceil' | 'trunc'
clone()
MethodDecimalStatic Methods
min, max, and minmax ignore nullish values and return null for an extremum when no values remain. isDecimal checks for a Decimal instance, isDecimalLike for accepted input, and isDecimalType for a Decimal or coefficient/scale object.
Decimal.isDecimal(value)
Static methodvalueunknown
value is DecimalDecimal.isDecimalLike(value)
Static methodvalueunknown
value is DecimalLikeDecimal.isDecimalType(value)
Static methodvalueunknown
booleanDecimal.pow10(exponent)
Static methodexponentnumber | bigint
DecimalDecimal.min(...values)
Static method...values(DecimalLike | null | undefined)[]
Decimal | nullDecimal.max(...values)
Static method...values(DecimalLike | null | undefined)[]
Decimal | nullDecimal.minmax(...values)
Static method...values(DecimalLike | null | undefined)[]
Decimal.equals(a, b)
Static methodaDecimalLike | null | undefinedbDecimalLike | null | undefined
booleanCalendar
Calendar instants use Unix epoch seconds, including fractional seconds; Date inputs convert from milliseconds. The initial display zone is 'local'. Zones accept 'local', 'utc', or IANA names; changing the zone preserves the instant. Factory methods preserve null and undefined.
Constructor
new Calendar()new Calendar(epochSeconds)new Calendar(year, month, day, hour?, minutes?, seconds?)
ConstructorCreates a calendar value in the local display zone.
epochSecondsDecimalLike | DateUnix epoch seconds or a JavaScript date.
year, month, daybigint | numberCalendar components; month and day are one-based.
hour?, minutes?bigint | numberseconds?DecimalLike
- Defaults
No arguments: current time.
hour,minutes,seconds:0.
CalendarStatic Methods
Calendar.fromEpoch(epochSeconds)
Static methodepochSecondsDecimalLike
CalendarCalendar.fromDate(date)
Static methoddateDate
CalendarCalendar.fromComponents(input)
Static methodinput{ year: DecimalLike, month: DecimalLike, day: DecimalLike, hour?: DecimalLike, minutes?: DecimalLike, seconds?: DecimalLike, zone?: string }
- Defaults
input.hour,input.minutes,input.seconds:0.input.zone:'local'.
CalendarCalendar.parse(value, format?, inputZone?)
Static methodvaluestringformat?stringinputZone?string
- Defaults
format: ISO 8601;inputZone:'local'.
CalendarMethods
Component getters use the display zone: months 1–12, days 1–31, hours 0–23, minutes 0–59, weekdays Sunday 0 through Saturday 6. Component setters and zone-changing methods return new instances; $ variants mutate the receiver. The zone argument to fromComponents() determines component interpretation, not the initial display zone.
Day/month/year alignment methods return new instances at midnight in the current zone. alignToSecond(step) aligns to a seconds interval within the day.
year()
Methodbigintmonth()
Methodbigintday()
Methodbiginthour()
Methodbigintminutes()
Methodbigintseconds()
MethodDecimalweekday()
Methodnumberepoch()
MethodDecimalcomponents()
Method{ year: bigint, month: bigint, day: bigint, hour: bigint, minutes: bigint, seconds: Decimal, weekday: number }clone()
MethodCalendaryear(value)month(value)day(value)hour(value)minutes(value)seconds(value)
MethodvalueDecimalLike
Calendaryear$(value)month$(value)day$(value)hour$(value)minutes$(value)seconds$(value)
MethodvalueDecimalLike
Calendarepoch(value)
MethodvalueDecimalLike
Calendarepoch$(value)
MethodvalueDecimalLike
thiszone()
Methodstringzone(value)
Methodvaluestring
Calendarutc()
MethodCalendarlocal()
MethodCalendarzone$(value)utc$()local$()
Methodvaluestring
thisalignToDay(step?)
Methodstep?number | bigint | (number | bigint)[]
- Defaults
step:1.
CalendarnextDay(step?)
Methodstep?number | bigint | (number | bigint)[]
- Defaults
step:1.
CalendaralignToMonth(step?)
Methodstep?number | bigint | (number | bigint)[]
- Defaults
step:1.
CalendarnextMonth(step?)
Methodstep?number | bigint | (number | bigint)[]
- Defaults
step:1.
CalendaralignToYear(step?, options?)
Methodoptions.era enables era-aware alignment.step?number | bigint | (number | bigint)[]options?{ era?: boolean }
- Defaults
step:1.
CalendarnextYear(step?, options?)
Methodoptions.era enables era-aware alignment.step?number | bigint | (number | bigint)[]options?{ era?: boolean }
- Defaults
step:1.
CalendaralignToSecond(step)
MethodstepDecimalLike
Calendarformat(format)
Methodformatstring
stringFormat Tokens
| Token | Parsing | Formatting |
|---|---|---|
Y / y, repeated n times | Optional sign; one or more digits | At least n digits; negative sign only |
IY | Same as Y | Four digits for years 0–9999; otherwise sign and at least six digits |
G, repeated n times | Positive era year; BC prefix or AD suffix | At least n digits; BC prefix or AD suffix |
g, repeated n times | Positive era year; optional BC prefix | At least n digits; BC prefix before AD 1 |
MM / M | 1–2 digit month | Two digits / no padding |
DD | 1–2 digit day | Two digits |
hh / h | 1–2 digit 24-hour time | Two digits / no padding |
mm | 1–2 digit minute | Two digits |
ss | 1–2 digit whole second | Two digits |
S, repeated n times | 1–n fractional digits | Exactly n digits; padded or truncated |
S* | One or more fractional digits | All fractional digits without trailing zeros; 0 for integer seconds |
Z | Z, ±HH:mm, or ±HHmm | Z for zero offset; otherwise ±HH:mm |
[text] | Literal text | Literal text |
| Backslash + character | Literal next character | Literal next character |
Custom parse formats require year and month; omitted components default to day 1 and midnight. Invalid dates throw. Formatting uses the current display zone. Year widths are minimum widths and never truncate; astronomical year 0 is 1 BC and -1 is 2 BC, while era-year tokens use positive era years. Characters other than recognized tokens and escapes, including fractional separators, are literal.