NPM.Fund (NPM v0.6.0)

Copy Markdown View Source

Discovers and aggregates funding information from installed packages.

Reads the funding field from package manifests to help users support open source maintainers.

Summary

Functions

Collects funding info from all packages in a node_modules directory.

Extracts funding info from a package.json data map.

Groups funding entries by funding URL.

Returns a summary of funding information.

Types

funding_info()

@type funding_info() :: %{
  package: String.t(),
  version: String.t(),
  type: String.t() | nil,
  url: String.t()
}

Functions

collect(node_modules_dir)

@spec collect(String.t()) :: [funding_info()]

Collects funding info from all packages in a node_modules directory.

extract(data)

@spec extract(map()) :: [funding_info()]

Extracts funding info from a package.json data map.

The funding field can be a string (URL), a map with type and url, or a list of such entries.

group_by_url(entries)

@spec group_by_url([funding_info()]) :: %{required(String.t()) => [funding_info()]}

Groups funding entries by funding URL.

summary(entries)

@spec summary([funding_info()]) :: %{
  packages_with_funding: non_neg_integer(),
  unique_urls: non_neg_integer(),
  types: [String.t()]
}

Returns a summary of funding information.