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

@digitalcredentials/cborld

v4.3.4

Published

A CBOR-LD encoder/decoder for Javascript.

Downloads

341

Readme

JavaScript CBOR-LD Processor (@digitalcredentials/cborld)

Node.js CI NPM Version

A JavaScript CBOR-LD Process for Web browsers and Node.js apps.

Table of Contents

Background

(Forked from digitalbazaar/cborld v4 to provide TypeScript and ReactNative compatibility.)

This library provides a CBOR-LD Processor for Web browsers, React Native, and Node.js applications.

Install

NPM

npm install @digitalcredentials/cborld

Git

To install locally (for development):

git clone https://github.com/digitalcredentials/cborld.git
cd cborld
npm install

Usage

This library provides two primary functions for encoding and decoding CBOR-LD data.

Encode to CBOR-LD

To encode a JSON-LD document as CBOR-LD:

import {encode, documentLoader} from '@digitalcredentials/cborld';

const jsonldDocument = {
  '@context': 'https://www.w3.org/ns/activitystreams',
  type: 'Note',
  summary: 'CBOR-LD',
  content: 'CBOR-LD is awesome!'
};

// encode a JSON-LD Javascript object into CBOR-LD bytes
const cborldBytes = await encode({jsonldDocument, documentLoader});

To decode a CBOR-LD document to JSON-LD:

import {decode, documentLoader} from '@digitalcredentials/cborld';

// get the CBOR-LD bytes
const cborldBytes = await fs.promises.readFile('out.cborld');

// decode the CBOR-LD bytes into a Javascript object
const jsonldDocument = await cborld.decode({cborldBytes, documentLoader});

API

Functions

Typedefs

encode(options) ⇒ Promise<Uint8Array>

Encodes a given JSON-LD document into a CBOR-LD byte array.

Kind: global function Returns: Uint8Array - - The encoded CBOR-LD bytes.

decode(options) ⇒ Promise<object>

Decodes a CBOR-LD byte array into a JSON-LD document.

Kind: global function Returns: object - - The decoded JSON-LD Document.

diagnosticFunction : function

A diagnostic function that is called with diagnostic information. Typically set to console.log when debugging.

Kind: global typedef

documentLoaderFunction ⇒ string

Fetches a resource given a URL and returns it as a string.

Kind: global typedef Returns: string - The resource associated with the URL as a string.

Examples:

TBD

Contribute

Please follow the existing code style.

PRs accepted.

If editing the README, please conform to the standard-readme specification.

License

  • MIT License - DCC - TypeScript compatibility.
  • New BSD License (3-clause) © 2020-2021 Digital Bazaar - Initial implementation.