Small adjustments for esm (& default build) (#798)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/x-textencoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Fallback from './fallback';
|
||||
import { TextDecoder as Fallback } from './fallback';
|
||||
|
||||
export default typeof TextDecoder === 'undefined'
|
||||
? Fallback as unknown as typeof TextDecoder
|
||||
: TextDecoder;
|
||||
export const TextDecoder = typeof global.TextDecoder === 'undefined'
|
||||
? Fallback as unknown as typeof global.TextDecoder
|
||||
: global.TextDecoder;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// This is very limited, only handling Ascii values
|
||||
export default class TextDecoder {
|
||||
export class TextDecoder {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-useless-constructor
|
||||
constructor (_: 'utf-8') {
|
||||
// nothing
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
import { TextDecoder as NodeTextDecoder } from 'util';
|
||||
|
||||
export default typeof TextDecoder === 'undefined'
|
||||
? NodeTextDecoder as unknown as typeof TextDecoder
|
||||
: TextDecoder;
|
||||
export const TextDecoder = typeof global.TextDecoder === 'undefined'
|
||||
? NodeTextDecoder as unknown as typeof global.TextDecoder
|
||||
: global.TextDecoder;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/x-textencoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import browser from './browser';
|
||||
|
||||
export default browser;
|
||||
export { TextDecoder } from './browser';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/x-textdecoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import BrowserTD from './browser';
|
||||
import NodeTD from './node';
|
||||
import { TextDecoder as BrowserTD } from './browser';
|
||||
import { TextDecoder as NodeTD } from './node';
|
||||
|
||||
console.log(new BrowserTD('utf-8').decode(new Uint8Array([1, 2, 3])));
|
||||
console.log(new NodeTD('utf-8').decode(new Uint8Array([1, 2, 3])));
|
||||
|
||||
Reference in New Issue
Block a user