ansi-truncate

A tiny function for truncating a string that may contain ANSI escape sequences.

MIT 8 个版本
安装
npm install ansi-truncate
yarn add ansi-truncate
pnpm add ansi-truncate
bun add ansi-truncate
README

ANSI Truncate

A tiny function for truncating a string that may contain ANSI escape sequences.

Install

npm install ansi-truncate

Usage

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

// Let's truncate a string to a visual width of 2

truncate ( colors.red ( 'foo' ), 2 ); // => Same as: colors.red ( 'f…' );

License

MIT © Fabio Spampinato

版本列表
1.4.0 2025-08-22
1.3.0 2025-08-04
1.2.0 2025-01-11
1.1.2 2024-02-27
1.1.1 2024-02-27
1.1.0 2024-02-25
1.0.1 2022-05-06
1.0.0 2022-05-06