index.d.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. declare namespace semverDiff {
  2. type Result =
  3. | 'major'
  4. | 'premajor'
  5. | 'minor'
  6. | 'preminor'
  7. | 'patch'
  8. | 'prepatch'
  9. | 'prerelease'
  10. | 'build';
  11. }
  12. /**
  13. Get the diff type of two [semver](https://github.com/npm/node-semver) versions: `0.0.1 0.0.2` → `patch`.
  14. @returns The difference type between two semver versions, or `undefined` if they're identical or the second one is lower than the first.
  15. @example
  16. ```
  17. import semverDiff = require('semver-diff');
  18. semverDiff('1.1.1', '1.1.2');
  19. //=> 'patch'
  20. semverDiff('1.1.1-foo', '1.1.2');
  21. //=> 'prepatch'
  22. semverDiff('0.0.1', '1.0.0');
  23. //=> 'major'
  24. semverDiff('0.0.1-foo', '1.0.0');
  25. //=> 'premajor'
  26. semverDiff('0.0.1', '0.1.0');
  27. //=> 'minor'
  28. semverDiff('0.0.1-foo', '0.1.0');
  29. //=> 'preminor'
  30. semverDiff('0.0.1-foo', '0.0.1-foo.bar');
  31. //=> 'prerelease'
  32. semverDiff('0.1.0', '0.1.0+foo');
  33. //=> 'build'
  34. semverDiff('0.0.1', '0.0.1');
  35. //=> undefined
  36. semverDiff('0.0.2', '0.0.1');
  37. //=> undefined
  38. ```
  39. */
  40. declare function semverDiff(
  41. versionA: string,
  42. versionB: string
  43. ): semverDiff.Result | undefined;
  44. export = semverDiff;