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

@ferrow/conflict-resolver

v2.0.0

Published

Field-level 3-way merge for offline-first sync: auto-merges non-conflicting field changes, resolves true conflicts via lastWrite/preferLocal/preferRemote/custom strategies, and reports every conflict and how it was resolved. Zero runtime dependencies.

Readme

conflict-resolver

CI

Field-level 3-way merge for offline-first sync, in TypeScript/Node. Given a common ancestor (base) and two divergent copies (local, remote), merge() auto-merges fields changed on only one side, resolves true conflicts (both sides changed the same field to different values) with a configurable strategy, and returns both the merged object and a list of every conflict with how it was resolved. Zero runtime dependencies.

Install

Copy src/index.ts into your project, or build this repo (npm run build) and depend on the compiled dist/.

Quickstart

import { merge } from 'conflict-resolver';

const { merged, conflicts } = merge(base, local, remote, {
  strategy: 'lastWrite',
  timestamps: {
    local: { title: 1000 },
    remote: { title: 2000 },
  },
});
  • Fields unchanged on both sides pass through from base.
  • Fields changed on only one side pass through from whichever side changed.
  • Fields changed identically on both sides merge with no reported conflict.
  • Fields changed differently on both sides are conflicts: resolved per strategy and pushed onto conflicts.

API

merge<T>(base: T, local: T, remote: T, options?: MergeOptions): { merged: T; conflicts: Conflict[] }

MergeOptions:

  • strategy?: 'lastWrite' | 'preferLocal' | 'preferRemote' — default strategy for scalar-field conflicts (default 'lastWrite').
  • fieldStrategies?: Record<string, FieldStrategy | CustomResolver> — per-field override, either a named strategy or ({ field, base, local, remote }) => resolvedValue.
  • timestamps?: { local?: Record<string, number>; remote?: Record<string, number> } — per-field epoch-ms timestamps used by 'lastWrite'. If only one side has a timestamp for a field, that side wins; if neither does, remote wins (treated as the later write).
  • arrayStrategy?: 'union' | 'concat' | 'replace' — how to merge a field whose base/local/remote values are all arrays (default 'union'): union keeps items present in local or remote (dedup by deep-equality, base-only-removed items dropped); concat appends remote items not already in local; replace picks whichever side actually changed from base (remote if both did).
  • fieldArrayStrategies?: Record<string, ArrayStrategy> — per-field array strategy override.

Each Conflict is { field, base, local, remote, resolved, resolution } where resolution is 'local' | 'remote' | 'custom' | 'array-merge'.

Scope and limits

  • Field-level, one level deep — nested objects are compared and merged as opaque values (deep-equal for change detection), not recursively merged field-by-field. Flatten nested state yourself first if you need per-nested-field resolution.
  • 'lastWrite' needs you to supply timestamps; it does not read or infer wall-clock time itself.
  • Array union/concat dedupe by deep equality, which is O(n·m) per field — fine for typical sync payloads, not built for huge arrays.
  • This is a merge algorithm, not a sync transport — it doesn't fetch base/local/remote for you or persist the result.

Sponsored by Ferrow


Part of the ferrow-toolkit collection · Sponsored by Ferrow