Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

is-package-latest

otoneko110214.5kMIT1.0.0

Check if a package is the latest version.

update, check, package, version

readme

is-package-latest

Check if a package is the latest version.

Install

npm install is-package-latest@latest

Usage

// CJS (require)
const { isPackageLatest } = require('is-package-latest');
const pkg = require("./package.json");
// ESM (import)
import { isPackageLatest } from 'is-package-latest';
import pkg from "./package.json" with { type: "json" };

(async () => {
  console.log(await isPackageLatest(pkg));
})();

API

Param

isPackageLatest(pkg)

  • pkg <Object> An object that has package information.
    • name <string> Required. The name of the package.
    • version <string> Required. The current version of the package.

Returns

The function returns a Promise.

Name Type Description
success boolean true if the check was successful.
name string The name of the package.
isLatest boolean true if the current version is the latest.
currentVersion string The current version from the pkg.
latestVersion string The latest version from the npm registry. Always null on failure.
error string Always null on success.