Gathering detailed insights and metrics for cli-truncate
Gathering detailed insights and metrics for cli-truncate
Gathering detailed insights and metrics for cli-truncate
Gathering detailed insights and metrics for cli-truncate
@types/cli-truncate
Stub TypeScript definitions entry for cli-truncate, which provides its own types definitions
@stdlib/string-truncate-cli
Truncate a string to a specified length.
@stdlib/string-truncate-middle-cli
Truncate a string in the middle to a specified length.
truncate-logs
CLI/JS module for truncating the beginning of a set of files easily
Truncate a string to a specific width in the terminal
npm install cli-truncate
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.5
Supply Chain
99.5
Quality
75.6
Maintenance
100
Vulnerability
100
License
JavaScript (94.11%)
TypeScript (5.89%)
Total Downloads
3,801,241,123
Last Day
1,149,000
Last Week
24,552,439
Last Month
107,403,010
Last Year
1,085,300,251
MIT License
87 Stars
30 Commits
13 Forks
4 Watchers
1 Branches
8 Contributors
Updated on Mar 09, 2025
Minified
Minified + Gzipped
Latest Version
4.0.0
Package Id
cli-truncate@4.0.0
Unpacked Size
10.64 kB
Size
3.20 kB
File Count
5
NPM Version
9.2.0
Node Version
18.18.2
Published on
Oct 28, 2023
Cumulative downloads
Total Downloads
Last Day
-10.3%
1,149,000
Compared to previous day
Last Week
-9.6%
24,552,439
Compared to previous week
Last Month
2.6%
107,403,010
Compared to previous month
Last Year
19.5%
1,085,300,251
Compared to previous year
2
Truncate a string to a specific width in the terminal
Gracefully handles ANSI escapes. Like a string styled with chalk
. It also supports Unicode surrogate pairs and fullwidth characters.
1npm install cli-truncate
1import cliTruncate from 'cli-truncate'; 2 3cliTruncate('unicorn', 4); 4//=> 'uni…' 5 6// Truncate at different positions 7cliTruncate('unicorn', 4, {position: 'start'}); 8//=> '…orn' 9 10cliTruncate('unicorn', 4, {position: 'middle'}); 11//=> 'un…n' 12 13cliTruncate('unicorns rainbow dragons', 6, {position: 'end'}) 14//=> 'unico…' 15 16cliTruncate('\u001B[31municorn\u001B[39m', 4); 17//=> '\u001B[31muni\u001B[39m…' 18 19// Truncate Unicode surrogate pairs 20cliTruncate('uni\uD83C\uDE00corn', 5); 21//=> 'uni\uD83C\uDE00…' 22 23// Truncate fullwidth characters 24cliTruncate('안녕하세요', 3); 25//=> '안…' 26 27// Truncate the paragraph to the terminal width 28const paragraph = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.'; 29cliTruncate(paragraph, process.stdout.columns); 30//=> 'Lorem ipsum dolor sit amet, consectetuer adipiscing…'
Type: string
The text to truncate.
Type: number
The number of columns to occupy in the terminal.
Type: object
Type: string
Default: 'end'
Values: 'start' | 'middle' | 'end'
The position to truncate the string.
Type: boolean
Default: false
Add a space between the text and the ellipsis.
1import cliTruncate from 'cli-truncate'; 2 3cliTruncate('unicorns', 5, {space: false}); 4//=> 'unic…' 5 6cliTruncate('unicorns', 5, {space: true}); 7//=> 'uni …' 8 9cliTruncate('unicorns', 6, {position: 'start', space: true}); 10//=> '… orns' 11 12cliTruncate('unicorns', 7, {position: 'middle', space: true}); 13//=> 'uni … s'
Type: boolean
Default: false
Truncate the string from a whitespace if it is within 3 characters from the actual breaking point.
1import cliTruncate from 'cli-truncate';
2
3cliTruncate('unicorns rainbow dragons', 20, {position: 'start', preferTruncationOnSpace: true})
4//=> '…rainbow dragons'
5
6// without preferTruncationOnSpace
7cliTruncate('unicorns rainbow dragons', 20, {position: 'start'})
8//=> '…rns rainbow dragons'
9
10cliTruncate('unicorns rainbow dragons', 20, {position: 'middle', preferTruncationOnSpace: true})
11//=> 'unicorns…dragons'
12
13cliTruncate('unicorns rainbow dragons', 6, {position: 'end', preferTruncationOnSpace: true})
14//=> 'unico…'
15
16// preferTruncationOnSpace would have no effect if space isn't found within next 3 indexes
17cliTruncate('unicorns rainbow dragons', 6, {position: 'middle', preferTruncationOnSpace: true})
18//=> 'uni…ns'
Type: string
Default: …
The character to use at the breaking point.
1import cliTruncate from 'cli-truncate'; 2 3cliTruncate('unicorns', 5, {position: 'end'}); 4//=> 'unic…' 5 6cliTruncate('unicorns', 5, {position: 'end', truncationCharacter: '.'}); 7//=> 'unic.' 8 9cliTruncate('unicorns', 5, {position: 'end', truncationCharacter: ''}); 10//=> 'unico'
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 7/30 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More