multicodec
Version:
JavaScript implementation of the multicodec specification
83 lines (53 loc) • 2.84 kB
Markdown
[](https://protocol.ai)
[](https://github.com/multiformats/multiformats)
[](https://webchat.freenode.net/?channels=%23ipfs)
[](https://github.com/RichardLitt/standard-readme)


> JavaScript implementation of the multicodec specification
[](http://github.com/hacdias)
- [Install](
- [Usage](
- [Example](
- [API](
- [Updating the lookup table](
- [Contribute](
- [License](
```sh
> npm install multicodec
```
The type definitions for this package are available on http://definitelytyped.org/. To install just use:
```sh
$ npm install -D @types/multicodec
```
```JavaScript
const multicodec = require('multicodec')
const prefixedProtobuf = multicodec.addPrefix('protobuf', protobufBuffer)
// prefixedProtobuf 0x50...
// The multicodec codec values can be accessed directly:
console.log(multicodec.DAG_CBOR)
// 113
// To get the string representation of a codec, e.g. for error messages:
console.log(multicodec.print[113])
// dag-cbor
```
https://multiformats.github.io/js-multicodec/
[](https://github.com/multiformats/multicodec/blob/master/table.csv)
Updating the lookup table is done with a script. The source of truth is the
[](https://github.com/multiformats/multicodec/blob/master/table.csv).
Update the table with running:
npm run update-table
Contributions welcome. Please check out [the issues](https://github.com/multiformats/js-multicodec/issues).
Check out our [contributing document](https://github.com/multiformats/multiformats/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
[](LICENSE) © 2016 Protocol Labs Inc.