You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

string-width

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-width

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

Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
391M
2.63%
Maintainers
1
Weekly downloads
 
Created
Source

string-width Build Status

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

Some Unicode characters are fullwidth and use double the normal width.

Useful to be able to measure the actual width of command-line output.

Install

$ npm install --save string-width

Usage

var stringWidth = require('string-width');

stringWidth('古');
//=> 2

stringWidth('\u001b[1m古\u001b[22m');
//=> 2

stringWidth('a');
//=> 1
  • string-width-cli - CLI for this module
  • string-length - Get the real length of a string

License

MIT © Sindre Sorhus

Keywords

string

FAQs

Package last updated on 20 Jul 2015

Did you know?

Socket

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.

Install

Related posts