TextEncoder/TextDecoder from polkadot-js (#686)
This commit is contained in:
@@ -1,21 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
let decoder: { decode: (value: Uint8Array) => string };
|
||||
import TextDecoder from '@polkadot/x-textdecoder';
|
||||
|
||||
function polyfilledDecode (value: Uint8Array): string {
|
||||
return value.reduce((str, code): string => {
|
||||
return str + String.fromCharCode(code);
|
||||
}, '');
|
||||
}
|
||||
|
||||
try {
|
||||
decoder = new TextDecoder('utf-8');
|
||||
} catch (error) {
|
||||
decoder = {
|
||||
decode: polyfilledDecode
|
||||
};
|
||||
}
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
|
||||
/**
|
||||
* @name u8aToString
|
||||
|
||||
Reference in New Issue
Block a user