# signed-varint

> efficiently store signed integers in varint

Latest version **2.0.1** (published 2016-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install signed-varint
pnpm add signed-varint
yarn add signed-varint
bun add signed-varint
```

## 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 | 2.0.1 |
| Published | 2016-11-05 |
| First published | 2014-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Dominic Tarr |
| Maintainers | dominictarr |

## Links

- npm: https://www.npmjs.com/package/signed-varint
- Repository: https://github.com/dominictarr/signed-varint
- Issues: https://github.com/dominictarr/signed-varint/issues
- npm.io page: https://npm.io/package/signed-varint

## Dependencies (1)

- [varint](https://npm.io/package/varint.md) ~5.0.0

## Recent versions

- 2.0.1 (latest) — 2016-11-05
- 2.0.0 — 2014-07-30
- 1.0.0 — 2014-05-13

## README

# signed-varint

store signed integers efficiently, as per protocol-buffers.

For unsigned integers use
[varint](https://github.com/chrisdickinson/varint).

Integers are mapped to positive integers, so that positive integers
become positive even numbers (n*2)
and negative integers become positive odd numbers. (n*-2 - 1)

This is the same as moving the sign bit from the most significant
possition to the least significant. Otherwise, varint will encode
negative numbers as large integers.

``` js
var varint = require('varint')
var svarint = require('signed-varint')

console.log('unsigned', varint.encode(-1))
console.log('signed', svarint.encode(-1))

//=> unsigned [255,255,255, 15]
//   signed [1]
```
## License

MIT

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