NPM.CacheStats (NPM v0.6.0)

Copy Markdown View Source

Provides statistics about the npm package cache.

Summary

Functions

Estimates cache size on disk.

Formats cache statistics for display.

Formats a byte size in human-readable form.

Computes cache hit/miss statistics for a lockfile.

Computes the hit rate as a percentage.

Lists cached packages with versions.

Functions

disk_size()

@spec disk_size() :: non_neg_integer()

Estimates cache size on disk.

format(stats)

@spec format(map()) :: String.t()

Formats cache statistics for display.

format_size(bytes)

@spec format_size(non_neg_integer()) :: String.t()

Formats a byte size in human-readable form.

hit_miss(lockfile)

@spec hit_miss(map()) :: %{
  hits: non_neg_integer(),
  misses: non_neg_integer(),
  total: non_neg_integer()
}

Computes cache hit/miss statistics for a lockfile.

hit_rate(lockfile)

@spec hit_rate(map()) :: float()

Computes the hit rate as a percentage.

list_cached()

@spec list_cached() :: [{String.t(), [String.t()]}]

Lists cached packages with versions.