Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use util.stripVTControlCharacters(str) to check string width #111

Open
bartveneman opened this issue Nov 18, 2024 · 0 comments
Open

Use util.stripVTControlCharacters(str) to check string width #111

bartveneman opened this issue Nov 18, 2024 · 0 comments

Comments

@bartveneman
Copy link
Member

bartveneman commented Nov 18, 2024

replace here

function str_length(str) {
// Basically strip ansi-characters from the string
// source: https://github.com/usmanyunusov/nanospinner/blob/a80396e2f2613462399d39e664a690ec31a0da3f/index.js#L9
return str
.replace(/\u001b[^m]*?m/g, '')
.length
}
using

https://nodejs.org/api/util.html#utilstripvtcontrolcharactersstr
requires Node 16.11.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

1 participant