Modules@robinpath/semver
@robinpath/semver
0.1.0PublicParse, compare, validate, and manipulate semantic version strings (semver 2.0.0 compliant)
@robinpath/semver
Parse, compare, validate, and manipulate semantic version strings (semver 2.0.0 compliant)
Why use this module?
The semver module lets you:
- Parse a semver version string into its components (major, minor, patch, prerelease, build)
- Check whether a string is a valid semver version
- Compare two semver versions, returning -1 (v1 < v2), 0 (equal), or 1 (v1 > v2)
- Check if the first version is greater than the second
- Check if the first version is less than the second
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/semver
Quick Start
No credentials needed — start using it right away:
semver.isValid "1.2.3"
Available Functions
| Function | Description |
|---|---|
semver.parse | Parse a semver version string into its components (major, minor, patch, prerelease, build) |
semver.isValid | Check whether a string is a valid semver version |
semver.compare | Compare two semver versions, returning -1 (v1 < v2), 0 (equal), or 1 (v1 > v2) |
semver.gt | Check if the first version is greater than the second |
semver.lt | Check if the first version is less than the second |
semver.eq | Check if two versions are equal (ignoring build metadata) |
semver.gte | Check if the first version is greater than or equal to the second |
semver.lte | Check if the first version is less than or equal to the second |
semver.satisfies | Check if a version satisfies a semver range (supports ^, ~, >=, <=, >, <, =, x wildcard, |
semver.inc | Increment a version by the specified release type (major, minor, patch, or prerelease) |
semver.major | Extract the major version number from a semver string |
semver.minor | Extract the minor version number from a semver string |
semver.patch | Extract the patch version number from a semver string |
semver.coerce | Coerce a loose version string into a clean semver string (e.g. "v1" becomes "1.0.0") |
semver.diff | Determine the type of difference between two versions (major, minor, patch, prerelease, or null) |
Examples
Check whether a string is a valid semver version
semver.isValid "1.2.3"
Compare two semver versions, returning -1 (v1 < v2), 0 (equal), or 1 (v1 > v2)
semver.compare "1.2.3" "1.3.0"
Check if the first version is greater than the second
semver.gt "2.0.0" "1.9.9"
Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/semver";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
semver.isValid "1.2.3"
`);
Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.0 | latest | yesterday |
Related Modules
utilities
1
@dev-tester/hello-world
v2.0.0dev-tester
Updated description
0 downloads
...
utilities
0
@robinpath/apollo
v0.1.1robinpath
Apollo module for RobinPath.
0 downloads
...
utilities
0
@robinpath/archive
v0.1.1robinpath
Create and extract .zip and .tar.gz file archives
0 downloads
...
utilities
0
@robinpath/assert
v0.1.1robinpath
Testing assertions: equal, deepEqual, truthy, falsy, type checks, includes, matches, throws, and more
0 downloads
...
Install
$ robinpath install @robinpath/semver Version0.1.0
LicenseMIT
Unpacked Size7.0 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

