npm package: @fnet/npm-pick-versions
Description: This project provides a simple utility for selecting and organizing a limited number of versions of an npm package. It retrieves the latest versions of a specified npm package and allows you to generate version ranges based on patch, minor, and major upda
Latest version: 0.1.14

# @fnet/npm-pick-versions

This project provides a simple utility for selecting and organizing a limited number of versions of an npm package. It retrieves the latest versions of a specified npm package and allows you to generate version ranges based on patch, minor, and major updates. This can be particularly useful for developers who need to manage dependencies with specific version restrictions.

## How It Works

The utility operates by first retrieving a list of versions for a given npm package using `@fnet/npm-list-versions`. It then selects a specified number of recent versions and constructs version ranges that can be used to define compatible dependency versions. The ranges are categorized into patch, minor, and major groups, offering flexible options for dependency management.

## Key Features

- Fetches the latest versions of a specified npm package.
- Allows specification of how many recent versions to consider.
- Generates version ranges for patch, minor, and major updates.
- Simplifies version management for npm package dependencies.

## Conclusion

The `@fnet/npm-pick-versions` tool is useful for developers needing to maintain npm package dependencies efficiently by providing structured version range information. It helps in managing which versions of a package can be used, ensuring compatibility and stability in projects without the overhead of manually tracking each version update.


# Developer Guide for `@fnet/npm-pick-versions`

## Overview

The `@fnet/npm-pick-versions` library is designed to help developers manage and select specific versions of npm packages based on semantic versioning. It enables users to efficiently retrieve lists of package versions and construct version ranges based on major, minor, or patch updates. This utility is particularly useful for projects that need to ensure compatibility with specific package versions.

## Installation

To install the `@fnet/npm-pick-versions` library, you can use npm or yarn:

```bash
npm install @fnet/npm-pick-versions
```

or

```bash
yarn add @fnet/npm-pick-versions
```

## Usage

Here's how you can use the library to fetch and organize npm package versions:

1. **Import the Default Function**: The main function exported by the library is an asynchronous function that retrieves versions for a given package name.

2. **Provide Parameters**: Pass an object with the package name and optionally specify the number of versions to retrieve.

3. **Access Version Ranges**: The function returns an object that includes arrays for individual versions and string representations of patch, minor, and major version ranges.

### Example Code

```javascript
import pickVersions from '@fnet/npm-pick-versions';

const fetchPackageVersions = async () => {
    // Fetch the most recent 3 versions of a package, grouped by major version
    const versionData = await pickVersions({
        name: 'express',
        count: 3
    });

    console.log('Latest Versions:', versionData.versions);
    console.log('Patch Version Range:', versionData.patchRange);
    console.log('Minor Version Range:', versionData.minorRange);
    console.log('Major Version Range:', versionData.majorRange);
};

fetchPackageVersions();
```

## Examples

Here are some practical examples for using the `@fnet/npm-pick-versions` library:

### Example 1: Fetching Latest Versions and Ranges

```javascript
(async () => {
    const { versions, patchRange, minorRange, majorRange } = await pickVersions({
        name: 'lodash',
        count: 2
    });

    console.log('Versions:', versions);
    console.log('Patch Range:', patchRange);
    console.log('Minor Range:', minorRange);
    console.log('Major Range:', majorRange);
})();
```

### Example 2: Custom Count of Versions

```javascript
import pickVersions from '@fnet/npm-pick-versions';

pickVersions({ name: 'react', count: 5 })
    .then(({ versions, patchRange }) => {
        console.log('Top 5 Versions:', versions);
        console.log('Patch Range for Compatibility:', patchRange);
    })
    .catch(error => {
        console.error('Error fetching versions:', error);
    });
```

## Acknowledgement

This library utilizes semantic versioning principles to assist developers in managing package dependencies effectively. It integrates with npm to provide accurate versioning data, making it a reliable tool for maintaining package consistency.



# Input Schema
```yaml
$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  name:
    type: string
    description: The name of the npm package.
  count:
    type: integer
    description: The number of versions to retrieve, defaults to 2.
    default: 2
required:
  - name

```