Skip to content

feat(text): stabilize truncate() - #7295

Open
tomas-zijdemans wants to merge 1 commit into
denoland:mainfrom
tomas-zijdemans:stabilize-text-truncate
Open

feat(text): stabilize truncate()#7295
tomas-zijdemans wants to merge 1 commit into
denoland:mainfrom
tomas-zijdemans:stabilize-text-truncate

Conversation

@tomas-zijdemans

Copy link
Copy Markdown
Contributor

Promotes truncate() to stable after five months unstable with zero bug reports. The new specifier is @std/text/truncate and it's now exported from mod.ts.

The diff is a rename plus bookkeeping: unstable_truncate.ts to truncate.ts (test file too), @experimental tag dropped, JSDoc import specifiers updated, deno.json export swapped. No logic changed. Behavior is identical to what's been on JSR since March (#7052).

One open question from the original request (#6456) is word and grapheme-aware truncation, which this API doesn't do. That's not a blocker: it lands later as an additive boundary option defaulting to today's behavior. What stabilization freezes is the defaults, so those are what to review hardest: UTF-16 code-unit measurement (matches every JS string builtin), no whitespace trimming before the suffix, and as the default suffix.

Tested: 19 unit tests and 4 doc examples pass, lint and fmt green.

@github-actions github-actions Bot added the text label Aug 23, 2026
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.03%. Comparing base (ca58f94) to head (04771a8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7295      +/-   ##
==========================================
- Coverage   95.03%   95.03%   -0.01%     
==========================================
  Files         617      618       +1     
  Lines       51637    51641       +4     
  Branches     9359     9359              
==========================================
+ Hits        49075    49078       +3     
  Misses       2021     2021              
- Partials      541      542       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant