Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ipld/dag-cbor

Package Overview
Dependencies
Maintainers
9
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/dag-cbor

JS implementation of DAG-CBOR

  • 9.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111K
decreased by-8.37%
Maintainers
9
Weekly downloads
 
Created

What is @ipld/dag-cbor?

@ipld/dag-cbor is an npm package that provides tools for encoding and decoding data in the CBOR (Concise Binary Object Representation) format, specifically tailored for use with the InterPlanetary Linked Data (IPLD) system. It allows for efficient and compact serialization of data structures, making it suitable for use in distributed systems and blockchain technologies.

What are @ipld/dag-cbor's main functionalities?

Encoding Data

This feature allows you to encode a JavaScript object into CBOR format. The `serialize` method converts the object into a binary representation.

const dagCBOR = require('@ipld/dag-cbor');
const data = { hello: 'world' };
const encoded = dagCBOR.util.serialize(data);
console.log(encoded);

Decoding Data

This feature allows you to decode CBOR data back into a JavaScript object. The `deserialize` method takes a binary representation and converts it back into a readable object.

const dagCBOR = require('@ipld/dag-cbor');
const encoded = new Uint8Array([161, 101, 104, 101, 108, 108, 111, 101, 119, 111, 114, 108, 100]);
const decoded = dagCBOR.util.deserialize(encoded);
console.log(decoded);

CID Generation

This feature allows you to generate a Content Identifier (CID) for a given piece of data. The CID is a unique identifier used in IPLD to reference data objects.

const dagCBOR = require('@ipld/dag-cbor');
const CID = require('cids');
const data = { hello: 'world' };
const encoded = dagCBOR.util.serialize(data);
const cid = new CID(1, 'dag-cbor', dagCBOR.util.cid(encoded));
console.log(cid.toString());

Other packages similar to @ipld/dag-cbor

Keywords

FAQs

Package last updated on 30 Jan 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc