Skip to content

org-redtea/semint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Sep 19, 2018
6201cdf · Sep 19, 2018

History

3 Commits
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018
Sep 19, 2018

Repository files navigation

Semint

Semint is a small lib to encode/decode SemVer to/from integer.

Install

$ npm install -S @redtea/semint

Usage

// lib also support umd
import {encode, decode, isValid} from 'semint'; 

// first argument is semver in string representation and second argument is max decimals numbers to encode one part of semver
encode('1.1.1', 1); // 1 1 1
encode('1.1.1', 2); // 1 01 01
encode('1.1.1', 3); // 1 001 001
encode('999.999.999', 3); // 999 999 999

// first argument is semver in number representation and second argument is the same as for `encode`
decode(999999999, 3); // '999.999.999'

// `encode` and `decode` function use `isValid` to validate input and throw error if it is not valid
isValid(999999999, 3); // true
isValid(999999999, 1); // false
isValid('999.999.999', 3); // true
isValid('999.999.999', 1); // false
isValid('999.999.999-1', 3); // false
isValid('999.999.', 3); // false

About

Semint converts version from string to integer represent. (https://github.com/semver)

Resources

Stars

Watchers

Forks

Packages

No packages published