You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@aryzing/varint

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aryzing/varint

Encode and decode `varint`s.

1.0.0
latest
Source
npm
Version published
Maintainers
0
Created
Source

varint

Usage:

import { encode, decode } from "@aryzing/varint";

encode(1);     // Uint8Array(1) [ 1 ]
encode(127);   // Uint8Array(1) [ 127 ]
encode(128);   // Uint8Array(2) [ 128, 1 ]
encode(255);   // Uint8Array(2) [ 255, 1 ]
encode(300);   // Uint8Array(2) [ 172, 2 ]
encode(16384); // Uint8Array(3) [ 128, 128, 1 ]

decode(new Uint8Array([1]));           // 1n
decode(new Uint8Array([127]));         // 127n
decode(new Uint8Array([128, 1]));      // 128n
decode(new Uint8Array([255, 1]));      // 255n
decode(new Uint8Array([172, 2]));      // 300n
decode(new Uint8Array([128, 128, 1])); // 16384n

FAQs

Package last updated on 20 Dec 2024

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