# `NPM.Dependency.Peer`
[🔗](https://github.com/elixir-volt/npm_ex/blob/v0.7.4/lib/npm/dependency/peer.ex#L1)

Analyzes and validates peer dependency declarations.

Peer dependencies declare that a package expects the consumer to provide a
compatible version of another package. This module extracts peer dependency
metadata from package manifests, distinguishes required and optional peers,
checks lockfiles for satisfaction, and formats peer warnings for reports.

# `warning`

```elixir
@type warning() :: %{
  package: String.t(),
  peer: String.t(),
  required: String.t(),
  found: String.t() | nil,
  satisfied: boolean()
}
```

# `check`

```elixir
@spec check(map(), [map()]) :: [warning()]
```

Check peer dependency satisfaction for a list of package manifests.

# `count_across`

```elixir
@spec count_across([map()]) :: non_neg_integer()
```

Count total peer dependency declarations across packages.

# `extract`

```elixir
@spec extract(map()) :: map()
```

Extract peer dependencies from package manifest data.

# `format_warnings`

```elixir
@spec format_warnings([warning()]) :: [String.t()]
```

Format peer dependency warnings as human-readable strings.

# `meta`

```elixir
@spec meta(map()) :: map()
```

Extract raw `peerDependenciesMeta` data from package manifest data.

# `optional?`

```elixir
@spec optional?(String.t(), map()) :: boolean()
```

Check if a peer dependency is marked as optional.

# `optional_peers`

```elixir
@spec optional_peers(map()) :: MapSet.t()
```

Return the peer dependency names marked as optional.

# `required`

```elixir
@spec required(map()) :: map()
```

Return required, non-optional peer dependencies.

# `satisfied?`

```elixir
@spec satisfied?(map(), map()) :: boolean()
```

Check if all required peers are satisfied by a lockfile.

# `summary`

```elixir
@spec summary([warning()]) :: %{
  satisfied: non_neg_integer(),
  missing: non_neg_integer(),
  incompatible: non_neg_integer()
}
```

Summarize peer dependency warnings for display.

# `unsatisfied`

```elixir
@spec unsatisfied(map(), map()) :: [{String.t(), String.t(), String.t() | nil}]
```

List required peer dependencies not satisfied by a lockfile.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
