@oslojs/cbor
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@oslojs/cbor

Documentation: https://cbor.oslojs.dev

[!CAUTION] This package is highly experimental!

A CBOR library for JavaScript based on RFC 8949.

  • Runtime agnostic
  • No third-party dependencies
  • Fully typed
import { decodeCBORToNativeValueNoLeftoverBytes } from "@oslojs/cbor";

const MAX_DEPTH = 10;
const encoded = new Uint8Array([
	0xa1, 0x67, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x65, 0x68, 0x65, 0x6c, 0x6c, 0x6f
]);
const result = decodeCBORToNativeValueNoLeftoverBytes(encoded, MAX_DEPTH) as Result;
const message: string = result.message;

interface Result {
	message: string;
}

This package currently only supports decoding

Installation

npm i @oslojs/cbor

Readme

Keywords

Package Sidebar

Install

npm i @oslojs/cbor

Weekly Downloads

17

Version

0.2.0

License

MIT

Unpacked Size

33.7 kB

Total Files

13

Last publish

Collaborators

  • pilcrowonpaper