GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB

2 months ago
  1. # string-width
  2. > Get the visual width of a string - the number of columns required to display it
  3. Some 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.
  4. Useful to be able to measure the actual width of command-line output.
  5. ## Install
  6. ```
  7. $ npm install string-width
  8. ```
  9. ## Usage
  10. ```js
  11. const stringWidth = require('string-width');
  12. stringWidth('a');
  13. //=> 1
  14. stringWidth('古');
  15. //=> 2
  16. stringWidth('\u001B[1m古\u001B[22m');
  17. //=> 2
  18. ```
  19. ## Related
  20. - [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
  21. - [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
  22. - [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
  23. ---
  24. <div align="center">
  25. <b>
  26. <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>
  27. </b>
  28. <br>
  29. <sub>
  30. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  31. </sub>
  32. </div>