You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jake Champion 7116d37297 Add exta npm info 2 years ago
.eslintrc.js Initial commit 2 years ago
.gitignore Initial commit 2 years ago
README.md Fix typo 2 years ago
index.js Initial commit 2 years ago
index.test.js Initial commit 2 years ago
package-lock.json Initial commit 2 years ago
package.json Add exta npm info 2 years ago

README.md

SemVergh

A module to return SemVer versions which are known to satisfy or unsatisfy a basic SemVer range.

This has only been tested with these SemVer range types:

  • Hyphen Ranges (1.2.3 - 2.3.4)
  • X-Ranges (1.2.x, 1.X, 1.2.*, *)
  • Partial version ranges (1, 1.2)
  • Tilde Ranges (~1.2.3, ~1.2, ~1)
  • Caret Ranges (^1.2.3, ^0.2.5, ^0.0.4)
  • Greater Than (>3)
  • Greater Than or Equal (>=3)
  • Less Than (<3)
  • Less Than or Equal (<=3)

Install

npm install --save semvergh

Usage

"use strict";

const { satisfyingVersion, unsatisfyingVersion } = require("./");

satisfyingVersion("1.2.3 - 2.3.4"); // => '1.2.3'
unsatisfyingVersion("1.2.3 - 2.3.4"); // =>'0.2.3'

satisfyingVersion("3.x"); // => '3.0.0'
unsatisfyingVersion("3.x"); // => '3.1.0'

satisfyingVersion("1"); // => '1.0.0'

unsatisfyingVersion("1"); // => '2.0.0'

satisfyingVersion("~1"); // => '1.0.0'
unsatisfyingVersion("~1"); // => '0.0.0'

satisfyingVersion("^1"); // => '1.0.0'
unsatisfyingVersion("^1"); // => '0.0.0'

satisfyingVersion(">3"); // => '4.0.0'
unsatisfyingVersion(">3"); // => '3.0.0'

satisfyingVersion(">=3"); // => '3.0.0'
unsatisfyingVersion(">=3"); // => '2.0.0'

satisfyingVersion("<3"); // => '0.0.0'
unsatisfyingVersion("<3"); // => '4.0.0'

satisfyingVersion("<=3"); // => '3.0.0'
unsatisfyingVersion("<=3"); // => '4.0.0'

satisfyingVersion("*"); // => '0.0.0'
unsatisfyingVersion("*"); // => null

API

satisfyingVersion(range) -> string

Find a SemVer version that satisfies the supplied SemVer range.

  • Parameters: string - A SemVer range. E.G. “>=3” or “3.*” (Required)
  • Returns: string - A SemVer version that satisfies the supplied range.

unsatisfyingVersion(range) -> string or null

Find a SemVer version that does not satisfy the supplied SemVer range. Will return null if all versions would satisfy the range.

  • Parameters: string - A SemVer range. E.G. “>=3” or “3.*” (Required)
  • Returns: string or null - A SemVer version that does not satisfy the supplied range. Will return null if all versions would satisfy the range.

License

MIT