# @bpmn-io/semver-compat

> Check whether provided semver versions satisfy required ranges

Latest version **0.1.0** (published 2026-05-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bpmn-io/semver-compat
pnpm add @bpmn-io/semver-compat
yarn add @bpmn-io/semver-compat
bun add @bpmn-io/semver-compat
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2026-05-08 |
| First published | 2026-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 217.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | bpmn.io contributors |
| Maintainers | bpmn-io-admin, nikku, barmac, philippfromme, maxtru, skaiir-camunda, vsgoulart, barinali, jarekdanielak, ev-camunda, alekseymanetov |

## Links

- npm: https://www.npmjs.com/package/@bpmn-io/semver-compat
- Repository: https://github.com/bpmn-io/semver-compat
- Homepage: https://github.com/bpmn-io/semver-compat#readme
- Issues: https://github.com/bpmn-io/semver-compat/issues
- npm.io page: https://npm.io/package/@bpmn-io/semver-compat

## Dependencies (1)

- [semver](https://npm.io/package/semver.md) ^7.7.2

## Recent versions

- 0.1.0 (latest) — 2026-05-08

## README

# @bpmn-io/semver-compat

[![CI](https://github.com/jarekdanielak/semver-compat/actions/workflows/CI.yml/badge.svg)](https://github.com/jarekdanielak/semver-compat/actions/workflows/CI.yml)

Check whether provided semver versions satisfy required ranges.

## Installation

```sh
npm install @bpmn-io/semver-compat
```

## Usage

### `isCompatible(required, provided)`

Returns `true` if every entry in `required` is satisfied by the corresponding version in `provided`.

```js
import { isCompatible } from '@bpmn-io/semver-compat';

isCompatible(
  { node: '>=18', npm: '>=9' },  // required
  { node: '16',   npm: '10'  }   // provided
); // → false

isCompatible(
  { node: '>=18', npm: '>=9' },
  { node: '20',   npm: '10'  }
); // → true
```

### Behavior

The compatibility check **fails open**: when data is missing or unparseable the entry is considered compatible, so misconfiguration never blocks the user unexpectedly.

Only keys present in both `required` and `provided` are checked:

```js
isCompatible(
  { node: '>=18', npm: '>=9' },
  { node: '20' }               // npm not provided
); // → true
```

Entries in `provided` whose value cannot be coerced to semver are skipped (treated as compatible):

```js
isCompatible(
  { node: '>=18' },
  { node: 'not-a-version' }
); // → true
```

Entries in `required` with an invalid semver range are skipped (treated as compatible):

```js
isCompatible(
  { node: 'not-a-range' },
  { node: '20' }
); // → true
```

| Parameter  | Type            | Description                       |
|------------|-----------------|-----------------------------------|
| `required` | `SemverRanges`  | Named semver range requirements   |
| `provided` | `SemverVersions`| Named version strings to check    |

### `getCompatible(required, provided)`

Returns the subset of `provided` whose versions satisfy the corresponding ranges in `required`.

```js
getCompatible(
  { node: '>=18', npm: '>=9' },  // required
  { node: '20',   npm: '8'   }   // provided
); // → { node: '20' }
```

| Parameter  | Type            | Description                       |
|------------|-----------------|-----------------------------------|
| `required` | `SemverRanges`  | Named semver range requirements   |
| `provided` | `SemverVersions`| Named version strings to check    |

### `getCoerced(versions)`

Returns the subset of `versions` whose values can be coerced to valid semver, normalized to standard semver format. Entries with uncoercible values are omitted.

```js
getCoerced(
  { node: '20', myLib: '18.0.0.Final', broken: 'not-a-version' }
); // → { node: '20.0.0', myLib: '18.0.0' }
```

| Parameter  | Type            | Description                       |
|------------|-----------------|-----------------------------------|
| `versions` | `SemverVersions`| Named version strings to coerce   |

### `isSatisfied(range, version)`

Returns `true` if the version satisfies the range, `false` if it does not, or `null` if the check should be skipped — when the range is invalid or the version cannot be coerced to semver.

```js
isSatisfied('>=18', '20');          // → true
isSatisfied('>=18', '16');          // → false
isSatisfied('not-a-range', '20');   // → null
isSatisfied('>=18', 'not-a-version'); // → null
```

| Parameter | Type     | Description              |
|-----------|----------|--------------------------|
| `range`   | `string` | A semver range string    |
| `version` | `string` | A version string to check |

## License

MIT

---
_Source: https://npm.io/package/@bpmn-io/semver-compat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
