Skip to content

Commit

Permalink
fix: getCodec, return codec
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Oct 2, 2016
1 parent 4e146c1 commit 0fff927
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ exports.rmPrefix = (data) => {

exports.getCodec = (prefixedData) => {
const code = new Buffer(varint.decode(prefixedData))

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
}

0 comments on commit 0fff927

Please sign in to comment.