()
| 22 | const APPROX_ENCODING = "approx-4"; |
| 23 | |
| 24 | function shouldUseApproxTokenizer(): boolean { |
| 25 | // MUX_FORCE_REAL_TOKENIZER=1 overrides approx mode (for tests that need real tokenization) |
| 26 | // MUX_APPROX_TOKENIZER=1 enables fast approximate mode (default in Jest) |
| 27 | if (process.env.MUX_FORCE_REAL_TOKENIZER === "1") { |
| 28 | return false; |
| 29 | } |
| 30 | return process.env.MUX_APPROX_TOKENIZER === "1"; |
| 31 | } |
| 32 | |
| 33 | function approximateCount(text: string): number { |
| 34 | if (typeof text !== "string" || text.length === 0) { |
no outgoing calls
no test coverage detected