Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/utils/utf8.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import { UINT32_MAX } from "./int";

const TEXT_ENCODING_AVAILABLE =
(typeof process === "undefined" || process.env["TEXT_ENCODING"] !== "never") &&
(typeof process === "undefined" || process?.env?.["TEXT_ENCODING"] !== "never") &&
typeof TextEncoder !== "undefined" &&
typeof TextDecoder !== "undefined";

Expand Down Expand Up @@ -91,7 +92,7 @@ export function utf8EncodeJs(str: string, output: Uint8Array, outputOffset: numb
const sharedTextEncoder = TEXT_ENCODING_AVAILABLE ? new TextEncoder() : undefined;
export const TEXT_ENCODER_THRESHOLD = !TEXT_ENCODING_AVAILABLE
? UINT32_MAX
: typeof process !== "undefined" && process.env["TEXT_ENCODING"] !== "force"
: typeof process !== "undefined" && process?.env?.["TEXT_ENCODING"] !== "force"
? 200
: 0;

Expand Down Expand Up @@ -159,7 +160,7 @@ export function utf8DecodeJs(bytes: Uint8Array, inputOffset: number, byteLength:
const sharedTextDecoder = TEXT_ENCODING_AVAILABLE ? new TextDecoder() : null;
export const TEXT_DECODER_THRESHOLD = !TEXT_ENCODING_AVAILABLE
? UINT32_MAX
: typeof process !== "undefined" && process.env["TEXT_DECODER"] !== "force"
: typeof process !== "undefined" && process?.env?.["TEXT_DECODER"] !== "force"
? 200
: 0;

Expand Down