Skip to main content

@std/encoding@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score64%
Published2 years ago (0.215.0)
function encode
encode(
num: bigint | number,
buf?: Uint8Array,
offset?
): [Uint8Array, number]

Takes unsigned number num and converts it into a VarInt encoded Uint8Array, returning a tuple consisting of a Uint8Array slice of the encoded VarInt, and an offset where the VarInt encoded bytes end within the Uint8Array.

If buf is not given then a Uint8Array will be created. offset defaults to 0.

If passed buf then that will be written into, starting at offset. The resulting returned Uint8Array will be a slice of buf. The resulting returned number is effectively offset + bytesWritten.

Parameters

optional
buf: Uint8Array
optional
offset

Return Type

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/encoding

Import symbol

import { encode } from "@std/encoding/varint";
or

Import directly with a jsr specifier

import { encode } from "jsr:@std/encoding/varint";