MCPcopy Create free account
hub / github.com/Noumena-Network/code / wrapText

Function wrapText

src/ink/wrap-text.ts:53–69  ·  view source on GitHub ↗
(
  text: string,
  maxWidth: number,
  wrapType: Styles['textWrap'],
)

Source from the content-addressed store, hash-verified

51}
52
53export default function wrapText(
54 text: string,
55 maxWidth: number,
56 wrapType: Styles['textWrap'],
57): string {
58 if (text.length <= MAX_CACHEABLE_TEXT_LENGTH) {
59 const key = wrapCacheKey(text, maxWidth, wrapType)
60 const cached = wrapCache.get(key)
61 if (cached !== undefined) return cached
62
63 const result = computeWrap(text, maxWidth, wrapType)
64 wrapCache.set(key, result)
65 return result
66 }
67
68 return computeWrap(text, maxWidth, wrapType)
69}
70
71function computeWrap(
72 text: string,

Callers 2

wrapWithSoftWrapFunction · 0.70
measureTextNodeFunction · 0.70

Calls 4

wrapCacheKeyFunction · 0.85
computeWrapFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected