tiny-truncate

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

MIT 6 个版本
安装
npm install tiny-truncate
yarn add tiny-truncate
pnpm add tiny-truncate
bun add tiny-truncate
README

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

版本列表
1.0.5 2025-08-22
1.0.4 2025-08-04
1.0.3 2025-01-12
1.0.2 2022-05-06
1.0.1 2022-05-06
1.0.0 2022-05-06