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

@blazediff/matcher

v1.2.1

Published

Core matcher logic for visual regression testing with blazediff

Downloads

570

Readme

@blazediff/matcher

npm bundle size NPM Downloads

Core matcher logic for visual regression testing. Provides snapshot comparison with multiple algorithms, framework-agnostic APIs, and snapshot state tracking.

Features

  • Multiple comparison methods: core, bin, ssim, msssim, hitchhikers-ssim, gmsd
  • Flexible input types: File paths or image buffers
  • Snapshot state tracking: Reports added/matched/updated/failed status
  • Configurable thresholds: Pixel count or percentage-based
  • Framework-agnostic: Core logic for Jest, Vitest, Bun integrations
  • Rich comparison results: Diff counts, percentages, and similarity scores

Installation

npm install @blazediff/matcher

Quick Start

import { getOrCreateSnapshot } from '@blazediff/matcher';

const result = await getOrCreateSnapshot(
  imageBuffer, // or file path
  {
    method: 'core',
    failureThreshold: 0.01,
    failureThresholdType: 'percent',
  },
  {
    testPath: '/path/to/test.spec.ts',
    testName: 'should render correctly',
  }
);

console.log(result.pass); // true/false
console.log(result.snapshotStatus); // 'added' | 'matched' | 'updated' | 'failed'
console.log(result.diffPercentage); // e.g., 0.05

API Reference

getOrCreateSnapshot(received, options, testContext)

Main function for snapshot comparison.

Returns: Promise<ComparisonResult>

MatcherOptions

ComparisonResult

ImageInput

type ImageInput =
  | string // File path
  | {
      data: Uint8Array | Uint8ClampedArray | Buffer;
      width: number;
      height: number;
    };

Comparison Methods

bin

Rust-native comparison via N-API bindings. Fastest method with native performance.

  • Input: File paths only
  • Algorithm: YIQ color space with block-based optimization
  • Best for: Production testing, large images

core

Pixel-by-pixel comparison in JavaScript. Pure JS implementation with no native dependencies.

  • Input: File paths or buffers
  • Algorithm: YIQ color space with anti-aliasing detection
  • Best for: Cross-platform compatibility

ssim

Structural Similarity Index. Measures perceptual similarity.

  • Input: File paths or buffers
  • Algorithm: Standard SSIM with configurable window size
  • Best for: Perceptual quality assessment
  • Score: 1 = identical, lower = more different

msssim

Multi-Scale Structural Similarity Index.

  • Input: File paths or buffers
  • Algorithm: SSIM across multiple scales
  • Best for: Images with varying resolutions or scales

hitchhikers-ssim

Fast SSIM approximation from Hitchhiker's Guide.

  • Input: File paths or buffers
  • Algorithm: Optimized SSIM calculation
  • Best for: Faster SSIM with acceptable accuracy trade-off

gmsd

Gradient Magnitude Similarity Deviation.

  • Input: File paths or buffers
  • Algorithm: Gradient-based perceptual similarity
  • Best for: Detecting structural changes
  • Score: 0 = identical, higher = more different

Usage Examples

With File Paths

const result = await getOrCreateSnapshot(
  '/path/to/screenshot.png',
  { method: 'bin' },
  { testPath: __filename, testName: 'test name' }
);

With Image Buffers

const imageData = {
  data: new Uint8Array([...]),
  width: 800,
  height: 600,
};

const result = await getOrCreateSnapshot(
  imageData,
  { method: 'core' },
  { testPath: __filename, testName: 'test name' }
);

Custom Threshold

const result = await getOrCreateSnapshot(
  imagePath,
  {
    method: 'core',
    failureThreshold: 0.1,
    failureThresholdType: 'percent', // Allow 0.1% difference
  },
  { testPath: __filename, testName: 'test name' }
);

Different Comparison Methods

// Fastest - Rust native (file paths only)
await getOrCreateSnapshot(imagePath, { method: 'bin' }, context);

// Pure JavaScript
await getOrCreateSnapshot(imageBuffer, { method: 'core' }, context);

// Perceptual similarity
await getOrCreateSnapshot(imageBuffer, { method: 'ssim' }, context);

// Gradient-based
await getOrCreateSnapshot(imageBuffer, { method: 'gmsd' }, context);

Framework Integrations

This package provides the core logic for framework-specific integrations:

Links