版博士V2.0程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. import stringWidth from 'string-width';
  12. stringWidth('a');
  13. //=> 1
  14. stringWidth('古');
  15. //=> 2
  16. stringWidth('\u001B[1m古\u001B[22m');
  17. //=> 2
  18. ```
  19. ## API
  20. ### stringWidth(string, options?)
  21. #### string
  22. Type: `string`
  23. The string to be counted.
  24. #### options
  25. Type: `object`
  26. ##### ambiguousIsNarrow
  27. Type: `boolean`\
  28. Default: `false`
  29. Count [ambiguous width characters](https://www.unicode.org/reports/tr11/#Ambiguous) as having narrow width (count of 1) instead of wide width (count of 2).
  30. ## Related
  31. - [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
  32. - [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
  33. - [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
  34. ---
  35. <div align="center">
  36. <b>
  37. <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>
  38. </b>
  39. <br>
  40. <sub>
  41. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  42. </sub>
  43. </div>