NPM.LockMerge (NPM v0.6.0)

Copy Markdown View Source

Merge two lockfiles, preferring entries from the newer lockfile.

Used for workspace scenarios where multiple package.json files produce separate lockfiles that need to be combined.

Summary

Functions

Find packages that differ between two lockfiles.

Merge two lockfiles. Entries in newer override entries in base.

Merge with a custom conflict resolver.

Functions

diff(base, newer)

@spec diff(NPM.Lockfile.t(), NPM.Lockfile.t()) ::
  {[String.t()], [String.t()], [{String.t(), String.t(), String.t()}]}

Find packages that differ between two lockfiles.

Returns {added, removed, changed} where:

  • added — packages in newer but not base
  • removed — packages in base but not newer
  • changed — packages in both with different versions

merge(base, newer)

Merge two lockfiles. Entries in newer override entries in base.

Returns the merged lockfile map.

merge(base, newer, resolver)

Merge with a custom conflict resolver.

The resolver function receives (name, base_entry, newer_entry) and returns the winning entry.