npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@iimrd/dvbcss-clocks

v0.1.4

Published

Javascript library implementing clock objects for modelling timelines. Useful in DVB CSS implementations.

Downloads

307

Readme

@iimrd/dvbcss-clocks

TypeScript classes for representing clocks and timelines and their relationships to each other. Useful in event-driven real-time applications to drive and track the progress of time, such as synchronised companion screen applications based on DVB CSS / HbbTV 2.

This package is part of the @iimrd/dvbcss-protocols monorepo.

[!NOTE] This is a TypeScript + ESM rewrite of the original dvbcss-clocks library developed by the BBC.

Installation

pnpm add @iimrd/dvbcss-clocks

API overview

| Export | Description | |---|---| | ClockBase | Abstract base class for all clocks. Extends EventEmitter. Manages parent-child relationships and emits change / available / unavailable events. | | DateNowClock | Root clock backed by Date.now(). Options: tickRate, maxFreqErrorPpm. | | CorrelatedClock | Clock whose time is derived from a parent via a Correlation. Options: tickRate, speed, correlation. | | Correlation | Immutable value object mapping a point on a parent clock to a point on a child clock, with optional error bounds. | | OffsetClock | Applies a fixed time offset to its parent clock (e.g. for render-latency compensation). | | measurePrecision | Utility function that empirically measures the minimum observable tick of a time source. |

Quick overview

Clock objects form a hierarchy and are used to represent how one sense of time relates to another — e.g. how a timeline for media playback relates to real world time.

import {
  DateNowClock,
  Correlation,
  CorrelatedClock,
} from "@iimrd/dvbcss-clocks";

A DateNowClock is a root clock wrapping system time from Date.now():

const rootClock = new DateNowClock({ tickRate: 1000, maxFreqErrorPpm: 50 });
console.log(rootClock.now());

Build a hierarchy using CorrelatedClock objects where a Correlation describes the relationship between a clock and its parent:

const corr = new Correlation(5000, 0);
const wallClock = new CorrelatedClock(rootClock, {
  tickRate: 50,
  correlation: corr,
});

This clock has 50 ticks/second. The correlation means that when rootClock is at time position 5000, wallClock is at position 0. Querying the position of this clock calculates a value from its parent by extrapolating from the correlation and converting tick rates:

console.log(rootClock.now(), wallClock.now());
// e.g. 5000, 0
//      5200, 10
//      5215, 10.75

Add another clock to the chain — for example, a video timeline starting from zero right now:

const videoTimeline = new CorrelatedClock(wallClock, {
  tickRate: 25,
  correlation: new Correlation(wallClock.now(), 0),
});

Listen for events — changes propagate down the hierarchy:

videoTimeline.on("change", () => console.log("Video timeline changed"));
videoTimeline.on("available", () => console.log("Video timeline available"));
videoTimeline.on("unavailable", () => console.log("Video timeline unavailable"));

Modify clock properties. This triggers change events on all descendant clocks:

wallClock.correlation = new Correlation(rootClock.now(), 0);
wallClock.speed = 2.0;
wallClock.availabilityFlag = false;
wallClock.availabilityFlag = true;

Schedule callbacks tied to a clock's timeline:

videoTimeline.setAtTime(() => console.log("Time to stop video"), 500);

This callback fires when videoTimeline reaches (or jumps past) time position 500, even if correlations change in the meantime.

Clocks can be built into arbitrarily complex hierarchies and reconfigured dynamically. There are helper methods for converting time values between clocks, and ways to annotate clocks with quantified uncertainty bounds (dispersions) that are tracked by their descendants.

Tests

pnpm test

Licence and Authors

All code and documentation is licensed by the original author and contributors under the Apache License v2.0:

See the AUTHORS file for a full list of individuals and organisations that have contributed to this code.