feat(smartversion): add equality comparison methods for SmartVersion instances and version strings
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-04-07 - 3.1.0 - feat(smartversion)
|
||||||
|
add equality comparison methods for SmartVersion instances and version strings
|
||||||
|
|
||||||
|
- Adds equals() to compare two SmartVersion instances
|
||||||
|
- Adds equalsString() to compare a SmartVersion against a version string
|
||||||
|
- Covers equality behavior with node+chromium tests
|
||||||
|
|
||||||
## 2026-04-07 - 3.0.6 - fix(tooling)
|
## 2026-04-07 - 3.0.6 - fix(tooling)
|
||||||
migrate project config and test tooling while hardening fuzzy version parsing
|
migrate project config and test tooling while hardening fuzzy version parsing
|
||||||
|
|
||||||
|
|||||||
@@ -33,4 +33,14 @@ tap.test('should create a patch version', async () => {
|
|||||||
console.log(newVersion.versionString);
|
console.log(newVersion.versionString);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
tap.test('should compare versions for equality', async () => {
|
||||||
|
const v1 = new smartversion.SmartVersion('1.2.3');
|
||||||
|
const v2 = new smartversion.SmartVersion('1.2.3');
|
||||||
|
const v3 = new smartversion.SmartVersion('1.2.4');
|
||||||
|
expect(v1.equals(v2)).toBeTrue();
|
||||||
|
expect(v1.equals(v3)).toBeFalse();
|
||||||
|
expect(v1.equalsString('1.2.3')).toBeTrue();
|
||||||
|
expect(v1.equalsString('1.2.4')).toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
export default tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartversion',
|
name: '@push.rocks/smartversion',
|
||||||
version: '3.0.6',
|
version: '3.1.0',
|
||||||
description: 'A library to handle semantic versioning with ease.'
|
description: 'A library to handle semantic versioning with ease.'
|
||||||
}
|
}
|
||||||
|
|||||||
11
ts/index.ts
11
ts/index.ts
@@ -54,6 +54,17 @@ export class SmartVersion {
|
|||||||
return plugins.semver.lt(this.versionString, versionStringArg);
|
return plugins.semver.lt(this.versionString, versionStringArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public equals(smartVersionArg: SmartVersion) {
|
||||||
|
return this.equalsString(smartVersionArg.versionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* compares the version of this against a string for equality
|
||||||
|
*/
|
||||||
|
public equalsString(versionStringArg: string) {
|
||||||
|
return plugins.semver.eq(this.versionString, versionStringArg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tries to get the best match from a range of available versions
|
* tries to get the best match from a range of available versions
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user