From 0fff927daaed3922d17aff9b7253db679298d79e Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 2 Oct 2016 13:44:14 +0100 Subject: [PATCH] fix: getCodec, return codec --- src/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index a762484..0ab7ccf 100644 --- a/src/index.js +++ b/src/index.js @@ -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 }