UNPKG

713 BTypeScriptView Raw
1/**
2Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
3
4@param string - A string with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
5@param startSlice - Zero-based index at which to start the slice.
6@param endSlice - Zero-based index at which to end the slice.
7
8@example
9```
10import chalk from 'chalk';
11import sliceAnsi from 'slice-ansi';
12
13const string = 'The quick brown ' + chalk.red('fox jumped over ') +
14 'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
15
16console.log(sliceAnsi(string, 20, 30));
17```
18*/
19export default function sliceAnsi(string: string, startSlice: number, endSlice?: number): string;