|
1 | 1 | export const TEXT_ENCODING_AVAILABLE = |
2 | | - process.env.TEXT_ENCODING !== "never" && typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined"; |
| 2 | + typeof process !== "undefined" && |
| 3 | + process.env.TEXT_ENCODING !== "never" && |
| 4 | + typeof TextEncoder !== "undefined" && |
| 5 | + typeof TextDecoder !== "undefined"; |
3 | 6 |
|
4 | 7 | export function utf8Count(str: string): number { |
5 | 8 | const strLength = str.length; |
@@ -85,7 +88,7 @@ export function utf8EncodeJs(str: string, output: Uint8Array, outputOffset: numb |
85 | 88 | } |
86 | 89 |
|
87 | 90 | const sharedTextEncoder = TEXT_ENCODING_AVAILABLE ? new TextEncoder() : undefined; |
88 | | -export const TEXT_ENCODER_THRESHOLD = process.env.TEXT_ENCODING !== "force" ? 200 : 0; |
| 91 | +export const TEXT_ENCODER_THRESHOLD = typeof process !== "undefined" && process.env.TEXT_ENCODING !== "force" ? 200 : 0; |
89 | 92 |
|
90 | 93 | function utf8EncodeTEencode(str: string, output: Uint8Array, outputOffset: number): void { |
91 | 94 | // eslint-disable-next-line @typescript-eslint/no-non-null-assertion |
@@ -151,7 +154,7 @@ export function utf8DecodeJs(bytes: Uint8Array, inputOffset: number, byteLength: |
151 | 154 | } |
152 | 155 |
|
153 | 156 | const sharedTextDecoder = TEXT_ENCODING_AVAILABLE ? new TextDecoder() : null; |
154 | | -export const TEXT_DECODER_THRESHOLD = process.env.TEXT_DECODER !== "force" ? 200 : 0; |
| 157 | +export const TEXT_DECODER_THRESHOLD = typeof process !== "undefined" && process.env.TEXT_DECODER !== "force" ? 200 : 0; |
155 | 158 |
|
156 | 159 | export function utf8DecodeTD(bytes: Uint8Array, inputOffset: number, byteLength: number): string { |
157 | 160 | const stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength); |
|
0 commit comments