NPM.Stats (NPM v0.6.0)

Copy Markdown View Source

Collects statistics about the project's npm dependencies.

Provides aggregate insights: package counts, version freshness, dependency types, maintainer diversity, etc.

Summary

Functions

Computes statistics from a lockfile and root dependencies.

Returns the dependency-to-package ratio (how connected the graph is).

Finds the most depended-upon packages (highest fan-in).

Computes version distribution across the lockfile.

Types

project_stats()

@type project_stats() :: %{
  total_packages: non_neg_integer(),
  direct_deps: non_neg_integer(),
  transitive_deps: non_neg_integer(),
  with_install_scripts: non_neg_integer(),
  avg_dep_count: float(),
  max_dep_chain: non_neg_integer(),
  scoped_packages: non_neg_integer()
}

Functions

compute(lockfile, root_deps)

@spec compute(map(), map()) :: project_stats()

Computes statistics from a lockfile and root dependencies.

connectivity(lockfile)

@spec connectivity(map()) :: float()

Returns the dependency-to-package ratio (how connected the graph is).

most_depended(lockfile, n \\ 10)

@spec most_depended(map(), non_neg_integer()) :: [{String.t(), non_neg_integer()}]

Finds the most depended-upon packages (highest fan-in).

version_distribution(lockfile)

@spec version_distribution(map()) :: %{required(String.t()) => non_neg_integer()}

Computes version distribution across the lockfile.

Returns a map of major version buckets.