Coder Social home page Coder Social logo

appv's Introduction

appv

NPM

Build Status

操作 app 版本的方法库

Install

npm i appv # or yarn install

Usage

const appv = require('appv');

appv.parseVersion('1.2.3') // { major: 1, minor: 2, patch: 3 }

Feature

parseVersion

格式化 xx.xx.xx 格式的版本,返回 major、minor 和 patch。

Example

appv.parseVersion('1.2.3') // { major: 1, minor: 2, patch: 3 }
appv.parseVersion('1.2') // { major: 1, minor: 2, patch: 0 }
appv.parseVersion('1') // { major: 1, minor: 0, patch: 0 }

valid

判断是否是合法版本号(x.x.x),提供 isValidVersion 方法。

Example

appv.isValidVersion('1.2.3') // true
appv.isValidVersion('abc') // false

compare

比较两个版本号,提供 isEqisGtisGteisLtisLte 等方法。

Example

参考 appv.test.js

appv.isEq('1.2.3', '1.2.3') // true
appv.isEq('1.2.3', '3.2.1') // false
appv.isEq('1.2.0', '1.2') // true
appv.isGt('1.2.3', '1.2.2') // true
appv.isGte('1', '0.11.12') // true
appv.isLt('1.21.21', '2.1') // true

range

判断版本是否在一个区间,提供 isBetween 方法。

Example

参考 appv.test.js

appv.isBetween('1.2.3', ['1', '2']) // true

compute

操作版本,提供 patchminormajor 方法。

Example

参考 appv.test.js

appv.patch('0.0.1') // 0.0.2
appv.minor('0.0.1') // 0.1.0
appv.major('0.0.1') // 1.0.0

test

npm test

appv's People

Contributors

sunhengzhe avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.