decode

import { decode } from "jsr:@ende/msgpack";

function

function decode(data: Uint8Array): ValueType

Decode a value from the MessagePack binary format.

If the input is not in valid message pack format, an error will be thrown.

data: Uint8Array

MessagePack binary data.

Returns

Decoded value from the MessagePack binary data.

Example: Usage

import { decode } from "@ende/msgpack/decode";
import { assertEquals } from "@ende/assert";

const encoded = new Uint8Array([163, 72, 105, 33]);

assertEquals(decode(encoded), "Hi!");

Source