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

@pixxl-tools/compare

v0.1.0

Published

Text and image comparison helpers for Pixxl tools.

Readme

@pixxl-tools/compare

Text and image comparison utilities for Pixxl apps.

@pixxl-tools/compare is a pre-1.0 public package. It exposes pure browser-safe helpers for text diffs, image pixel comparison, and browser image loading. It does not expose a server endpoint and does not persist user input.

Quick Start

import { compareText } from "@pixxl-tools/compare/text";

const result = compareText({
  firstText: "Pixxl tools\nCompare text",
  secondText: "Pixxl tools\nCompare documents",
  granularity: "word",
});

console.log(result.stats.similarity);

Image comparison works on decoded RGBA buffers:

import { compareImageData } from "@pixxl-tools/compare/image";

const black = new Uint8ClampedArray([0, 0, 0, 255]);
const white = new Uint8ClampedArray([255, 255, 255, 255]);

const result = compareImageData({
  firstImage: { data: black, width: 1, height: 1 },
  secondImage: { data: white, width: 1, height: 1 },
  calculateClusters: true,
});

Install/CSS

Install the package:

pnpm add @pixxl-tools/compare

No CSS import is required. The helpers run without React.

Public API

  • @pixxl-tools/compare: root export for text and image utilities.
  • @pixxl-tools/compare/text: compareText, side-by-side rows, inline spans, scroll indicators, and text diff types.
  • @pixxl-tools/compare/image: compareImageData, difference points, difference clusters, and pixel buffer types.
  • @pixxl-tools/compare/browser: browser image decoding helpers for file and URL based workflows.

Model/Persistence

Inputs are transient values supplied by the caller.

  • Text APIs accept strings and return diff rows plus similarity stats.
  • Image APIs accept RGBA Uint8Array or Uint8ClampedArray data with width and height.
  • JSON cannot carry typed arrays directly; encode buffers at transport boundaries and recreate typed arrays before comparison.
  • The package does not store files, text, pixels, or comparison history.

Examples

Runnable examples:

  • examples/compare/text-hello.ts
  • examples/compare/image-hello.ts

Website examples:

  • website/src/components/tools/TextComparePlayground.tsx
  • website/src/components/tools/ImageComparePlayground.tsx

Testing

Relevant checks:

pnpm test
node scripts/check-docs.mjs
node scripts/check-public-api.mjs

Limits

  • Text diff cost grows with input size and selected granularity.
  • Image comparison samples the shared visible area when dimensions differ.
  • Difference clusters are emitted only when calculateClusters is true.
  • Browser decoding helpers require browser image APIs; core text/image utilities do not.

Troubleshooting

  • If image comparison throws, verify data.length >= width * height * 4.
  • If JSON transport loses image data, rebuild a typed array before calling compareImageData.
  • If text diffs look too noisy, try ignoreWhitespace, ignoreCase, or a coarser granularity.

Migration/Versioning

Keep result shapes additive until a publish migration plan exists. Runtime normalization options should default conservatively so existing callers keep the same comparison behavior.