Move @polkadot/x-{fetch,textdecoder,textencoder,ws} (#737)
* Move @polkadot/x-{fetch,textdecoder,textencoder,ws}
* Adjust copyrights
* Fix jest aliassing
* tsconfig resolution
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// Copyright 2017-2020 @polkadot/x-textencoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TextEncoder as NodeTextEncoder } from 'util';
|
||||
|
||||
export default typeof TextEncoder === 'undefined'
|
||||
? class {
|
||||
#encoder: NodeTextEncoder;
|
||||
|
||||
constructor () {
|
||||
this.#encoder = new NodeTextEncoder();
|
||||
}
|
||||
|
||||
// For a Jest 26.0.1 environment, Buffer !== Uint8Array
|
||||
encode (value: string): Uint8Array {
|
||||
const encoded = this.#encoder.encode(value);
|
||||
|
||||
return Uint8Array.from(encoded);
|
||||
}
|
||||
} as unknown as typeof TextEncoder
|
||||
: TextEncoder;
|
||||
Reference in New Issue
Block a user