npm.io
1.0.5 • Published 1 year ago

tiny-truncate

Licence
MIT
Version
1.0.5
Deps
1
Size
3 kB
Vulns
0
Weekly
0
Stars
3

Tiny Truncate

A tiny function for truncating a string which may containg ANSI escapes, with automatic terminal width detection.

Install

npm install tiny-truncate

Usage

import colors from 'tiny-colors';
import truncate from 'tiny-truncate';

// Let's truncate a string, spanning at most the entire width of the terminal

truncate ( colors.red ( '---'.repeat ( 1000 ) ) ); // Some red dashes that don't overflow the width of the terminal

License

MIT Fabio Spampinato

Keywords