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

@coder-ka/term

v1.0.1

Published

A small library for reactive programming.

Readme

term.js

A small library for reactive programming.

Getting Started

npm i @coder-ka/term

Hello World

import { createTerm, createEffect } from "@coder-ka/term";

const GreetTo = createTerm<string>();

createEffect(
  () => {
      console.log(`Hello, ${GreetTo()}!`);
  },
  [GreetTo],
  [GreetTo],
);

GreetTo.set("World");
GreetTo.set("John");
GreetTo.set("Alice");

This code produces the following output:

Hello, World!
Hello, John!
Hello, Alice!

Term and Effect

Term.js consists of two core concepts: “Term” and “Effect”.

A Term is similar to a variable in mathematics, while an Effect is a process that reacts to Terms.

The idea is to first define Terms and Effects that operate on them, and then assign concrete values to the Terms—much like defining a mathematical formula and later substituting specific values for its variables.

This is the basic concept of Term.js.

API

createTerm

createTerm<T>(): Term<T>

The createTerm function is very simple.

const Count = createTerm<number>();

Count.set(0);

console.log(Count()); // 0

createEffect

createEffect(
    fn: () => (() => void) | void,
    dirtyCheckDeps: Term[],
    timingDeps: Term[]
): { dispose(): void }

An Effect takes three arguments.

The first argument is a function that defines the effect’s logic. This function may return a cleanup function, which will be executed before the effect is re-run.

The second argument is an array of Terms used to determine whether the effect should run. If any of these Terms is marked as dirty, the effect will be executed. A Term becomes dirty when its value is updated.

The third argument is an array of Terms that determine the timing of execution. The effect will run in response to changes in any of these Terms.

const Created = createTerm<{}>();
const Position = createTerm<{ x: number; y: number }>();
const AnimationFrame = createTerm<{ delta: number }>();

createEffect(
  () => {
    const position = Position();
    const frame = AnimationFrame();

    Position.set({
      x: position.x + frame.delta,
      y: position.y + frame.delta,
    });
  },
  // Only when position is dirty
  [Position],
  // Execute per animation frame
  [AnimationFrame],
);

createEffect(
  () => {
    let now = performance.now();
    let animationId = requestAnimationFrame(setFrame);
    function setFrame() {
      const next = performance.now();
      AnimationFrame.set({
        delta: next - now,
      });
      now = next;
      animationId = requestAnimationFrame(setFrame);
    }

    return () => {
      cancelAnimationFrame(animationId);
    };
  },
  [Created],
  [Created],
);

Position.set({
  x: 0,
  y: 0,
});
Created.set({});

In the above example, the Created term is used only to trigger the initialization effect.

You can dispose of an effect by calling the dispose method on the object returned by createEffect.

const effect = createEffect(() => {
    return () => {};
});

effect.dispose();

When an effect is disposed, its cleanup function is also executed.