Returns the width of a string in cells. This is the number of cells that the string will occupy when printed in a terminal. ANSI escape codes are ignored and wide characters (such as east asian characters & emojis) are accounted for.
Optional
import { stringWidth } from './width';width('a');//=> 1width('古');//=> 2width('\u001B[1m古\u001B[22m');//=> 2 Copy
import { stringWidth } from './width';width('a');//=> 1width('古');//=> 2width('\u001B[1m古\u001B[22m');//=> 2
Returns the width of a string in cells. This is the number of cells that the string will occupy when printed in a terminal. ANSI escape codes are ignored and wide characters (such as east asian characters & emojis) are accounted for.