Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
index.d.ts | D | 24-Sep-2023 | 792 | 30 | 5 | |
index.js | D | 24-Sep-2023 | 923 | 48 | 31 | |
license | D | 24-Sep-2023 | 1.1 KiB | 10 | 5 | |
package.json | D | 24-Sep-2023 | 941 | 57 | 56 | |
readme.md | D | 24-Sep-2023 | 1.4 KiB | 51 | 32 |
readme.md
1# string-width 2 3> Get the visual width of a string - the number of columns required to display it 4 5Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. 6 7Useful to be able to measure the actual width of command-line output. 8 9 10## Install 11 12``` 13$ npm install string-width 14``` 15 16 17## Usage 18 19```js 20const stringWidth = require('string-width'); 21 22stringWidth('a'); 23//=> 1 24 25stringWidth('古'); 26//=> 2 27 28stringWidth('\u001B[1m古\u001B[22m'); 29//=> 2 30``` 31 32 33## Related 34 35- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module 36- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string 37- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string 38 39 40--- 41 42<div align="center"> 43 <b> 44 <a href="https://tidelift.com/subscription/pkg/npm-string-width?utm_source=npm-string-width&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> 45 </b> 46 <br> 47 <sub> 48 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. 49 </sub> 50</div> 51