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

multicodec

Package Overview
Dependencies
Maintainers
6
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multicodec

JavaScript implementation of the multicodec specification

  • 3.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
637K
increased by16.69%
Maintainers
6
Weekly downloads
 
Created

What is multicodec?

The multicodec npm package is a self-describing multiformat, which is useful for identifying the format of a given piece of data. It is used extensively in the IPFS ecosystem to handle various data formats in a consistent manner.

What are multicodec's main functionalities?

Encoding and Decoding

This feature allows you to encode a buffer with a specific codec and decode it to find out the codec used. The `addPrefix` method adds a prefix to the buffer, and the `rmPrefix` method removes it.

const multicodec = require('multicodec');

// Encoding a buffer with a specific codec
const buffer = Buffer.from('hello world');
const encoded = multicodec.addPrefix('raw', buffer);
console.log(encoded);

// Decoding a buffer to find out the codec
const decoded = multicodec.rmPrefix(encoded);
console.log(decoded);

Listing Supported Codecs

This feature allows you to list all the supported codecs in the multicodec package. The `print` property contains a list of all the codecs.

const multicodec = require('multicodec');

// Listing all supported codecs
const codecs = multicodec.print;
console.log(codecs);

Resolving Codec Names and Codes

This feature allows you to resolve codec names to their corresponding codes and vice versa. The `getCodeVarint` method returns the code for a given codec name, and the `getName` method returns the name for a given codec code.

const multicodec = require('multicodec');

// Resolving codec name to code
const code = multicodec.getCodeVarint('dag-pb');
console.log(code);

// Resolving codec code to name
const name = multicodec.getName(0x70);
console.log(name);

Other packages similar to multicodec

Keywords

FAQs

Package last updated on 02 Sep 2021

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