[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nindent_style = tab\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n\n[*.yml]\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n"
  },
  {
    "path": ".github/security.md",
    "content": "# Security Policy\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: CI\non:\n  - push\n  - pull_request\njobs:\n  test:\n    name: Node.js ${{ matrix.node-version }}\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        node-version:\n          - 21\n          - 20\n          - 18\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions/setup-node@v4\n        with:\n          node-version: ${{ matrix.node-version }}\n      - run: npm install\n      - run: npm test\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nyarn.lock\n"
  },
  {
    "path": ".npmrc",
    "content": "package-lock=false\n"
  },
  {
    "path": "index.d.ts",
    "content": "import type {Options as PackageJsonOptions} from 'package-json';\n\nexport {PackageNotFoundError, VersionNotFoundError} from 'package-json';\n\nexport type Options = Pick<PackageJsonOptions, 'version' | 'registryUrl' | 'omitDeprecated'>;\n\n/**\nGet the latest version of an npm package.\n\n@example\n```\nimport latestVersion from 'latest-version';\n\nconsole.log(await latestVersion('ava'));\n//=> '6.1.1'\n\nconsole.log(await latestVersion('@sindresorhus/df'));\n//=> '4.0.0'\n\n// Also works with semver ranges and dist-tags\nconsole.log(await latestVersion('npm', {version: 'latest-5'}));\n//=> '5.10.0'\n```\n*/\nexport default function latestVersion(packageName: string, options?: Options): Promise<string>;\n"
  },
  {
    "path": "index.js",
    "content": "import packageJson from 'package-json';\n\nexport {PackageNotFoundError, VersionNotFoundError} from 'package-json';\n\nexport default async function latestVersion(packageName, options) {\n\tconst {version} = await packageJson(packageName.toLowerCase(), options);\n\treturn version;\n}\n"
  },
  {
    "path": "index.test-d.ts",
    "content": "import {expectType} from 'tsd';\nimport latestVersion from './index.js';\n\nexpectType<Promise<string>>(latestVersion('ava'));\nexpectType<Promise<string>>(latestVersion('npm', {version: 'latest-5'}));\nexpectType<Promise<string>>(latestVersion('npm', {registryUrl: 'https://registry.yarnpkg.com'}));\nexpectType<Promise<string>>(latestVersion('npm', {omitDeprecated: false}));\n"
  },
  {
    "path": "license",
    "content": "MIT License\n\nCopyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"latest-version\",\n\t\"version\": \"9.0.0\",\n\t\"description\": \"Get the latest version of an npm package\",\n\t\"license\": \"MIT\",\n\t\"repository\": \"sindresorhus/latest-version\",\n\t\"funding\": \"https://github.com/sponsors/sindresorhus\",\n\t\"author\": {\n\t\t\"name\": \"Sindre Sorhus\",\n\t\t\"email\": \"sindresorhus@gmail.com\",\n\t\t\"url\": \"https://sindresorhus.com\"\n\t},\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\"types\": \"./index.d.ts\",\n\t\t\"default\": \"./index.js\"\n\t},\n\t\"sideEffects\": false,\n\t\"engines\": {\n\t\t\"node\": \">=18\"\n\t},\n\t\"scripts\": {\n\t\t\"test\": \"xo && ava && tsd\"\n\t},\n\t\"files\": [\n\t\t\"index.js\",\n\t\t\"index.d.ts\"\n\t],\n\t\"keywords\": [\n\t\t\"latest\",\n\t\t\"version\",\n\t\t\"npm\",\n\t\t\"pkg\",\n\t\t\"package\",\n\t\t\"package.json\",\n\t\t\"current\",\n\t\t\"module\"\n\t],\n\t\"dependencies\": {\n\t\t\"package-json\": \"^10.0.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"ava\": \"^6.1.1\",\n\t\t\"semver\": \"^7.6.0\",\n\t\t\"semver-regex\": \"^4.0.5\",\n\t\t\"tsd\": \"^0.30.7\",\n\t\t\"xo\": \"^0.57.0\"\n\t}\n}\n"
  },
  {
    "path": "readme.md",
    "content": "# latest-version\n\n> Get the latest version of an npm package\n\nFetches the version directly from the registry instead of depending on the massive [npm](https://github.com/npm/npm/blob/8b5e7b6ae5b4cd2d7d62eaf93b1428638b387072/package.json#L37-L85) module like the [latest](https://github.com/bahamas10/node-latest) module does.\n\n## Install\n\n```sh\nnpm install latest-version\n```\n\n## Usage\n\n```js\nimport latestVersion from 'latest-version';\n\nconsole.log(await latestVersion('ava'));\n//=> '6.1.1'\n\nconsole.log(await latestVersion('@sindresorhus/df'));\n//=> '4.0.0'\n\n// Also works with semver ranges and dist-tags\nconsole.log(await latestVersion('npm', {version: 'latest-5'}));\n//=> '5.10.0'\n```\n\nThis 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.\n\n## Related\n\n- [latest-version-cli](https://github.com/sindresorhus/latest-version-cli) - CLI for this module\n- [package-json](https://github.com/sindresorhus/package-json) - Get the package.json of a package from the npm registry\n"
  },
  {
    "path": "test.js",
    "content": "import test from 'ava';\nimport semver from 'semver';\nimport semverRegex from 'semver-regex';\nimport latestVersion, {PackageNotFoundError, VersionNotFoundError} from './index.js';\n\ntest('latest version', async t => {\n\tt.regex(await latestVersion('ava'), semverRegex());\n});\n\ntest('latest version with version', async t => {\n\tt.true(semver.satisfies(await latestVersion('package-json', {version: '0'}), '0.x'));\n});\n\ntest('latest version with dist-tag', async t => {\n\tt.true(semver.satisfies(await latestVersion('npm', {version: 'latest-5'}), '5.x'));\n});\n\ntest('latest version scoped', async t => {\n\tt.regex(await latestVersion('@sindresorhus/df'), semverRegex());\n});\n\ntest('registry url', async t => {\n\tt.regex(await latestVersion('npm', {registryUrl: 'https://registry.yarnpkg.com/'}), semverRegex());\n});\n\ntest('include deprecated', async t => {\n\tt.regex(await latestVersion('querystring', {version: '0.2', omitDeprecated: false}), semverRegex());\n});\n\ntest('throws if not found', async t => {\n\tawait t.throwsAsync(latestVersion('nnnope'), {instanceOf: PackageNotFoundError});\n\tawait t.throwsAsync(latestVersion('npm', {version: '0.0.0'}), {instanceOf: VersionNotFoundError});\n});\n"
  }
]