Small adjustments for esm (& default build) (#798)

This commit is contained in:
Jaco Greeff
2020-12-11 17:08:16 +01:00
committed by GitHub
parent 28b2435019
commit 4c02b25a2d
40 changed files with 101 additions and 94 deletions
+4 -4
View File
@@ -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;
+1 -1
View File
@@ -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 -3
View File
@@ -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 -3
View File
@@ -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';
+2 -2
View File
@@ -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])));