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.

1234567891011121314151617181920212223242526272829
  1. export interface Options {
  2. /**
  3. 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).
  4. @default true
  5. */
  6. readonly ambiguousIsNarrow: boolean;
  7. }
  8. /**
  9. Get the visual width of a string - the number of columns required to display it.
  10. 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.
  11. @example
  12. ```
  13. import stringWidth from 'string-width';
  14. stringWidth('a');
  15. //=> 1
  16. stringWidth('古');
  17. //=> 2
  18. stringWidth('\u001B[1m古\u001B[22m');
  19. //=> 2
  20. ```
  21. */
  22. export default function stringWidth(string: string, options?: Options): number;