Displayed width of strings according to UAX#11 rules
npm install @hyrious/string-width> Get displayed width of unicode strings according to UAX#11 rules.
This package is a JS port of Rust's unicode-width.
It does not handle ANSI escape codes and complex emoji sequences.
You can use strip-ansi and emoji-regex before passing strings to this package. See test.js of commented out test cases.
```
npm add @hyrious/string-width
`js
import stringWidth from '@hyrious/string-width'
// const stringWidth = require('@hyrious/string-width')
stringWidth('a')
//=> 1
stringWidth('古')
//=> 2
`
- string {String} The string to get the width of.options
- {Object}ambiguousIsNarrow
- {Boolean} (default: true`) Whether to treat ambiguous-width characters as narrow (count of 1) instead of wide (count of 2).
Returns a number of the column width of the string.
MIT @ hyrious