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#readme

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

Repository: git+https://github.com/sindresorhus/string-width.git

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

Sustain

Releases

2.0.0 September 22, 2016
1.0.2 August 14, 2016
1.0.1 July 20, 2015
1.0.0 July 16, 2015

Project Statistics

SourceRank 19
Dependencies 2
Dependent projects 83
Dependent repositories 9.07K
Total releases 4
Latest release
First release
Stars 64
Forks 5
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: 2017-04-21 14:05:20 UTC

Login to resync this project