GitShow/sindresorhus/string-width
sindresorhus

string-width

Get the visual width of a string - the number of columns required to display it

by sindresorhus
Star on GitHubForknpm

JavaScript

528 stars41 forks14 contributorsQuiet · 2mo agoSince 2015v8.2.1MIT

Meet the team

See all 14 on GitHub →
sindresorhus
sindresorhus57 contributions
fisker
fisker7 contributions
coreyfarrell
coreyfarrell2 contributions
BendingBender
BendingBender2 contributions
adam2k
adam2k1 contribution
privatenumber
privatenumber1 contribution
LitoMore
LitoMore1 contribution
Richienb
Richienb1 contribution

Languages

View on GitHub →
JavaScript98.6%
TypeScript1.4%

Commit activity

Last 12 weeks · 2 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Quiet · 1 discussion · Last activity 2mo ago
See all on GitHub →
sindresorhus
Use `stripVTControlCharacters` when targeting Node.js 22OpenIssue

https://github.com/sindresorhus/string-width/pull/61

sindresorhus · 6d ago

Recent fixes

View closed PRs →
JoshuaWise
Incorrect output for certain grapheme clustersClosedIssue

In my terminal (Terminal.app), I can write the string: Which consists of 6 instances of the code point (a Korean character), as a single grapheme cluster. In my terminal, each code point takes up 2 columns visually, for a total of 12 columns. But reports the entire string as just being 2 columns wide. This seems like a bug. I looked at the source code, and the culprit seems to be here: https://github.com/sindresorhus/string-width/blob/main/index.js#L111 , where it's just looking at the first code point of the grapheme cluster, rather than counting all of them.

JoshuaWise · 2mo ago
srinivasthedeveloper
SyntaxError: Invalid regular expression flags due to /v regex flag in older Node.js environmentsClosedIssue

Using the latest version of throws a runtime error in environments where the JavaScript engine does not support the (Unicode Sets) regex flag. The following regex in the package causes a crash: Error: Environment Node.js version: OS: string-width version: Package manager: Steps to Reproduce 1. Install the package 2. Run code that imports 3. Runtime throws the regex flag error Expected Behavior The package should either: maintain compatibility with Node versions that don't support , or clearly specify the required Node.js version in . Possible Solutions Replace with where Unicode set operations are not required. Document the minimum supported Node version. Provide a fallback build for older runtimes. Additional Context** This appears to occur because the flag (Unicode Sets) is not supported in some Node.js versions still widely used in production.

srinivasthedeveloper · 3mo ago
dulmandakh
chore: remove strip-ansi dependencyMergedPR

strip-ansi has below note on its npm page. So this PR removes strip-ansi dependency to use node:util. [!NOTE] Node.js has this built-in now with stripVTControlCharacters. The benefit of this package is consistent behavior across Node.js versions and faster improvements. The Node.js version is actually based on this package.

dulmandakh · 4mo ago
Structured data for AI agents

Repository: sindresorhus/string-width. Description: Get the visual width of a string - the number of columns required to display it Stars: 528, Forks: 41. Primary language: JavaScript. Languages: JavaScript (98.6%), TypeScript (1.4%). License: MIT. Latest release: v8.2.1 (2mo ago). Open PRs: 0, open issues: 1. Last activity: 2mo ago. Community health: 85%. Top contributors: sindresorhus, fisker, coreyfarrell, BendingBender, adam2k, privatenumber, LitoMore, Richienb, seachicken, shinnn and others.

·@ofershap

Replace github.com with gitshow.dev