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

Commit 91525fa

Browse files
authored
fix: remove text decoder (#93)
Use to-string function from uint8arrays module instead of creating another text decoder which breaks on older node.
1 parent e4aad1f commit 91525fa

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const uint8ArrayToString = require('uint8arrays/to-string')
1414
const uint8ArrayFromString = require('uint8arrays/from-string')
1515
const uint8ArrayConcat = require('uint8arrays/concat')
1616

17-
const textDecoder = new TextDecoder()
1817
const codes = {}
1918

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

61-
return textDecoder.decode(multibase.encode('base58btc', hash)).slice(1)
60+
return uint8ArrayToString(multibase.encode('base58btc', hash)).slice(1)
6261
}
6362

6463
/**
@@ -69,7 +68,7 @@ exports.toB58String = function toB58String (hash) {
6968
*/
7069
exports.fromB58String = function fromB58String (hash) {
7170
const encoded = hash instanceof Uint8Array
72-
? textDecoder.decode(hash)
71+
? uint8ArrayToString(hash)
7372
: hash
7473

7574
return multibase.decode('z' + encoded)

0 commit comments

Comments
 (0)