Socket
Socket
Sign inDemoInstall

multicodec

Package Overview
Dependencies
1
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.1.0

32

lib/base-table.js

@@ -5,2 +5,6 @@ 'use strict';

// spec and table at: https://github.com/multiformats/multicodec
// TODO revisit all of these once https://github.com/multiformats/multicodec/pull/16 is merged
exports = module.exports;

@@ -11,6 +15,3 @@

// Multiformats
exports.multicodec = varintBuf(64); // 0x40
exports.multihash = varintBuf(65); // 0x41
exports.multiaddr = varintBuf(66); // 0x42
// bases encodings

@@ -22,4 +23,27 @@ // Serialization formats

// Multiformats
exports.multicodec = varintBuf(64); // 0x40
exports.multihash = varintBuf(65); // 0x41
exports.multiaddr = varintBuf(66); // 0x42
// multihashes
// multiaddrs
// archiving formats
// image formats
// video formats
// VCS formats
// IPLD formats
exports['dag-pb'] = new Buffer('70', 'hex');
exports['dag-cbor'] = new Buffer('71', 'hex');
exports['eth-block'] = new Buffer('90', 'hex');
exports['eth-tx'] = new Buffer('91', 'hex');
function varintBuf(n) {
return new Buffer(varint.encode(n));
}

13

lib/index.js

@@ -29,8 +29,13 @@ 'use strict';

exports.getCodec = function (prefixedData) {
var code = new Buffer(varint.decode(prefixedData));
Object.keys(table).forEach(function (multicodec) {
if (Buffer.isEqual(code, table[multicodec])) {
return multicodec;
var v = varint.decode(prefixedData);
var code = new Buffer(v.toString(16), 'hex');
var codec = void 0;
Object.keys(table).forEach(function (mc) {
if (code.equals(table[mc])) {
codec = mc;
}
});
return codec;
};
{
"name": "multicodec",
"version": "0.0.1",
"version": "0.1.0",
"description": "JavaScript implementation of the multicodec-packed specification",

@@ -47,2 +47,3 @@ "main": "lib/index.js",

"aegir": "^8.1.1",
"chai": "^3.5.0",
"pre-commit": "^1.1.3"

@@ -49,0 +50,0 @@ },

@@ -5,2 +5,6 @@ 'use strict'

// spec and table at: https://github.com/multiformats/multicodec
// TODO revisit all of these once https://github.com/multiformats/multicodec/pull/16 is merged
exports = module.exports

@@ -11,6 +15,3 @@

// Multiformats
exports.multicodec = varintBuf(64) // 0x40
exports.multihash = varintBuf(65) // 0x41
exports.multiaddr = varintBuf(66) // 0x42
// bases encodings

@@ -22,4 +23,27 @@ // Serialization formats

// Multiformats
exports.multicodec = varintBuf(64) // 0x40
exports.multihash = varintBuf(65) // 0x41
exports.multiaddr = varintBuf(66) // 0x42
// multihashes
// multiaddrs
// archiving formats
// image formats
// video formats
// VCS formats
// IPLD formats
exports['dag-pb'] = new Buffer('70', 'hex')
exports['dag-cbor'] = new Buffer('71', 'hex')
exports['eth-block'] = new Buffer('90', 'hex')
exports['eth-tx'] = new Buffer('91', 'hex')
function varintBuf (n) {
return new Buffer(varint.encode(n))
}

@@ -29,9 +29,14 @@ 'use strict'

exports.getCodec = (prefixedData) => {
const code = new Buffer(varint.decode(prefixedData))
const v = varint.decode(prefixedData)
const code = new Buffer(v.toString(16), 'hex')
let codec
Object.keys(table)
.forEach((multicodec) => {
if (Buffer.isEqual(code, table[multicodec])) {
return multicodec
.forEach((mc) => {
if (code.equals(table[mc])) {
codec = mc
}
})
return codec
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc