CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-wrap-ansi

tessl install tessl/npm-wrap-ansi@9.0.0

Wordwrap 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%

task.mdevals/scenario-8/

Text Wrapper with Whitespace Configuration

Build a text wrapping utility that properly handles edge cases involving whitespace-only input strings. The utility should support configurable whitespace preservation behavior.

Requirements

The utility should wrap text to a specified column width and handle whitespace-only strings correctly based on configuration:

Core Functionality

Implement a text wrapping function that:

  • Accepts a string to wrap, a column width, and optional configuration
  • Wraps text to fit within the specified column width
  • Handles standard word wrapping at word boundaries
  • Preserves the visual appearance of styled text

Whitespace Configuration

Support a trim configuration option that controls whitespace handling:

  • When trim is enabled (default), leading and trailing whitespace should be removed from wrapped lines
  • When trim is disabled, leading and trailing whitespace should be preserved exactly as provided

Edge Case Handling

The utility must correctly handle whitespace-only input strings:

  • When given a string containing only spaces, tabs, or other whitespace characters
  • Behavior must differ based on the trim configuration
  • The handling should be consistent and predictable

Test Cases

  • When wrapping " " (three spaces) at width 10 with trim enabled, returns an empty string @test
  • When wrapping " " (five spaces) at width 10 with trim disabled, returns the spaces wrapped according to column width @test
  • When wrapping "\t\t" (two tabs) at width 10 with trim enabled, returns an empty string @test
  • When wrapping " hello " at width 10 with trim enabled, removes leading and trailing spaces but preserves the word @test

Implementation

@generates

API

/**
 * Wraps text to fit within specified column width
 *
 * @param {string} text - The text to wrap
 * @param {number} columns - Maximum column width
 * @param {Object} options - Configuration options
 * @param {boolean} options.trim - Remove leading/trailing whitespace from wrapped lines (default: true)
 * @returns {string} The wrapped text
 */
function wrapText(text, columns, options) {
  // Implementation here
}

module.exports = { wrapText };

Dependencies { .dependencies }

wrap-ansi { .dependency }

Provides text wrapping support with ANSI escape code handling.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/wrap-ansi@9.0.x
tile.json