Skip to content
This repository was archived by the owner on Aug 24, 2021. It is now read-only.

fix: remove text decoder #93

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const uint8ArrayToString = require('uint8arrays/to-string')
const uint8ArrayFromString = require('uint8arrays/from-string')
const uint8ArrayConcat = require('uint8arrays/concat')

const textDecoder = new TextDecoder()
const codes = {}

for (const key in names) {
Expand Down Expand Up @@ -58,7 +57,7 @@ exports.toB58String = function toB58String (hash) {
throw new Error('must be passed a Uint8Array')
}

return textDecoder.decode(multibase.encode('base58btc', hash)).slice(1)
return uint8ArrayToString(multibase.encode('base58btc', hash)).slice(1)
}

/**
Expand All @@ -69,7 +68,7 @@ exports.toB58String = function toB58String (hash) {
*/
exports.fromB58String = function fromB58String (hash) {
const encoded = hash instanceof Uint8Array
? textDecoder.decode(hash)
? uint8ArrayToString(hash)
: hash

return multibase.decode('z' + encoded)
Expand Down