11const { Buffer, TextEncoder, TextDecoder } = globalThis
22const haveNativeBuffer = Buffer && ! Buffer . TYPED_ARRAY_SUPPORT
33export const nativeBuffer = haveNativeBuffer ? Buffer : null
4- export const isHermes = Boolean ( globalThis . HermesInternal )
5- export const isDeno = Boolean ( globalThis . Deno )
6- export const isLE = new Uint8Array ( Uint16Array . of ( 258 ) . buffer ) [ 0 ] === 2
4+ export const isHermes = ! ! globalThis . HermesInternal
5+ export const isDeno = ! ! globalThis . Deno
6+ export const isLE = /* @__PURE__ */ ( ( ) => new Uint8Array ( Uint16Array . of ( 258 ) . buffer ) [ 0 ] === 2 ) ( )
77
88// We consider Node.js TextDecoder/TextEncoder native
99let isNative = ( x ) => x && ( haveNativeBuffer || `${ x } ` . includes ( '[native code]' ) )
@@ -17,16 +17,19 @@ export const nativeDecoder = isNative(TextDecoder)
1717// Actually windows-1252, compatible with ascii and latin1 decoding
1818// Beware that on non-latin1, i.e. on windows-1252, this is broken in ~all Node.js versions released
1919// in 2025 due to a regression, so we call it Latin1 as it's usable only for that
20- let nativeDecoderLatin1impl = null
21- if ( nativeDecoder ) {
20+ const getNativeLain1 = ( ) => {
2221 // Not all barebone engines with TextDecoder support something except utf-8, detect
23- try {
24- nativeDecoderLatin1impl = new TextDecoder ( 'latin1' , { ignoreBOM : true } )
25- } catch { }
22+ if ( ! nativeDecoder ) {
23+ try {
24+ return new TextDecoder ( 'latin1' , { ignoreBOM : true } )
25+ } catch { }
26+ }
27+
28+ return null
2629}
2730
28- export const nativeDecoderLatin1 = nativeDecoderLatin1impl
29- export const canDecoders = Boolean ( nativeDecoderLatin1impl )
31+ export const nativeDecoderLatin1 = /* @__PURE__ */ getNativeLain1 ( )
32+ export const canDecoders = ! ! nativeDecoderLatin1
3033
3134// Block Firefox < 146 specifically from using native hex/base64, as it's very slow there
3235// Refs: https://bugzilla.mozilla.org/show_bug.cgi?id=1994067 (and linked issues), fixed in 146
@@ -51,7 +54,7 @@ function shouldSkipBuiltins() {
5154 return false // eslint-disable-line no-unreachable
5255}
5356
54- export const skipWeb = shouldSkipBuiltins ( )
57+ export const skipWeb = /* @__PURE__ */ shouldSkipBuiltins ( )
5558
5659function decodePartAddition ( a , start , end , m ) {
5760 let o = ''
0 commit comments