spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / git / parse / is-whole-listing / is-under-utf8-ceiling / is-under-utf8-ceiling.ts
13 lines · 465 BRaw
1import { MOST_UTF8_BYTES } from '../most-utf8-bytes'
2
3/**
4 * Whether the text's UTF-8 encoding stays under a byte count, encoding it
5 * only when its length alone cannot already say so.
6 *
7 * @param text the text
8 * @param ceiling the byte count it must stay under
9 * @returns whether it is under
10 */
11export const isUnderUtf8Ceiling = (text: string, ceiling: number) =>
12 text.length * MOST_UTF8_BYTES < ceiling ||
13 new TextEncoder().encode(text).length < ceiling