Skip to content

Commit b4db03e

Browse files
committed
refactor: minor code simplification
1 parent 8eea242 commit b4db03e

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

fallback/_utils.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ export const isHermes = Boolean(globalThis.HermesInternal)
55
export const isDeno = Boolean(globalThis.Deno)
66
export const isLE = new Uint8Array(Uint16Array.of(258).buffer)[0] === 2
77

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-
8+
// We consider Node.js TextDecoder/TextEncoder native
9+
let isNative = (x) => x && (haveNativeBuffer || `${x}`.includes('[native code]'))
1410
if (!haveNativeBuffer && isNative(() => {})) isNative = () => false // e.g. XS, we don't want false positives
1511

1612
export const nativeEncoder = isNative(TextEncoder) ? new TextEncoder() : null

0 commit comments

Comments
 (0)