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

@ipld/dag-cbor

Package Overview
Dependencies
Maintainers
3
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

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
110K
increased by2.03%
Maintainers
3
Weekly downloads
 
Created
Source

@ipld/dag-cbor

JS implementation of dag-cbor.

This is the new interface meant for use with multiformats and @ipld/block. It is not used by js-ipld-format which is currently used in IPFS. That library is here.

Usage (w/ Block Interface):

const multiformats = require('multiformats/basics')
multiformats.add(require('@ipld/dag-cbor'))
const Block = require('@ipld/block')(multiformats)
const { CID } = multiformats

const obj = {
  x: 1,
  /* CID instances are encoded as links */
  y: [2, 3, new CID('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4')],
  z: {
    a: new CID('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4'),
    b: null,
    c: 'string'
  }
}

let encoder = Block.encoder(obj, 'dag-json')
let encoded = await Block.encode() // binary encoded block
let decoded = await Block.decoder(encoded, 'dag-json').decode()
decoded.y[0] // 2
CID.isCID(decoded.z.a) // true

Keywords

FAQs

Package last updated on 18 Jun 2020

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