RN-specific getRandomValues (no node crypto) (#747)
* RN-specific getRandomValues (no node crypto) * Use polyfilled as available * === object
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/x-textencoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default typeof TextDecoder === 'undefined'
|
||||
? class {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-useless-constructor
|
||||
constructor (_: 'utf-8') {
|
||||
// nothing
|
||||
}
|
||||
import Fallback from './fallback';
|
||||
|
||||
decode (value: Uint8Array): string {
|
||||
return value.reduce((str, code): string => {
|
||||
return str + String.fromCharCode(code);
|
||||
}, '');
|
||||
}
|
||||
}
|
||||
export default typeof TextDecoder === 'undefined'
|
||||
? Fallback
|
||||
: TextDecoder;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/x-textencoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default class TextDecoder {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-useless-constructor
|
||||
constructor (_: 'utf-8') {
|
||||
// nothing
|
||||
}
|
||||
|
||||
decode (value: Uint8Array): string {
|
||||
return value.reduce((str, code): string => {
|
||||
return str + String.fromCharCode(code);
|
||||
}, '');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user