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

std/encoding/varint.ts>decodeU64

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

Decodes the given Uint8Array into a BigInt with LEB128.

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

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

Parameters

val: Uint8Array

Returns

BigInt