Analyzes and deduplicates npm dependency trees.
Finds packages that appear multiple times in the lockfile (or could
be hoisted) and suggests which duplicates can be removed. This is the
logic behind mix npm.dedupe.
Summary
Functions
Finds the best version of a package that satisfies all dependents.
Counts package groups installed at multiple versions.
Finds packages installed at multiple versions.
Finds packages in the lockfile that could potentially be deduped.
Formats duplicate report for display.
Returns the number of extra package versions that dedupe could remove.
Calculates how many bytes could be saved by deduplication.
Returns a summary of the deduplication analysis.
Functions
@spec count(map()) :: non_neg_integer()
Counts package groups installed at multiple versions.
Finds packages installed at multiple versions.
Returns maps with the base package name and sorted distinct versions.
Finds packages in the lockfile that could potentially be deduped.
Returns a list of {name, versions} where versions is a list of
version strings for packages that appear in multiple forms.
Formats duplicate report for display.
@spec potential_savings([%{name: String.t(), versions: [String.t()]}]) :: non_neg_integer()
Returns the number of extra package versions that dedupe could remove.
@spec savings_estimate(map()) :: %{ packages: non_neg_integer(), duplicates: non_neg_integer() }
Calculates how many bytes could be saved by deduplication.
This is an estimate based on the number of duplicate package entries.
@spec summary(map()) :: %{ total_packages: non_neg_integer(), unique_packages: non_neg_integer(), duplicate_groups: non_neg_integer(), saveable: non_neg_integer() }
Returns a summary of the deduplication analysis.