slice-ansi

  • Version 7.1.0
  • Published
  • 7.95 kB
  • 2 dependencies
  • MIT license

Install

npm i slice-ansi
yarn add slice-ansi
pnpm add slice-ansi

Overview

Slice a string with ANSI escape codes

Index

Functions

Functions

function sliceAnsi

sliceAnsi: (string: string, startSlice: number, endSlice?: number) => string;
  • Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)

    Parameter string

    A string with ANSI escape codes. Like one styled by [chalk](https://github.com/chalk/chalk).

    Parameter startSlice

    Zero-based index at which to start the slice.

    Parameter endSlice

    Zero-based index at which to end the slice.

    Example 1

    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));

Package Files (1)

Dependencies (2)

Dev Dependencies (5)

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/slice-ansi.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/slice-ansi)
  • HTML
    <a href="https://www.jsdocs.io/package/slice-ansi"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>