We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8eea242 commit b4db03eCopy full SHA for b4db03e
1 file changed
fallback/_utils.js
@@ -5,12 +5,8 @@ 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
7
8
-let isNative = (x) => {
9
- if (!x) return false
10
- if (haveNativeBuffer) return true // we consider Node.js TextDecoder/TextEncoder native
11
- return `${x}`.includes('[native code]')
12
-}
13
-
+// We consider Node.js TextDecoder/TextEncoder native
+let isNative = (x) => x && (haveNativeBuffer || `${x}`.includes('[native code]'))
14
if (!haveNativeBuffer && isNative(() => {})) isNative = () => false // e.g. XS, we don't want false positives
15
16
export const nativeEncoder = isNative(TextEncoder) ? new TextEncoder() : null
0 commit comments