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

Commit e5cb43c

Browse files
committed
refactor(clean-multihash): remove duplicate (old) cleanMultihash func
1 parent 43a1dfa commit e5cb43c

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

src/api/object.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const DAGLink = require('ipfs-merkle-dag').DAGLink
55
const promisify = require('promisify-es6')
66
const bs58 = require('bs58')
77
const bl = require('bl')
8+
const cleanMultihash = require('../clean-multihash')
89

910
module.exports = (send) => {
1011
const api = {
@@ -316,33 +317,3 @@ module.exports = (send) => {
316317

317318
return api
318319
}
319-
320-
// TODO verify if this is duplicated of clean-multihash.js
321-
function cleanMultihash (multihash, options) {
322-
if (Buffer.isBuffer(multihash)) {
323-
if (options.enc) {
324-
switch (options.enc) {
325-
case 'base58': {
326-
multihash = multihash.toString()
327-
break
328-
}
329-
default: throw new Error('invalid multihash')
330-
}
331-
} else {
332-
multihash = bs58.encode(multihash).toString()
333-
}
334-
} else if (typeof multihash === 'string') {
335-
if (options.enc) {
336-
// For the future, when we support more than one enc
337-
// switch (options.enc) {
338-
// case 'base58': // It is good
339-
// }
340-
} else {
341-
throw new Error('not valid multihash')
342-
}
343-
} else if (!multihash) {
344-
throw new Error('missing valid multihash')
345-
}
346-
347-
return multihash
348-
}

0 commit comments

Comments
 (0)