Adjust & dedupe global extraction tests (#1301)
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/x-textencoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
import { extractGlobal } from '@polkadot/x-global';
|
||||
|
||||
import { TextDecoder as Fallback } from './fallback';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const TextDecoder = (
|
||||
typeof xglobal.TextDecoder === 'undefined'
|
||||
? Fallback as unknown as typeof xglobal.TextDecoder
|
||||
: xglobal.TextDecoder
|
||||
);
|
||||
export const TextDecoder = extractGlobal('TextDecoder', Fallback);
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
|
||||
import util from 'util';
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
import { extractGlobal } from '@polkadot/x-global';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export const TextDecoder = (
|
||||
typeof xglobal.TextDecoder === 'undefined'
|
||||
? util.TextDecoder as unknown as typeof xglobal.TextDecoder
|
||||
: xglobal.TextDecoder
|
||||
);
|
||||
export const TextDecoder = extractGlobal('TextDecoder', util.TextDecoder);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/x-textdecoder authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
import { exposeGlobal } from '@polkadot/x-global';
|
||||
import { TextDecoder } from '@polkadot/x-textdecoder';
|
||||
|
||||
if (typeof xglobal.TextDecoder !== 'function') {
|
||||
(xglobal as Record<string, unknown>).TextDecoder = TextDecoder;
|
||||
}
|
||||
exposeGlobal('TextDecoder', TextDecoder);
|
||||
|
||||
Reference in New Issue
Block a user