string-width 2.0.0

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

Homepage: https://github.com/sindresorhus/string-width

Platform: npm

Language: JavaScript

License: MIT

Keywords: string, str, character, char, unicode, width, visual, column, columns, fullwidth, full-width, full, ansi, escape, codes, cli, command-line, terminal, console, cjk, chinese, japanese, korean, fixed-width

View on registry: https://www.npmjs.com/package/string-width

Direct download link: https://registry.npmjs.org/string-width/-/string-width-2.0.0.tgz

Install: npm install [email protected]


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. ANSI escape codes are stripped and doesn't affect the width.

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

Install

$ npm install --save string-width

Usage

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

stringWidth('');
//=> 2

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

stringWidth('a');
//=> 1

Related

License

MIT © Sindre Sorhus

Releases

  • 2.0.0 - September 22, 2016 06:54
  • 1.0.2 - August 14, 2016 15:23
  • 1.0.1 - July 20, 2015 01:31
  • 1.0.0 - July 16, 2015 22:08

Project Statistics

SourceRank 19
Dependencies 2
Dependent projects 68
Dependent repositories 8.19K
Total releases 4
Latest release
First release
Stars 62
Forks 3
Watchers 7
Contributors 1
Repo Size: 6.84 KB

Top Contributors See all

Sindre Sorhus

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2016-10-13 18:30:57 UTC

Login to resync this project