New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

semver

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semver

The semantic version parser used by npm.


Version published
Weekly downloads
391M
increased by6.57%
Maintainers
6
Weekly downloads
 
Created

What is semver?

The semver package is a module for semantic versioning (semver) parsing and comparison. It provides utilities for working with semantic version numbers, allowing users to parse, compare, increment, and manipulate version numbers according to the semantic versioning specification.

What are semver's main functionalities?

Parsing and Validating Versions

This feature allows you to parse a version string and check if it is a valid semantic version.

"const semver = require('semver');
const version = '1.2.3';
const valid = semver.valid(version); // '1.2.3'"

Comparing Versions

This feature enables you to compare two semantic version numbers to determine their order.

"const semver = require('semver');
const v1 = '1.2.3';
const v2 = '4.5.6';
const comparison = semver.compare(v1, v2); // -1"

Incrementing Versions

This feature allows you to increment a version number by the major, minor, or patch version.

"const semver = require('semver');
const version = '1.2.3';
const incremented = semver.inc(version, 'patch'); // '1.2.4'"

Ranges and Satisfaction

This feature checks if a version satisfies a given range.

"const semver = require('semver');
const version = '1.2.3';
const range = '^1.0.0';
const satisfied = semver.satisfies(version, range); // true"

Coercion

This feature coerces a string to a semantic version if possible.

"const semver = require('semver');
const version = 'v1';
const coerced = semver.coerce(version); // '1.0.0'"

Other packages similar to semver

FAQs

Package last updated on 29 Jan 2025

Did you know?

Socket

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.

Install

Related posts