break-string
Break string into lines according to visual width.
Some Unicode characters are fullwidth and use double the normal width. ANSI escape codes are stripped and doesn't affect the width.
Useful to be able to break the string into lines according to visual width(the number of columns) in the terminal.
Inspired by:
- string-width - Get visual width of a string
- string-length - Get the real length of a string
Install
$ npm install --save break-string
Usage
var breakString = ; // normal string;// => ['abcd', 'efg'] // with line break;// => ['abc', 'd', 'efg'];// => ['abcd', 'efg'];// => ['abcd', 'efg'] // with astral symbols;// => ['a🐴bc', 'de'] // with double with char;// => ['a古b', 'cde'] // with ansi code;// => ['uni\u001b[22mc', 'orn']