Socket
Socket
Sign inDemoInstall

slice-ansi

Package Overview
Dependencies
3
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

slice-ansi

Slice a string with ANSI escape codes


Version published
Maintainers
2
Weekly downloads
42,278,995
decreased by-7.37%

Weekly downloads

Readme

Source

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.

  • 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

Keywords

FAQs

Last updated on 29 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc