Skip to content

Commit

Permalink
Use UTF-8 only TextEncoder polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Nov 19, 2019
1 parent e3ec78c commit 15df785
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/utils/serialize.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"http-errors": "^1.7.2",
"js-sha256": "^0.9.0",
"node-fetch": "^2.3.0",
"text-encoding": "^0.7.0",
"text-encoding-utf-8": "^1.0.2",
"tweetnacl": "^1.0.1",
"typescript": "^3.5.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src.ts/utils/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import bs58 from 'bs58';
import BN from 'bn.js';

// TODO: Make sure this polyfill not included when not required
import * as encoding from 'text-encoding';
import * as encoding from 'text-encoding-utf-8';
if (typeof (global as any).TextDecoder !== 'function') {
(global as any).TextDecoder = encoding.TextDecoder;
}

const textDecoder = new TextDecoder('utf8', { fatal: true });
const textDecoder = new TextDecoder('utf-8', { fatal: true });

export function base_encode(value: Uint8Array | string): string {
if (typeof(value) === 'string') {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 15df785

Please sign in to comment.