Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
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.
| Sponsored by ppl
Some utils that aren't provided by the mainstream semver
module.
npm install --save semver-utils
'use strict';
var semverUtils = require('semver-utils');
var version = require('./package.json').version;
var semver = semverUtils.parse(version);
console.log(semver);
semverUtils.parse(semverString)
semverUtils.stringify(semverObject)
semverUtils.parseRange(rangeString)
semverUtils.stringifyRange(rangeArray)
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
}
]
Creates a range string such as >= 1.1.7 < 2.0.0 || 1.1.3
from an array of semver objects (and operators) such as
[
{ "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
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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.