NPM.PackageLock (NPM v0.6.0)

Copy Markdown View Source

Reads and analyzes npm's package-lock.json format.

Supports lockfileVersion 1, 2, and 3 for compatibility with projects migrating from npm.

Summary

Functions

Returns metadata about the lockfile.

Counts the total number of packages in the lockfile.

Extracts package names and versions.

Reads a package-lock.json file.

Checks if the lockfile requires npm 7+ (v2/v3 format).

Detects the lockfile version.

Functions

metadata(data)

@spec metadata(map()) :: map()

Returns metadata about the lockfile.

package_count(arg1)

@spec package_count(map()) :: non_neg_integer()

Counts the total number of packages in the lockfile.

packages(arg1)

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

Extracts package names and versions.

read(path)

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

Reads a package-lock.json file.

requires_npm7?(data)

@spec requires_npm7?(map()) :: boolean()

Checks if the lockfile requires npm 7+ (v2/v3 format).

version(arg1)

@spec version(map()) :: 1 | 2 | 3 | nil

Detects the lockfile version.