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

Commit

Permalink
fix: remove text decoder (#93)
Browse files Browse the repository at this point in the history
Use to-string function from uint8arrays module instead of creating
another text decoder which breaks on older node.
  • Loading branch information
achingbrain authored Aug 3, 2020
1 parent e4aad1f commit 91525fa
Showing 1 changed file with 2 additions and 3 deletions.
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

0 comments on commit 91525fa

Please sign in to comment.