![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@levischuck/tiny-cbor
Advanced tools
This minimal generic library decodes and encodes most useful CBOR structures into simple JavaScript structures:
string
s or number
s with CBORType
values as a Map
CBORType
valuesnumber
snumber
sNaN
, Infinity
, -Infinity
string
sUint8Array
null
and undefined
CBORTag(tag, value)
This implementation does not support:
[-9007199254740991, 9007199254740991]
, see
Number.MAX_SAFE_INTEGERMap
sThis implementation has the following constraints:
Maps that have duplicate keys will throw an error during decoding. Decoding data that is incomplete will throw an error during decoding.
// NPM
// import { decodeCBOR } from "@levischuck/tiny-cbor";
// or JSR
// import { decodeCBOR } from "jsr:@levischuck/tiny-cbor";
import { decodeCBOR } from "./index.ts";
// Get your bytes somehow, directly or with decodeBase64 / decodeHex (available through @levischuck/tiny-encodings)
const HELLO_WORLD_BYTES = new Uint8Array([
107, // String wih length 11
104, // h
101, // e
108, // l
108, // l
111, // o
32, // Space
119, // w
111, // o
114, // r
108, // l
100, // d
]);
const helloWorld = decodeCBOR(HELLO_WORLD_BYTES);
if ("hello world" == helloWorld) {
console.log("Success!");
}
This library is available on NPM and JSR.
This library is no longer automatically published to Deno's Third Party Modules. Newer versions may appear on deno.land/x, but do not work.
FAQs
Tiny CBOR library
We found that @levischuck/tiny-cbor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.