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

@dgkit/signal-history

v0.2.0

Published

Undo/redo history for Angular signals, with grouped transactions.

Readme

@dgkit/signal-history

Undo/redo for Angular signals. Attach history to any WritableSignal and get undo(), redo(), canUndo(), canRedo() — all signals, so they drop straight into templates and computed()s.

Useful for editors, dashboards, configuration screens, drag-and-drop builders, filters and complex forms.

  • ✅ Works with any existing WritableSignal — no wrapper type to adopt
  • ✅ Grouped transactions — many writes, one undo step
  • Debounce mode — coalesce keystrokes into one entry
  • ✅ Bounded memory via limit
  • ✅ Custom equality — ignore structurally identical values
  • ✅ Automatic teardown with the injection context

Installation

pnpm add @dgkit/signal-history

Compatibility

Works with Angular 18, 19, 20 and 21.

| Peer dependency | Supported range | | ----------------- | -------------------- | | @angular/core | >=18.0.0 <22.0.0 | | @angular/common | >=18.0.0 <22.0.0 | | rxjs | ^6.5.3 or ^7.4.0 |

Angular and RxJS are peer dependencies — never bundled into the package.

Quick start

import { signal } from '@angular/core';
import { signalHistory } from '@dgkit/signal-history';

const document = signal(initialDocument);

const history = signalHistory(document, {
  limit: 50,
  debounce: 300,
});

history.undo();
history.redo();
history.canUndo(); // Signal<boolean>
history.canRedo(); // Signal<boolean>
history.reset();

In a component:

@Component({
  standalone: true,
  template: `
    <button (click)="history.undo()" [disabled]="!history.canUndo()">
      Undo
    </button>
    <button (click)="history.redo()" [disabled]="!history.canRedo()">
      Redo
    </button>
  `,
})
export class Editor {
  protected readonly doc = signal({ title: '', description: '' });
  protected readonly history = signalHistory(this.doc, { debounce: 300 });
}

Transactions

Group several writes into a single undoable step:

history.transaction(() => {
  document.update(updateTitle);
  document.update(updateDescription);
});

history.undo(); // reverts both at once

Transactions nest — only the outermost one commits an entry — and the depth is restored even if the callback throws.

API

const history = signalHistory(source, options?);

history.undo();
history.redo();
history.canUndo();   // Signal<boolean>
history.canRedo();   // Signal<boolean>
history.reset();     // clear history, keep the current value
history.reset(value) // clear history and set a new baseline value
history.transaction(fn);
history.past();      // Signal<readonly T[]>  oldest first
history.future();    // Signal<readonly T[]>  next-to-redo first
history.destroy();   // stop tracking early (also automatic on destroy)

Options

| Option | Type | Default | Description | | ---------- | ------------------------- | ----------- | ----------------------------------------------------------------- | | limit | number | 100 | Max past entries; oldest dropped. 0/non-finite means unlimited. | | debounce | number | 0 | Coalesce changes arriving within this window into one entry. | | equal | (a: T, b: T) => boolean | Object.is | Decides whether a change is worth recording. |

Behavior details

How changes are observed

History watches the source with an effect. A burst of synchronous writes therefore collapses into a single entry naturally — the watcher sees the final value once per flush. Use transaction() when you need that grouping guaranteed regardless of flush timing.

Undo/redo/reset update the internal "current" marker before writing to the source, so history never re-records its own writes — this is timing-independent and doesn't rely on effect scheduling order.

Redo invalidation

Any new change clears the redo stack, matching standard editor semantics.

Memory

limit bounds the past stack. Values are stored by reference — if you mutate objects in place rather than replacing them, history will hold the same mutated reference. Prefer immutable updates (update(x => ({...x, …}))).

License

MIT