API Reference

@techsquidtv/canvas-timeline-utils

packages/utils/src/index.ts

Common Entry Points

Start with these essential APIs, then check the full reference index below.

API Index

Exhaustive list of all public exports grouped by category.

Function

20
addRational

Adds two rational timeline times.

assertValidRationalTime

Asserts that a value is a finite rational timeline time.

clamp

Restricts a number to an inclusive minimum and maximum range.

compareRational

Compares two rational timeline times.

formatRationalTimecode

Formats a `RationalTime` as editable timecode text.

formatSeconds

Formats a rational timeline time as decimal seconds.

formatTime

Formats a rational timeline time as mm:ss.

formatTimecode

Formats seconds for flexible editable timecode text. Decimal formats are rounded to centiseconds and clamped at zero. Non-finite values are treated as zero. Frame formats round to the nearest frame for the supplied frame rate.

fromSeconds

Converts seconds to rational timeline time at the requested tick rate.

fromTimecodeFrameNumber

Converts a zero-based frame number to rational timeline time.

maxRational

Returns the later of two rational timeline times.

minRational

Returns the earlier of two rational timeline times.

parseTimecode

Parses flexible editable timecode text into seconds. Accepts plain seconds, decimal seconds, `m:ss`, `m:ss.cc`, `h:mm:ss`, `h:mm:ss.cc`, flexible single-digit colon segments such as `1:2`, and unit suffixes like `s` (seconds), `ms` (milliseconds), `m` (minutes), or `f` (frames, which requires a `frameRate` option). Invalid, negative, missing, or out-of-range user text returns `null`. Invalid developer options such as unsupported drop-frame rates throw `RangeError`.

parseTimecodeToRationalTime

Parses editable timecode text into `RationalTime`.

rationalEquals

Checks whether two rational timeline times represent the same moment.

resolveTimecodeFrameRate

Resolves a frame-rate option to frames per second. This uses the same validation and normalization path as the timecode formatter/parser helpers, so invalid rates throw the same `RangeError`.

round

Rounds a number to the requested number of decimal places.

subRational

Subtracts one rational timeline time from another.

toSeconds

Converts a rational timeline time to seconds.

toTimecodeFrameNumber

Converts a rational time to the nearest source frame number.