std/encoding/varint.ts

Deno standard library
Go to Latest
function decodeU32
import { decodeU32 } from "https://deno.land/std@0.145.0/encoding/varint.ts?s=decodeU32";

Decodes the given Uint8Array into a number with LEB128.

import { decodeU32 } from "./varint.ts";
const bytes = Uint8Array.from([221, 199, 1]);
const decodedValue = decodeU32(bytes);

// Do something with the decoded value
console.log(decodedValue === 25565);

Parameters

val: Uint8Array[src]