
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
semver-utils
Advanced tools
The semver-utils npm package provides utilities for parsing, comparing, and manipulating semantic version strings. It is useful for developers who need to handle versioning in their applications, ensuring compatibility and proper version management.
Parsing Semantic Versions
This feature allows you to parse a semantic version string into its component parts, such as major, minor, patch, and pre-release identifiers.
const semverUtils = require('semver-utils');
const parsed = semverUtils.parse('1.2.3-alpha.1');
console.log(parsed);
Comparing Versions
This feature enables you to compare two semantic version strings to determine their order. It returns -1, 0, or 1 depending on whether the first version is less than, equal to, or greater than the second version.
const semverUtils = require('semver-utils');
const result = semverUtils.compare('1.2.3', '1.2.4');
console.log(result);
Incrementing Versions
This feature allows you to increment a semantic version string by a specified part (major, minor, or patch).
const semverUtils = require('semver-utils');
const incremented = semverUtils.increment('1.2.3', 'patch');
console.log(incremented);
The semver package is a popular library for parsing, validating, comparing, and incrementing semantic version strings. It offers a comprehensive set of features for handling semantic versions and is widely used in the Node.js ecosystem. Compared to semver-utils, semver provides more extensive functionality and better integration with npm.
node-semver is another library for working with semantic versioning in Node.js. It provides similar functionalities to semver-utils, such as parsing, comparing, and incrementing versions. However, it is less commonly used than the semver package and may have fewer features.
Some utils that aren't provided by the mainstream semver
module.
Turns a string such as 1.0.6-1+build-623
into the object
{
semver: '1.0.6-1+build-623'
, version: '1.0.6'
, major: '1'
, minor: '0'
, patch: '6'
, release: '1'
, build: 'build-623'
}
returns null
on error
Creates a string such as 1.0.6-1+build-623
from the object
{
major: '1'
, minor: '0'
, patch: '6'
, release: '1'
, build: 'build-623'
}
A solution to https://github.com/isaacs/node-semver/issues/10
Parses a range string into an array of semver objects
>= 1.1.7 < 2.0.0 || 1.1.3'
becomes
[
{
"semver": ">= v1.1.7"
, "operator": ">="
, "major": 1
, "minor": 1
, "patch": 7
}
, {
"semver": "< v2.0.0"
, "operator": "<"
, "major": 2
, "minor": 0
, "patch": 0
}
, {
"operator": "||"
}
, {
"semver": "v1.1.3"
, "operator": "="
, "major": 1
, "minor": 1
, "patch": 3
}
]
FAQs
Tools for manipulating semver strings and objects
The npm package semver-utils receives a total of 423,684 weekly downloads. As such, semver-utils popularity was classified as popular.
We found that semver-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.