@flownet/lib-pick-npm-versions v0.1.13
@flownet/lib-pick-npm-versions
The @flownet/lib-pick-npm-versions project is a utility tool for Node.js developers that gives a simplified way of tracking and managing different versions of Node.js packages in a project. It does this by automatically fetching a list of the available versions of a given NPM package, then extracting a certain number of its most recent versions.
Functionality
This module consists of a single function, which interacts with the @flownet/lib-list-npm-versions library to fetch the version list for a specific NPM package. The user specifies the package by name and, optionally, the number of versions they wish to retrieve.
The function then extracts the specified number of latest versions from the fetched list, and it constructs three different variations of SemVer (Semantic Versioning) ranges: patch, minor, and major.
Patch Range: A range constructed from the full version numbers, using the caret (^) symbol to allow updates that do not modify the leftmost non-zero digit in the version. For instance, for a version number 1.2.3, any version that increments the patch version (e.g. 1.2.4, 1.2.5, etc.) is allowed.
Minor Range: A range constructed from the major and minor numbers of the versions. It allows updates that increment the minor and patch versions. For instance, for a version number 1.2.3, any version that increments the minor or patch number (e.g. 1.3.0 or 1.2.4) is allowed.
Major Range: A range that allows updates incrementing any level of the version number (major, minor, or patch). For instance, for a version 1.2.3, any newer version (e.g., 2.0.0, 1.3.0, or 1.2.4) is allowed.
The generated version ranges permit developers to manage their package dependencies efficiently, by defining the types of updates the packages are allowed to undergo.
Finally, the function returns an object containing arrays of the chosen versions, and strings of the patch, minor, and major version ranges.