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 🙏

© 2025 – Pkg Stats / Ryan Hefner

deltadom

v1.0.3

Published

Execute client-side the results generated server-side by DeltaDOM

Downloads

6

Readme

DeltaDOM

Maven NPM Tests

DeltaDOM small, fast Java library for finding the differences between two HTML documents. This is primarily useful for web applications employing server-side rendering that want to push changes to the browser.

Usage

First you will need to add DeltaDOM to your project. If you are using Gradle, you will need to add the following dependencies to your build.gradle file:

dependencies {
    implementation group: "com.leaprnd.deltadom", name: "core", version: "1.0.3"
}

Once that is done, you can use DeltaDOM to find the differences between any two HTML documents.

Consider the following verbose example:

package com.example;

import org.w3c.dom.Document;
import com.leaprnd.deltadom.DeltaDOM;
import com.leaprnd.deltadom.json.JSONDifferenceHandler;
import org.xml.sax.InputSource;

import javax.xml.parsers.DocumentBuilderFactory;

import java.io.StringReader;

import static com.leaprnd.deltadom.matching.NodeMatches.between;

public class Example {

	private static final String BEFORE_HTML = """
			<html>
				<body>
					<h1>Table of Prices</h1>
					<p>Here is our list of prices, as of <time>June 21, 2021</time></p>
					<table>
						<thead>
							<tr>
								<th scope="col">Feature</th>
								<th scope="col">Price</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th scope="row">Widget</th>
								<td>12.99</td>
							</tr>
							<tr>
								<th scope="row">Gizmo</th>
								<td>9.99</td>
							</tr>
							<tr>
								<th scope="row">Gadget</th>
								<td>10.99</td>
							</tr>
							<tr>
								<th scope="row">Thingamabob</th>
								<td>4.99 <strong>Sale!</strong></td>
							</tr>
							<tr>
								<th scope="row">Thingamajig</th>
								<td>6.99</td>
							</tr>
						</tbody>
					</table>
				</body>
			</html>
			""";

	private static final String AFTER_HTML = """
			<html>
				<body>
					<h1>Table of Prices</h1>
					<p>Here is our list of prices, as of <time>December 22, 2021</time></p>
					<table>
						<thead>
							<tr>
								<th scope="col">Feature</th>
								<th scope="col">Price</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th scope="row">Widget</th>
								<td>13.99</td>
							</tr>
							<tr>
								<th scope="row">Gizmo</th>
								<td>9.99</td>
							</tr>
							<tr>
								<th scope="row">Gadget</th>
								<td>10.99</td>
							</tr>
							<tr>
								<th scope="row">Thingamabob</th>
								<td>6.99</td>
							</tr>
							<tr>
								<th scope="row">Thingamajig</th>
								<td>4.99 <strong>Sale!</strong></td>
							</tr>
						</tbody>
					</table>
				</body>
			</html>
			""";

	public static void main(String ... arguments) throws Exception {
		final var before = parse(BEFORE_HTML);
		final var after = parse(AFTER_HTML);
		final var nodeMatches = between(before, after);
		try (final var json = new JSONDifferenceHandler(System.out)) {
			new DeltaDOM<>(before, after, nodeMatches, json).find();
		}
	}

	private static Document parse(String html) throws Exception {
		final var factory = DocumentBuilderFactory.newInstance();
		final var reader = new StringReader(html);
		final var source = new InputSource(reader);
		return factory.newDocumentBuilder().parse(source);
	}

}

When runned, the above class will output the difference between BEFORE_HTML and AFTER_HTML as a JSON array of operations:

[
    [4,"html>body>p>time",0,"December 22, 2021"],
    [6,"html>body>table>tbody>tr:last-of-type>td","html>body>table>tbody>tr:nth-of-type(4)",3],
    [5,"html>body>table>tbody>tr:last-of-type",3,"html>body>table>tbody>tr:nth-of-type(4)",4],
    [6,"html>body>table>tbody>tr:nth-of-type(4)>td:last-of-type","html>body>table>tbody>tr:last-of-type",3],
    [5,"html>body>table>tbody>tr:nth-of-type(4)",5,"html>body>table>tbody>tr:last-of-type",4],
    [4,"html>body>table>tbody>tr:first-of-type>td",0,"13.99"],
    [0,"html>body>table>tbody>tr:first-of-type>td",1],
    [0,"html>body>p>time",1]
]

You can install the client-side logic for executing these operations via NPM:

npm install deltadom

After which you can import the execute function into your project.

import {execute} from "deltadom";

It's up to you to somehow get the array of commands from the server to the browser, but either an EventSource or a WebSocket should do the trick.