# `NPM.Lockfile`
[🔗](https://github.com/elixir-volt/npm_ex/blob/v0.7.3/lib/npm/lockfile.ex#L1)

Read and write `npm.lock` lockfile.

The lockfile records resolved versions, integrity hashes, and dependency
relationships to ensure reproducible installs.

# `entry`

```elixir
@type entry() :: %{
  version: String.t(),
  integrity: String.t(),
  tarball: String.t(),
  dependencies: %{required(String.t()) =&gt; String.t()},
  optional_dependencies: %{required(String.t()) =&gt; String.t()},
  has_install_script: boolean()
}
```

# `t`

```elixir
@type t() :: %{required(String.t()) =&gt; entry()}
```

# `current_policy`

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

Return the effective lockfile security policy for new locks.

# `default_path`

```elixir
@spec default_path() :: String.t()
```

Return the default npm_ex lockfile path.

# `get_package`

```elixir
@spec get_package(String.t(), String.t()) :: {:ok, entry()} | :error
```

Get a single package entry from the lockfile.

# `has_package?`

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

Check if a specific package is in the lockfile.

# `package_names`

```elixir
@spec package_names(String.t()) :: {:ok, [String.t()]} | {:error, term()}
```

List all package names in the lockfile.

# `parse_packages`

```elixir
@spec parse_packages(map()) :: t()
```

Parse a raw packages map into lockfile entries.

# `policy_matches?`

```elixir
@spec policy_matches?(map() | nil) :: boolean()
```

Whether a recorded lockfile policy is compatible with current settings.

# `read`

```elixir
@spec read(String.t()) :: {:ok, t()} | {:error, term()}
```

Read the lockfile. Returns empty map if it doesn't exist.

# `read_policy`

```elixir
@spec read_policy(String.t()) :: {:ok, map() | nil} | {:error, term()}
```

Read the security policy recorded in the lockfile.

# `version`

```elixir
@spec version(String.t()) :: integer() | nil
```

Get the lockfile version from a file.

# `write`

```elixir
@spec write(t(), String.t()) :: :ok | {:error, term()}
```

Write the lockfile.

---

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