slice-ansi
Slice a string with ANSI escape codes
Last updated 5 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install slice-ansi 
SYNC missed versions from official npm registry.

slice-ansi XO: Linted

Slice a string with ANSI escape codes

Install

npm install slice-ansi

Usage

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

API

sliceAnsi(string, startSlice, endSlice?)

string

Type: string

String with ANSI escape codes. Like one styled by chalk.

startSlice

Type: number

Zero-based index at which to start the slice.

endSlice

Type: number

Zero-based index at which to end the slice.

Related

  • wrap-ansi - Wordwrap a string with ANSI escape codes
  • cli-truncate - Truncate a string to a specific width in the terminal
  • chalk - Terminal string styling done right

Maintainers

Current Tags

  • 6.0.0                                ...           latest (2 years ago)

11 Versions

  • 6.0.0                                ...           2 years ago
  • 5.0.0                                ...           4 years ago
  • 4.0.0                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.0                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
  • 0.0.4                                ...           9 years ago
  • 0.0.3                                ...           9 years ago
  • 0.0.2                                ...           9 years ago
Maintainers (2)
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (5)
Dependents (4)

Copyright 2013 - present © cnpmjs.org | Home |