Skip to content

Conversation

@wojtekmaj
Copy link

@wojtekmaj wojtekmaj commented Aug 4, 2025

This PR replaces wrap-ansi with fast-wrap-ansi, a lighter (>2x), faster fork of wrap-ansi.

On lightness:
https://bundlephobia.com/package/wrap-ansi@9.0.0
https://bundlephobia.com/package/fast-wrap-ansi@0.1.3

On speed:

basic wrapping
┌─────────┬─────────────────────────┬──────────────────┬───────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name               │ Latency avg (ns) │ Latency med (ns)  │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼─────────────────────────┼──────────────────┼───────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'fast-wrap-ansi'        │ '13693 ± 3.01%'  │ '11200 ± 200.00'  │ '83887 ± 0.11%'        │ '89286 ± 1623'         │ 73034   │
│ 1       │ 'wrap-ansi'             │ '222490 ± 9.22%' │ '139400 ± 7400.0' │ '6572 ± 0.65%'         │ '7174 ± 396'           │ 4495    │
│ 2       │ 'fast-wrap-ansi (prod)' │ '13296 ± 1.80%'  │ '12000 ± 200.00'  │ '81045 ± 0.08%'        │ '83333 ± 1366'         │ 75213   │
└─────────┴─────────────────────────┴──────────────────┴───────────────────┴────────────────────────┴────────────────────────┴─────────┘
styled wrapping
┌─────────┬─────────────────────────┬───────────────────┬───────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name               │ Latency avg (ns)  │ Latency med (ns)  │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼─────────────────────────┼───────────────────┼───────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'fast-wrap-ansi'        │ '7751.4 ± 3.53%'  │ '6300.0 ± 100.00' │ '150942 ± 0.07%'       │ '158730 ± 2480'        │ 129010  │
│ 1       │ 'wrap-ansi'             │ '125284 ± 18.62%' │ '70500 ± 8000.0'  │ '13554 ± 0.48%'        │ '14184 ± 1653'         │ 8113    │
│ 2       │ 'fast-wrap-ansi (prod)' │ '7926.1 ± 5.70%'  │ '6900.0 ± 100.00' │ '140737 ± 0.05%'       │ '144928 ± 2070'        │ 126167  │
└─────────┴─────────────────────────┴───────────────────┴───────────────────┴────────────────────────┴────────────────────────┴─────────┘

Fixes #1799

@codecov
Copy link

codecov bot commented Aug 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@22d47dd). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1800   +/-   ##
=======================================
  Coverage        ?   97.76%           
=======================================
  Files           ?       39           
  Lines           ?     2548           
  Branches        ?      702           
=======================================
  Hits            ?     2491           
  Misses          ?       48           
  Partials        ?        9           

☔ View full report in Codecov by Sentry.
📢 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.

@wojtekmaj
Copy link
Author

Oh noooo - I didn't realize it has a separate CJS build, which stops this PR from being merged until we drop support for the last Node.js version that does not support require(esm) - 18.x.

@SBoudrias
Copy link
Owner

Ah indeed! I've been lagging a bit on going ESM only due to how much support load it created the last time I did. Hopefully it'll be easier this time around, but there'll be some friction due to the amount of usage Inquirer has.

@LitoMore
Copy link
Collaborator

LitoMore commented Aug 13, 2025

We can also observe whether this project remains active at the moment.

I just checked its code, and it looks like the test was never run: https://github.com/43081j/fast-wrap-ansi/actions/runs/16728230029/job/47349506743#step:6:11. Its reliability remains to be seen.

Update:
I also tried to fix the misconfigured test for fast-wrap-ansi on my local, but its test still fails.

CleanShot 2025-08-21 at 11 17 06@2x

I would say Sindre's wrap-ansi is more reliable, and Node.js version stripVTControlCharacters is actually based on the strip-ansi.

wojtekmaj added a commit to wojtekmaj/fast-wrap-ansi that referenced this pull request Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider replacing wrap-ansi with fast-wrap-ansi

3 participants