
Company News
Socket Has Acquired Secure Annex
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.
display-width
Advanced tools
A node.js port of [uwcwidth](https://github.com/Z4JC/uwcwidth), a fast function for determining a string's display width
A node.js port of uwcwidth, a fast function for determining a string's display width
That code is a port of POSIX wcswidth, a standard function for counting the number of columns occupied by a string, and is derived from musl libc
import { wcswidth } from "display-width";
// wcswidth("π©ββ€οΈβπ¨") == 2
console.log(wcswidth("\u{1F469}\u{200D}\u{2764}\u{FE0F}\u{200D}\u{1F468}"));
>> wcswidth("cafeΜ") == 4
>> "cafeΜ".length == 5
>> wcswidth("β οΈ warning") == 9
>> "β οΈ warning".length == 10
>> wcswidth("π¨βπ¨βπ§βπ§") == 2
>> "π¨βπ¨βπ§βπ§".length == 11
>> wcswidth("π©ββ€οΈβπ¨") == 2
>> "π©ββ€οΈβπ¨".length == 8
yes! Compared to string-width, it's about 33x faster
βββββββββββ¬ββββββββββββββββββ¬ββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββ¬ββββββββββ
β (index) β Task Name β ops/sec β Average Time (ns) β Margin β Samples β
βββββββββββΌββββββββββββββββββΌββββββββββββΌβββββββββββββββββββββΌββββββββββββΌββββββββββ€
β 0 β 'display-width' β '188,426' β 5307.115321339439 β 'Β±1.55%' β 18843 β
β 1 β 'string-width' β '5,586' β 179008.73345259373 β 'Β±11.73%' β 559 β
βββββββββββ΄ββββββββββββββββββ΄ββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββ΄ββββββββββ
see the bench directory for details
no!
no!
no! I ported the code and all the tests from uwcwidth though, so I have good vibes about it
FAQs
A node.js port of [uwcwidth](https://github.com/Z4JC/uwcwidth), a fast function for determining a string's display width
We found that display-width demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.