Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/willow_utils/src/encoding/encoding.ts>compactWidth

TypeScript typings and utilities for the Willow protocol.
Latest
function compactWidth
import { compactWidth } from "https://deno.land/x/willow_utils@1.0.0/src/encoding/encoding.ts";

Returns the number of octets needed to store a number, along the lines of 8-bit, 16-bit, 32-bit, or 64-bit unsigned integers.

https://willowprotocol.org/specs/encodings/index.html#compact_width

Parameters

num: number | bigint

Returns

| 1
| 2
| 4
| 8