{"id":19122933,"url":"https://github.com/digitalbazaar/cborld","last_synced_at":"2025-04-06T23:17:43.918Z","repository":{"id":38172148,"uuid":"278740412","full_name":"digitalbazaar/cborld","owner":"digitalbazaar","description":"A Javascript CBOR-LD processor for web browsers and Node.js apps.","archived":false,"fork":false,"pushed_at":"2024-10-22T01:45:19.000Z","size":504,"stargazers_count":25,"open_issues_count":21,"forks_count":18,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-30T21:12:31.815Z","etag":null,"topics":["cbor","cborld","jsonld","linked-data"],"latest_commit_sha":null,"homepage":"https://json-ld.github.io/cbor-ld-spec/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalbazaar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-10T21:54:38.000Z","updated_at":"2025-03-11T16:17:54.000Z","dependencies_parsed_at":"2023-12-06T03:04:54.011Z","dependency_job_id":"f2d61be2-f682-48f3-8568-50a25e156fee","html_url":"https://github.com/digitalbazaar/cborld","commit_stats":{"total_commits":268,"total_committers":8,"mean_commits":33.5,"dds":0.6417910447761195,"last_synced_commit":"b6fde00c65d5b2adf5fd1bd2849d353a2320f2dc"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fcborld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fcborld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fcborld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fcborld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalbazaar","download_url":"https://codeload.github.com/digitalbazaar/cborld/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247563941,"owners_count":20958971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cbor","cborld","jsonld","linked-data"],"created_at":"2024-11-09T05:23:40.113Z","updated_at":"2025-04-06T23:17:43.893Z","avatar_url":"https://github.com/digitalbazaar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JavaScript CBOR-LD Processor\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/digitalbazaar/cborld/main.yml)](https://github.com/digitalbazaar/cborld/actions/workflows/main.yml)\n[![Coverage Status](https://img.shields.io/codecov/c/github/digitalbazaar/cborld)](https://codecov.io/gh/digitalbazaar/cborld)\n\n\u003e A JavaScript CBOR-LD Process for Web browsers and Node.js apps.\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n- [Contribute](#contribute)\n- [Commercial Support](#commercial-support)\n- [License](#license)\n\n## Background\n\nThis library provides a CBOR-LD Processor for Web browsers and Node.js\napplications.\n\n## Install\n\n- Browsers and Node.js 18+ are supported.\n\n### NPM\n\n```\nnpm install @digitalbazaar/cborld\n```\n\n### Git\n\nTo install locally (for development):\n\n```\ngit clone https://github.com/digitalbazaar/cborld.git\ncd cborld\nnpm install\n```\n\n## Usage\n\nThis library provides two primary functions for encoding and decoding\nCBOR-LD data.\n\n### Encode to CBOR-LD\n\nTo encode a JSON-LD document as CBOR-LD:\n\n```js\nimport {encode} from '@digitalbazaar/cborld';\n\nconst jsonldDocument = {\n  '@context': 'https://www.w3.org/ns/activitystreams',\n  type: 'Note',\n  summary: 'CBOR-LD',\n  content: 'CBOR-LD is awesome!'\n};\n\n// encode a JSON-LD Javascript object into CBOR-LD bytes\n// Note: user must provide their own JSON-LD `documentLoader`\nconst cborldBytes = await encode({jsonldDocument, documentLoader});\n```\n\nTo decode a CBOR-LD document to JSON-LD:\n\n```js\nimport {decode} from '@digitalbazaar/cborld';\n\n// get the CBOR-LD bytes\nconst cborldBytes = await fs.promises.readFile('out.cborld');\n\n// decode the CBOR-LD bytes into a Javascript object\n// Note: user must provide their own JSON-LD `documentLoader`\nconst jsonldDocument = await cborld.decode({cborldBytes, documentLoader});\n```\n\n## API\n\n**NOTE**: Please check `encode.js` and `decode.js` for the latest API options.\n\n### Functions\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#encode\"\u003eencode(options)\u003c/a\u003e ⇒ \u003ccode\u003eUint8Array\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\n  \u003cp\u003eEncodes a given JSON-LD document into a CBOR-LD byte array.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#decode\"\u003edecode(options)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\n  \u003cp\u003eDecodes a CBOR-LD byte array into a JSON-LD document.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n### Typedefs\n\n\u003cdl\u003e \u003cdt\u003e\u003ca href=\"#diagnosticFunction\"\u003ediagnosticFunction\u003c/a\u003e :\n    \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n  \u003cdd\u003e\n    \u003cp\u003eA diagnostic function that is called with\n      diagnostic information. Typically set to \u003ccode\u003econsole.log\u003c/code\u003e when\n      debugging.\u003c/p\u003e\n  \u003c/dd\u003e \u003cdt\u003e\u003ca href=\"#documentLoaderFunction\"\u003edocumentLoaderFunction\u003c/a\u003e ⇒\n    \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n  \u003cdd\u003e\n    \u003cp\u003eFetches a resource given a URL and returns it\n      as a string.\u003c/p\u003e\n  \u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"encode\"\u003e\u003c/a\u003e\n\n### encode(options) ⇒ \u003ccode\u003ePromise\u0026lt;Uint8Array\u003e\u003c/code\u003e\nEncodes a given JSON-LD document into a CBOR-LD byte array.\n\n**Kind**: global function\n**Returns**: \u003ccode\u003eUint8Array\u003c/code\u003e - - The encoded CBOR-LD bytes.\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eParam\u003c/th\u003e\n      \u003cth\u003eType\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eoptions\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eobject\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eThe\n          options to use when encoding to CBOR-LD.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eoptions.jsonldDocument\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eobject\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eThe JSON-LD\n          Document to convert to CBOR-LD bytes.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eoptions.documentLoader\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\u003ca href=\"#documentLoaderFunction\"\u003edocumentLoaderFunction\u003c/a\u003e\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eThe document loader to use when resolving JSON-LD Context URLs.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e[options.appContextMap]\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eMap\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eA map of JSON-LD Context URLs and their encoded CBOR-LD values\n          (must be values greater than 32767 (0x7FFF)).\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e[options.appTermMap]\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eMap\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eA map of JSON-LD terms and their associated\n          CBOR-LD term codecs.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e[options.diagnose]\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\u003ca href=\"#diagnosticFunction\"\u003ediagnosticFunction\u003c/a\u003e\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eA function that, if provided, is called with diagnostic\n        information.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003ca name=\"decode\"\u003e\u003c/a\u003e\n\n### decode(options) ⇒ \u003ccode\u003ePromise\u0026lt;object\u003e\u003c/code\u003e\nDecodes a CBOR-LD byte array into a JSON-LD document.\n\n**Kind**: global function\n**Returns**: \u003ccode\u003eobject\u003c/code\u003e - - The decoded JSON-LD Document.\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eParam\u003c/th\u003e\n      \u003cth\u003eType\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eoptions\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eobject\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eThe options to use when decoding CBOR-LD.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eoptions.cborldBytes\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eUint8Array\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eThe encoded CBOR-LD bytes to\n          decode.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eoptions.documentLoader\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003efunction\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eThe document loader to use when\n          resolving JSON-LD Context URLs.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e[options.appContextMap]\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eMap\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eA map of JSON-LD Context URLs and\n          their associated CBOR-LD values. The values must be greater than\n          32767 (0x7FFF)).\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e[options.appTermMap]\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eMap\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eA map of JSON-LD terms and\n          their associated CBOR-LD term codecs.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e[options.diagnose]\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\u003ca href=\"#diagnosticFunction\"\u003ediagnosticFunction\u003c/a\u003e\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eA function that, if\n          provided, is called with diagnostic information.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003ca name=\"diagnosticFunction\"\u003e\u003c/a\u003e\n\n### diagnosticFunction : \u003ccode\u003efunction\u003c/code\u003e\nA diagnostic function that is called with diagnostic information. Typically\nset to `console.log` when debugging.\n\n**Kind**: global typedef\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eParam\u003c/th\u003e\u003cth\u003eType\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n\u003ctr\u003e\n    \u003ctd\u003emessage\u003c/td\u003e\u003ctd\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003cp\u003eThe diagnostic message.\u003c/p\u003e\n\u003c/td\u003e\n    \u003c/tr\u003e  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ca name=\"documentLoaderFunction\"\u003e\u003c/a\u003e\n\n### documentLoaderFunction ⇒ \u003ccode\u003estring\u003c/code\u003e\nFetches a resource given a URL and returns it as a string.\n\n**Kind**: global typedef\n**Returns**: \u003ccode\u003estring\u003c/code\u003e - The resource associated with the URL as a string.\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eParam\u003c/th\u003e\n      \u003cth\u003eType\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003eurl\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eThe URL to retrieve.\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\nExamples:\n\n```\nTBD\n```\n\n## Contribute\n\nPlease follow the existing code style.\n\nPRs accepted.\n\nIf editing the README, please conform to the\n[standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n## Commercial Support\n\nCommercial support for this library is available upon request from\nDigital Bazaar: support@digitalbazaar.com\n\n## License\n\n[BSD-3-Clause](LICENSE.md) © Digital Bazaar\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbazaar%2Fcborld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalbazaar%2Fcborld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbazaar%2Fcborld/lists"}