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

@ipld/codec-interface

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/codec-interface

Codec interface for IPLD.

  • 1.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
324
increased by184.21%
Maintainers
3
Weekly downloads
 
Created
Source

Install

npm install @ipld/codec-interface

Codec Interface

This is the primary interface for implementing new codecs.

The interface is quite simple:

{
  encode: Function,
  decode: Function,
  codec: String,
  reader: Function
}

encode & decode

These are the primary methods you need to implement in order to implement a new codec.

While you can implement the entire Reader interface yourself, you can actually leverage our codec-interface.create utility to get a full implementation with these methods alone.

  • encode takes a native JavaScript object and returns a binary encoding.
  • decode takes a binary encoding and returns a nativfe JavaScript object.

Methods can be either synchronous or asynchronous (returns a promise).

reader(block)

The reader function accepts a Block instance and returns a full Reader interface.

This method can be either synchronous or asynchronous (returns a promise).

codec-interface.create(encode, decode, codecName)

Returns a full Codec Interface based on your encode and decode implementations.

Reader()

Reader.get(path

Returns a generator of all the links in the block.

Reader.tree()

FAQs

Package last updated on 17 Jan 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