Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

signed-varint

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

signed-varint

efficiently store signed integers in varint

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44K
decreased by-70.4%
Maintainers
1
Weekly downloads
 
Created
Source

signed-varint

store signed integers efficiently, as per protocol-buffers.

For unsigned integers use varint.

Integers are mapped to positive integers, so that positive integers become positive even numbers (n2) 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.

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

FAQs

Package last updated on 05 Nov 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