Skip to content

Commit

Permalink
Merge pull request #3 from multiformats/fix/getCodec
Browse files Browse the repository at this point in the history
fix: getCodec, return codec
  • Loading branch information
daviddias authored Oct 2, 2016
2 parents 4e146c1 + 0fff927 commit 66b361d
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 66b361d

Please sign in to comment.