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

@oh-just-another/history

v0.57.4

Published

Undo/redo kernel: transactional, invertible patch stacks over a Scene.

Readme

@oh-just-another/history

npm version

Undo / redo kernel: transactional, invertible patch stacks for @oh-just-another/scene.

L1 pure logic — no DOM, no Node API. Depends only on @oh-just-another/types and @oh-just-another/scene. The class owns no scene; callers push patches and apply the returned inverse / replay patches themselves, so the same instance drives an interactive editor, a headless replay, or a server-side audit log.

Quick start

import { History } from "@oh-just-another/history";
import { apply } from "@oh-just-another/scene";

const history = new History({ limit: 100 });

// Single op
history.push(patch);
scene = apply(scene, history.undo()!); // returns the inverse to apply
scene = apply(scene, history.redo()!); // re-apply the original

// Gesture: many patches → one undo step
const tx = history.transaction();
for (const p of dragPatches) tx.add(p);
tx.commit(); // merged per entity: 100 moves of one shape collapse to 1

API

| Name | Purpose | | ------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | new History(options?) | Construct. options.limit (default Infinity), options.mergeTransactions (default true). | | push(patch) | Append. Clears the redo stack. No-ops are skipped. | | undo() / redo() | Return the patch to apply (inverse for undo), or null if empty. Moves the record onto the other stack. | | canUndo / canRedo / size / redoSize | Stack introspection. | | clear() | Drop both stacks. | | transaction() | Open a transaction. Returns { add, commit, cancel, isOpen }. | | hasOpenTransaction() | True between transaction() and commit/cancel(). | | record(patch, { transaction? }) | Route through a given open transaction, or push directly. | | mergeByEntity(patches) | Standalone helper: collapses a patch list per entity (first.before / latest.after). Used internally too. | | describe(patch) | Human-readable label for a patch (e.g. for undo/redo menu text). |

Design notes

  • History owns no scene. Returning patches (not applying them) keeps the class trivial to test, lets the host integrate with any state container, and makes the same instance reusable for offline replay.
  • undo() returns the inverse patch; redo() returns the original. That is the form callers need at the application site.
  • Transactions merge per entity by default. A 100-tick drag of one shape becomes one undo record with before = shape-at-press, after = shape-at-up. Disable for debug logs that want every intermediate state.
  • Selection should not be a patch. Selection is conventionally excluded from undo. The kernel doesn't enforce it — just don't push selection-only changes.