Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/encoding/varint.ts>decode32

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function decode32
import { decode32 } from "https://deno.land/std@0.194.0/encoding/varint.ts";

Given a buf, starting at offset (default: 0), begin decoding bytes as VarInt encoded bytes, for a maximum of 5 bytes (offset + 5). The returned tuple is of the decoded varint 32-bit number, and the new offset with which to continue decoding other data.

VarInts are not 32-bit by default so this should only be used in cases where the varint is assured to be 32-bits. If in doubt, use decode().

To know how many bytes the VarInt took to encode, simply negate offset from the returned new offset.

Parameters

buf: Uint8Array
optional
offset = [UNSUPPORTED]

Returns

[number, number]