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

trackerjs

v1.0.0

Published

A fork of Meteor Tracker

Readme

Tracker

Tracker is an incredibly tiny (~1k) but incredibly powerful library for transparent reactive programming in JavaScript. (It is a fork of Meteor Tracker)

Tracker gives you much of the power of a full-blown Functional Reactive Programming (FRP) system without requiring you to rewrite your program as a FRP data flow graph. Combined with Tracker-aware libraries, this lets you build complex event-driven programs without writing a lot of boilerplate event-handling code.

Tracker is essentially a simple convention, or interface, that lets reactive data sources (like your database) talk to reactive data consumers (such as a live-updating HTML templating library) without the application code in between having to be involved. Since the convention is very simple, it is quick and easy for library authors to make their libraries Tracker-aware, so that they can participate in Tracker reactivity.

This README has a short introduction to Tracker. For a complete guide to Tracker, consult the thorough and informative Tracker Manual, which is five times longer than the Tracker source code itself. You can also browse the API reference on the main Meteor docs page.

Installation

npm:

npm install --save tracker

Example

Take this ordinary JavaScript function:

function currentTemperatureFahrenheit () {
  return currentTemperatureCelsius() * 9/5 + 32;
}

We can call it for its value (assuming there's a currentTemperatureCelsius function):

> currentTemperatureFahrenheit()
71.8

But, if the currentTemperatureCelsius function is Tracker-aware (or even if it's not, but as long it reads the current temperature ultimately from some Tracker-aware data source), then we can also call currentTemperatureFahrenheit reactively.

var Tracker = require('trackerjs');

// Reactive function
function currentTemperatureFahrenheit () {
  return currentTemperatureCelsius() * 9/5 + 32;
}

var handle = Tracker.autorun(function () {
  console.log('The current temperature is', currentTemperatureFahrenheit(), 'F.');
});
The current temperature is 113 F.
The current temperature is 75.2 F.
The current temperature is 39.2 F.
...                      

The function passed to Tracker.autorun is called once immediately, and then it's called again whenever there are any changes to any of the reactive data sources that it referenced. To make this work, currentTemperatureCelsius just needs to register with Tracker as a reactive data source when it's called, which takes only a few lines of code.

var Tracker = require('trackerjs');
var dep = new Tracker.Dependency();
var temperature = randomTemperature();

// create random temperature
function randomTemperature () {
  var min = 0;
  var max = 100;
  var range = max - min;
  var temperature = Math.ceil(Math.random() * range) + min;
  return temperature;
}

// Data source
function currentTemperatureCelsius () {
  dep.depend();
  return temperature;
}

// dep.changed() will cause Tracker-aware recompute.
setInterval(function () {
  temperature = randomTemperature();
  dep.changed();
  console.log('Temperature changed.');
}, 1000);

The function Tracker.autorun return a computation. And we can stop "Reactive function" recomputing everytime data source change by using stop function in computation object.

handle.stop();

Code

var Tracker = require('tracker');
var dep = new Tracker.Dependency();

// create random temperature
function randomTemperature () {
  var min = 0;
  var max = 100;
  var range = max - min;
  return Math.ceil(Math.random() * range) + min;
}

var temperature = randomTemperature();

// Data source
function currentTemperatureCelsius () {
  dep.depend();
  return temperature;
}

// dep.changed() will cause Tracker-aware recompute.
setInterval(function () {
  temperature = randomTemperature();
  dep.changed();
  console.log('Temperature changed.');
}, 1000);

// Reactive function
function currentTemperatureFahrenheit () {
  return currentTemperatureCelsius() * 9/5 + 32;
}

var handle = Tracker.autorun(function () {
  console.log('The current temperature is', currentTemperatureFahrenheit(), 'F.');
});

// stop recomputing
setTimeout(function () {
  console.log('Stop recomputing.')
  handle.stop();
}, 3000);
The current temperature is 75.2 F.
Temperature changed.
The current temperature is 93.2 F.
Temperature changed.
The current temperature is 123.8 F.
Temperature changed.
Stop recomputing.
Temperature changed.
Temperature changed.