tessl install tessl/npm-wrap-ansi@9.0.0Wordwrap a string with ANSI escape codes
Agent Success
Agent success rate when using this tile
100%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.04x
Baseline
Agent success rate without this tile
96%
Build a text wrapping utility that intelligently handles long words by minimizing the total number of line breaks when text must be forcibly split.
Your implementation should:
Input: "abc verylongword" with width 10
Option A (start on current line):
"abc verylo"
"ngword"
Total: 2 lines, 1 break in the word
Option B (start on next line):
"abc"
"verylongwo"
"rd"
Total: 3 lines, 1 break in the word
Choose Option A (fewer total lines)Input: "abcdefgh verylongword" with width 10
Option A (start on current line):
"abcdefgh v"
"erylongwor"
"d"
Total: 3 lines, 2 breaks in the word
Option B (start on next line):
"abcdefgh"
"verylongwo"
"rd"
Total: 3 lines, 1 break in the word
Choose Option B (same lines, fewer breaks in word)/**
* Wraps text to the specified column width with optimized line break handling.
*
* @param {string} text - The text to wrap
* @param {number} width - The maximum column width
* @returns {string} The wrapped text with newlines
*/
function wrapText(text, width) {
// Implementation here
}
module.exports = { wrapText };@generates
Provides text wrapping functionality with support for optimized hard wrapping algorithm that minimizes line breaks.
@satisfied-by