Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions borsh-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import bs58 from "bs58";

// TODO: Make sure this polyfill not included when not required
import * as encoding from "text-encoding-utf-8";
const TextDecoder =
typeof (global as any).TextDecoder !== "function"
const ResolvedTextDecoder =
typeof TextDecoder !== "function"
? encoding.TextDecoder
: (global as any).TextDecoder;
const textDecoder = new TextDecoder("utf-8", { fatal: true });
: TextDecoder;
const textDecoder = new ResolvedTextDecoder("utf-8", { fatal: true });

export function baseEncode(value: Uint8Array | string): string {
if (typeof value === "string") {
Expand Down
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const bn_js_1 = __importDefault(require("bn.js"));
const bs58_1 = __importDefault(require("bs58"));
// TODO: Make sure this polyfill not included when not required
const encoding = __importStar(require("text-encoding-utf-8"));
const TextDecoder = typeof global.TextDecoder !== "function"
const ResolvedTextDecoder = typeof TextDecoder !== "function"
? encoding.TextDecoder
: global.TextDecoder;
const textDecoder = new TextDecoder("utf-8", { fatal: true });
: TextDecoder;
const textDecoder = new ResolvedTextDecoder("utf-8", { fatal: true });
function baseEncode(value) {
if (typeof value === "string") {
value = Buffer.from(value, "utf8");
Expand Down