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

@vaagatech/snapline-engine

v0.2.5

Published

Deep data reconciliation engine for declarative snapshot testing — field stripping, transforms, and structural mapping

Readme

@vaagatech/snapline-engine

Deep JSON comparison engine for declarative snapshot testing.

npm version License: MIT

Install

npm install @vaagatech/snapline-engine

Supports ESM, CommonJS, and TypeScript out of the box.

When to use

Use @vaagatech/snapline-engine when you need to:

  • Compare API responses or database rows against JSON golden files
  • Ignore fields that change every run (pincode, transaction IDs, internal metadata)
  • Normalize timestamps, UUIDs, or other dynamic values before diffing
  • Map equivalent values across systems (ABC in DB-A → CBA in DB-B)

Quick demo

ESM

Save as snapline-demo.mjs and run with node snapline-demo.mjs.

import { snapline, assertAgainstFile } from '@vaagatech/snapline-engine';
import { writeFileSync } from 'node:fs';

// --- Live response from your API (dynamic fields included) ---
const liveResponse = {
  id: 'usr_001',
  email: '[email protected]',
  status: 'synced',
  currentdate: new Date().toISOString(),
  pincode: '482910',
};

// --- Expected fixture (pre-normalized values) ---
const expected = {
  id: 'usr_001',
  email: '[email protected]',
  status: 'synced',
  currentdate: 'VALID_DATE',
};

const result = snapline(liveResponse, expected, {
  ignoreFields: ['pincode'],
  transformations: {
    currentdate: (value) =>
      typeof value === 'string' && !Number.isNaN(Date.parse(value))
        ? 'VALID_DATE'
        : 'INVALID_DATE',
  },
});

console.log(result.match ? 'PASS' : 'FAIL');
console.log(result.diff ?? 'No differences');

// --- File-based assertion ---
writeFileSync('./expected-output.json', JSON.stringify(expected, null, 2));

const fileResult = assertAgainstFile(liveResponse, './expected-output.json', {
  ignoreFields: ['pincode'],
  transformations: {
    currentdate: (value) =>
      typeof value === 'string' && !Number.isNaN(Date.parse(value))
        ? 'VALID_DATE'
        : 'INVALID_DATE',
  },
});

console.log(fileResult.match ? 'File assertion PASS' : 'File assertion FAIL');

CommonJS

const { snapline } = require('@vaagatech/snapline-engine');

const result = snapline(
  { id: 1, updatedAt: '2026-07-04T10:00:00Z', traceId: 'abc' },
  { id: 1, updatedAt: 'VALID_DATE' },
  {
    ignoreFields: ['traceId'],
    transformations: {
      updatedAt: (v) =>
        typeof v === 'string' && !Number.isNaN(Date.parse(v))
          ? 'VALID_DATE'
          : 'INVALID_DATE',
    },
  },
);

console.log(result.match);

API reference

snapline(liveData, expectedData, options?)

Full pipeline: strip ignored fields → apply transformations → apply data mapping → compare.

| Option | Type | Description | |--------|------|-------------| | ignoreFields | string[] | Field names or dot-paths to exclude (e.g. ['pincode', 'meta.requestId']) | | transformations | Record<string, Function> | Per-field functions applied to live data only | | dataMapping | Record<string, object \| Function> | Value lookup tables or mappers applied to live data only |

Returns: { match, processed, expected, diff }

assertAgainstFile(liveData, expectedFilePath, options?)

Loads a JSON fixture from disk and runs snapline.

Standalone utilities

| Function | Purpose | |----------|---------| | stripFields(data, ignoreFields) | Remove ignored fields recursively | | applyTransformations(data, transformations) | Run field transformers | | applyDataMapping(data, dataMapping) | Apply cross-system value maps | | compareObjects(actual, expected) | Deep structural compare | | diffValues(actual, expected) | Return first diff or null | | loadJsonFile(path) | Read and parse a JSON fixture | | deepClone(value) | JSON-safe deep clone | | isPlainObject(value) | Plain object type guard | | stableStringify(value) | Deterministic JSON string |

Configuration patterns

Ignore dynamic fields

ignoreFields: ['pincode', 'transactionId', 'response.headers.date']

Normalize timestamps

const transformations = {
  createdAt: (value) =>
    typeof value === 'string' && !Number.isNaN(Date.parse(value))
      ? 'VALID_DATE'
      : 'INVALID_DATE',
  updatedAt: (value) =>
    typeof value === 'string' && !Number.isNaN(Date.parse(value))
      ? 'VALID_DATE'
      : 'INVALID_DATE',
};

Expected fixtures should already contain normalized values (VALID_DATE), not raw ISO strings.

Cross-database status mapping

const dataMapping = {
  status: {
    ABC: 'CBA',
    PENDING: 'IN_PROGRESS',
  },
};

Functional mapping:

const dataMapping = {
  status: (value) => (value === 'ABC' ? 'CBA' : value),
};

TypeScript

Full types are exported:

import {
  snapline,
  type SnaplineOptions,
  type SnaplineResult,
  type DiffResult,
} from '@vaagatech/snapline-engine';

Module formats

| Import style | Entry | Types | |--------------|-------|-------| | ESM import | dist/index.js | dist/index.d.ts | | CJS require | dist/index.cjs | dist/index.d.cts |

Requirements

  • Node.js 18+

Examples

Runnable examples ship with the package:

npm install @vaagatech/snapline-engine
node node_modules/@vaagatech/snapline-engine/examples/basic-snapline.mjs

Or from a cloned monorepo:

npm run build
node packages/snapline/examples/basic-snapline.mjs

Documentation

https://vaagatech.github.io/snapline/ · Python edition · Snapline Hub

Related packages

| Package | Role | |---------|------| | @vaagatech/snapline-core | Full test orchestration DSL | | @vaagatech/snapline-auth-adapters | OAuth2, OpenID, Basic Auth |

License

MIT — free to use, modify, distribute, fork, and contribute.


Built by VaagaTech.