npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cbor-redux

v1.0.0

Published

The Concise Binary Object Representation (CBOR) data format (RFC7049) implemented in pure JavaScript, revived.

Downloads

10,176

Readme

cbor-redux

The Concise Binary Object Representation (CBOR) data format (RFC 8949) implemented in pure JavaScript with an API surface like the built-in JSON functions. Rewritten in TypeScript for the browser, Deno, and Node.

GitHub last commit GitHub contributors npm collaborators GitHub top language npm bundle size GitHub code size in bytes npm NPM Quality Gate Status Maintainability Rating Security Rating Coverage

Using CBOR

Like the JSON API, this library is synchronous. Simply import into your runtime: Deno, browser, Node ESM, or Node CommonJS.

// This is an example Deno import statement.
import { CBOR } from "https://deno.land/x/[email protected]/mod.ts";

const initial = { Hello: "World", how: "are you?" };
const encoded = CBOR.encode(initial, ["Hello"]);
const decoded = CBOR.decode(encoded);
console.log(decoded); // Output: { Hello: "World" }

Unrecognized CBOR tags will be emitted as instances of TaggedValue, allowing an application to use custom handling. Simple values in CBOR that are reserved or unassigned will be emitted as instances of SimpleValue so that they may be handled directly.

Browser imports are provided in the web directory; web/mod.js uses module exports and web/polyfill.js is classic JS that attaches as a global variable CBOR. Recommended installation is self-hosted, but versioned releases can be script-tagged or imported from https://deno.land/x/cbor_redux for development.

For users who need more power and control, the entire library API is documented at doc.deno.land.

Supported Features

  • Concise Binary Object Representation (RFC 8949)
  • CBOR Sequences (RFC 8742)
  • Proper support for large integers; integers larger than a JavaScript number may safely hold will be decoded as bigint. Values of bigint will be encoded when provided by the application.
  • Typed Arrays (RFC 8746)
  • Tags (RFC 8949)
  • Simple Values (RFC 8949)
  • Rejection with mode: 'strict' of duplicate keys in key/value dictionaries (RFC 8152)
  • Preferred serialization
  • "deterministic encoding" per spec in RFC 8949

Contributing code and issues

Issues

Please report bugs! I maintain this library in my free time, so please do not expect immediate turn-around for your bug.

Feel free to drop an issue abotu a missing feature of CBOR. Please reference the appropriate RFC number and explain how you believe the library should behave.

No matter why you're opening an issue, please provide:

  • The environment OS
  • The JavaScript runtime, and version
  • An example working piece of code that reproduces your issue.

Code

This project accepts pull requests! If you have a fix for a bug or an implementation of a CBOR feature, bring it. You'll be credited here in the readme.

Ground rules:

  1. Please adhere to the Contributor Covenant v2.1
  2. Use vanilla TypeScript; no explicit Node, Deno, or browser references permitted except for tests
  3. Reference an open issue; if one does not exist, please create one

If you have a history of commits and would like maintianer status to help triage issues and deploy code faster, please open an issue requesting access. Don't be put off by the fact that this codebase targets Deno. It is compiled and released for browser and Node; Deno is not a hard prerequisite for contributing (but it does help).

Contributors

  • Patrick Gansterer (paroga): Original author
  • Aaron Huggins (aaronhuggins): Fork maintainer
  • Maik Riechert (letmaik): Added support for Node
  • Sangwhan Moon (cynthia): Performance improvements
  • Kevin Wooten (kdubb): Added TaggedValue feature
  • Glenn Engel (glenne): Support for Typed Arrays
  • Matt Vollrath (mvollrath): Optimized byte array encoding
  • Sami Vaarala (svaarala): Fixed bug in codepoint handling
  • Timothy Cyrus (tcyrus): Various quality improvements
  • Benny Neugebauer (bennycode): Various quality improvements
  • Tyler Young: Various quality improvements