substr-ansi
Get the
String#substr
correctly handling ansi escape codes.
Install
$ npm install --save substr-ansi
Usage
var substrAnsi = ; console;//=> HiNote that the ansi code are preserved: \u001b47mHi\u001b49m '\u001b[47mHi\u001b[49m' results in a broken string://=> \u001b[ ;//=> Hello (visible text)Complete string: `\u001b[0m\u001b[31m\u001b[47mHello`
API
substrAnsi(str, start[, length])
str
Required
Type: string
The original string that will be used to extract a section from it.
start
Type: integer
Default: 0
Location at which to begin extracting characters.
length
Type: integer
Default: str.length
Optional. The number of characters to extract.
License
MIT © Danilo Sampaio