Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

latest-version

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

latest-version - npm Package Compare versions

Comparing version 8.0.0 to 9.0.0

17

index.d.ts

@@ -1,8 +0,7 @@

export type Options = {
/**
A semver range or [dist-tag](https://docs.npmjs.com/cli/dist-tag).
*/
readonly version?: string;
};
import type {Options as PackageJsonOptions} from 'package-json';
export {PackageNotFoundError, VersionNotFoundError} from 'package-json';
export type Options = Pick<PackageJsonOptions, 'version' | 'registryUrl' | 'omitDeprecated'>;
/**

@@ -16,12 +15,12 @@ Get the latest version of an npm package.

console.log(await latestVersion('ava'));
//=> '0.18.0'
//=> '6.1.1'
console.log(await latestVersion('@sindresorhus/df'));
//=> '1.0.1'
//=> '4.0.0'
// Also works with semver ranges and dist-tags
console.log(await latestVersion('npm', {version: 'latest-5'}));
//=> '5.5.1'
//=> '5.10.0'
```
*/
export default function latestVersion(packageName: string, options?: Options): Promise<string>;
import packageJson from 'package-json';
export {PackageNotFoundError, VersionNotFoundError} from 'package-json';
export default async function latestVersion(packageName, options) {

@@ -4,0 +6,0 @@ const {version} = await packageJson(packageName.toLowerCase(), options);

{
"name": "latest-version",
"version": "8.0.0",
"version": "9.0.0",
"description": "Get the latest version of an npm package",

@@ -40,11 +40,11 @@ "license": "MIT",

"dependencies": {
"package-json": "^9.0.0"
"package-json": "^10.0.0"
},
"devDependencies": {
"ava": "^6.1.0",
"semver": "^7.5.4",
"ava": "^6.1.1",
"semver": "^7.6.0",
"semver-regex": "^4.0.5",
"tsd": "^0.30.4",
"xo": "^0.56.0"
"tsd": "^0.30.7",
"xo": "^0.57.0"
}
}

@@ -19,12 +19,14 @@ # latest-version

console.log(await latestVersion('ava'));
//=> '0.18.0'
//=> '6.1.1'
console.log(await latestVersion('@sindresorhus/df'));
//=> '1.0.1'
//=> '4.0.0'
// Also works with semver ranges and dist-tags
console.log(await latestVersion('npm', {version: 'latest-5'}));
//=> '5.5.1'
//=> '5.10.0'
```
This package exposes the [`version`](https://github.com/sindresorhus/package-json#version), [`registryUrl`](https://github.com/sindresorhus/package-json#registryurl), and [`omitDeprecated`](https://github.com/sindresorhus/package-json#omitdeprecated) options from [`package-json`](https://github.com/sindresorhus/package-json#options), as well as the [`PackageNotFoundError`](https://github.com/sindresorhus/package-json#packagenotfounderror) and [`VersionNotFoundError`](https://github.com/sindresorhus/package-json#versionnotfounderror) errors.
## Related

@@ -31,0 +33,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc