New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

general-version-compare

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

general-version-compare

general version compare(通用类库比较)

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-30%
Maintainers
1
Weekly downloads
 
Created
Source

general-version-compare

在开发 360静态资源库 时需要进行版本排序,但是compare-versions 不能满足要求,因为有的版本不符合 semver规范 (如 angular.js 的版本 1.0.0rc9),所以写了一个通用的版本比较,测试使用了compare-versions的测试用例 (具体测试情况,请查看test/compare.js中注解)。

Install

Install with npm:

$ npm install general-version-compare --save

<script />

You can simply include general-version-compare like this:

<script src='[path of index.js]'></script>

Usage

var compareVersion = require('general-version-compare');
compareVersion('10.1.8', '10.0.4');              // -1
compareVersion('1.0.0rc10', '1.0.0rc12');        //  1
compareVersion('1.3.0-beta.17', '1.3.0-beta.1'); //-1

Can also be used for sorting:

var versions = [
    '1.5.19'
    '1.2.3',
    '1.5.5',
];
console.log(versions.sort(compareVersion));

Outputs:

[
    '1.5.19',
    '1.5.5',
    '1.2.3'
]

License

MIT

Keywords

FAQs

Package last updated on 17 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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