Socket
Socket
Sign inDemoInstall

compare-versions

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compare-versions - npm Package Compare versions

Comparing version 4.1.4 to 5.0.0

lib/esm/index.d.ts

23

package.json
{
"name": "compare-versions",
"version": "4.1.4",
"version": "5.0.0",
"description": "Compare semver version strings to find greater, equal or lesser.",

@@ -23,17 +23,22 @@ "repository": {

"scripts": {
"test": "c8 --reporter=lcov mocha"
"build": "npm run build:esm && npm run build:umd",
"build:esm": "tsc --module esnext --target es2017 --outDir lib/esm",
"build:umd": "rollup lib/esm/index.js --format umd --name compareVersions --sourcemap -o lib/umd/index.js",
"test": "c8 --reporter=lcov mocha -r ts-node/register test/**/*.ts"
},
"main": "index.js",
"module": "index.mjs",
"types": "index.d.ts",
"main": "./lib/umd/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/esm/index.d.ts",
"sideEffects": false,
"files": [
"index.js",
"index.mjs",
"index.d.ts"
"lib"
],
"devDependencies": {
"@types/mocha": "^9.1.0",
"c8": "^7.10.0",
"mocha": "^10.0.0"
"mocha": "^10.0.0",
"rollup": "^2.78.1",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
}
}

@@ -22,4 +22,6 @@ # compare-versions

Note: Starting from v4 this library includes a ESM version which will automatically be selected by your bundler (webpack, parcel etc). The old CJS version is `index.js` and the new ESM version is `index.mjs`.
__Note__: Starting from v5 the main export is now _named_ like so: `import { compareVersions } from 'compare-versions'`.
__Note__: Starting from v4 this library includes a ESM version which will automatically be selected by your bundler (webpack, parcel etc). The CJS/UMD version is `lib/umd/index.js` and the new ESM version is `lib/esm/index.js`.
## Usage

@@ -30,3 +32,3 @@

```js
import compareVersions from 'compare-versions';
import { compareVersions } from 'compare-versions';

@@ -90,3 +92,3 @@ compareVersions('11.1.1', '10.0.0'); // 1

Applies the same ruleset used comparing version numbers and returns a boolean:
Applies the same rules used comparing version numbers and returns a boolean:

@@ -103,12 +105,13 @@ ```js

If included directly in the browser, `compareVersions()` is available on the global window:
If included directly in the browser, the functions above are available on the global window under the `compareVersions` object:
```html
<script src=https://unpkg.com/compare-versions></script>
<script src=https://unpkg.com/compare-versions/lib/umd/index.js></script>
<script>
window.compareVersions('11.0.0', '10.0.0');
window.compareVersions.compare('11.0.0', '10.0.0', '>');
window.compareVersions.validate('11.0.0');
window.compareVersions.satisfies('1.2.0', '^1.0.0');
const { compareVersions, compare, satisfies, validate } = window.compareVersions
console.log(compareVersions('11.0.0', '10.0.0'))
console.log(compare('11.0.0', '10.0.0', '>'))
console.log(satisfies('1.2.0', '^1.0.0'))
console.log(validate('11.0.0'))
</script>
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc