# semvertoint

> Safely convert any semver to an integer for easy comparisons

Latest version **1.1.0** (published 2018-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install semvertoint
pnpm add semvertoint
yarn add semvertoint
bun add semvertoint
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-02-07 |
| First published | 2018-02-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | sospedra |
| Maintainers | sospedra |
| Keywords | semver, int, compare, parse, semvertoint, integer |

## Links

- npm: https://www.npmjs.com/package/semvertoint
- Repository: https://github.com/sospedra/semvertoint
- Homepage: https://github.com/sospedra/semvertoint#readme
- Issues: https://github.com/sospedra/semvertoint/issues
- npm.io page: https://npm.io/package/semvertoint

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-02-07
- 1.0.0 — 2018-02-07

## README

# semverToInt

[![Build Status](https://travis-ci.org/sospedra/semvertoint.svg?branch=master)](https://travis-ci.org/sospedra/semvertoint)
[![David](https://img.shields.io/david/sospedra/semvertoint.svg)]()
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

Safely convert any semver to an integer for easy comparisons in 677 Bytes

### Install

`yarn add semvertoint`

### Usage

```js
import semverToInt from 'semvertoint'

semverToInt('12.0.1') // 130000100001
semverToInt('190.10.0') > semverToInt('190.09.9999') // true
semverToInt(require('./package.json').version)
```

Very useful to be combined with migrations policies, changelogs, etc.
You'll only need to mantain the `package.json` version (for example) and use it for all the historic changes that you need!

#### Custom base

In case you need more digits (moar?) or maybe less (less?!!) you specify a custom base:

```js
semverToInt('13.3.7') // 140000400007
semverToInt('13.3.7', 12) // 14000004000007
```

You might need this if you have humongous numbers

```js
// this is wrong
semverToInt('13.300000.7') // 170000100007
// becuase is greater than
semverToInt('15.0.0') // 150000100000
// but you can increase the base
semverToInt('13.300000.7', 12) // 14300001000007
semverToInt('14.0.0', 12) // 15000001000000
```

---
_Source: https://npm.io/package/semvertoint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
