std/encoding/varint.ts

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

Encodes the given BigInt into Uint8Array with LEB128. The number needs to be in the range of 0 and 0xffffffffffffffff.

import { encodeU64 } from "./varint.ts";

const encodedValue = encodeU64(42n);
// Do something with the encoded value

Parameters

val: bigint[src]

Returns

Uint8Array[src]