index.d.ts 981 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. declare namespace latestVersion {
  2. interface Options {
  3. /**
  4. A semver range or [dist-tag](https://docs.npmjs.com/cli/dist-tag).
  5. */
  6. readonly version?: string;
  7. }
  8. }
  9. declare const latestVersion: {
  10. /**
  11. Get the latest version of an npm package.
  12. @example
  13. ```
  14. import latestVersion = require('latest-version');
  15. (async () => {
  16. console.log(await latestVersion('ava'));
  17. //=> '0.18.0'
  18. console.log(await latestVersion('@sindresorhus/df'));
  19. //=> '1.0.1'
  20. // Also works with semver ranges and dist-tags
  21. console.log(await latestVersion('npm', {version: 'latest-5'}));
  22. //=> '5.5.1'
  23. })();
  24. ```
  25. */
  26. (packageName: string, options?: latestVersion.Options): Promise<string>;
  27. // TODO: Remove this for the next major release, refactor the whole definition to:
  28. // declare function latestVersion(
  29. // packageName: string,
  30. // options?: latestVersion.Options
  31. // ): Promise<string>;
  32. // export = latestVersion;
  33. default: typeof latestVersion;
  34. };
  35. export = latestVersion;