-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c06536
commit 55ed49f
Showing
2 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) | ||
@param string - A string with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk). | ||
@param startSlice - Zero-based index at which to start the slice. | ||
@param endSlice - Zero-based index at which to end the slice. | ||
@example | ||
``` | ||
import chalk from 'chalk'; | ||
import sliceAnsi from 'slice-ansi'; | ||
const string = 'The quick brown ' + chalk.red('fox jumped over ') + | ||
'the lazy ' + chalk.green('dog and then ran away with the unicorn.'); | ||
console.log(sliceAnsi(string, 20, 30)); | ||
``` | ||
*/ | ||
export default function sliceAnsi(string: string, startSlice: number, endSlice?: number): string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters