Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
refactor(clean-multihash): remove duplicate (old) cleanMultihash func
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 15, 2016
1 parent 43a1dfa commit e5cb43c
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions src/api/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const DAGLink = require('ipfs-merkle-dag').DAGLink
const promisify = require('promisify-es6')
const bs58 = require('bs58')
const bl = require('bl')
const cleanMultihash = require('../clean-multihash')

module.exports = (send) => {
const api = {
Expand Down Expand Up @@ -316,33 +317,3 @@ module.exports = (send) => {

return api
}

// TODO verify if this is duplicated of clean-multihash.js
function cleanMultihash (multihash, options) {
if (Buffer.isBuffer(multihash)) {
if (options.enc) {
switch (options.enc) {
case 'base58': {
multihash = multihash.toString()
break
}
default: throw new Error('invalid multihash')
}
} else {
multihash = bs58.encode(multihash).toString()
}
} else if (typeof multihash === 'string') {
if (options.enc) {
// For the future, when we support more than one enc
// switch (options.enc) {
// case 'base58': // It is good
// }
} else {
throw new Error('not valid multihash')
}
} else if (!multihash) {
throw new Error('missing valid multihash')
}

return multihash
}

0 comments on commit e5cb43c

Please sign in to comment.