sindresorhus / cli-truncate

Truncate a string to a specific width in the terminal
MIT License
85 stars 14 forks source link

Add `truncationCharacter` option #19

Closed codemaster138 closed 3 years ago

codemaster138 commented 3 years ago

This PR adds an option ellipsis that allows the user to replace the default with another character.

Example:

import cliTruncate from 'cli-truncate';

// Without option
cliTruncate('unicorns', 5, {position: 'end'});
//=> 'unic…'

// With option set to '.'
cliTruncate('unicorns', 5, {position: 'end', ellipsis: '.'});
//=> 'unic.'

// With option set to ''
cliTruncate('unicorns', 5, {position: "end", ellipsis: ''});
//=> 'unico'

Includes type definitions and documentation.


Closes #18

sindresorhus commented 3 years ago

This will need tests.

codemaster138 commented 3 years ago

I'm on it

codemaster138 commented 3 years ago

@sindresorhus I'm trying to run yarn test but xo is telling me Parsing error: File @sindresorhus/tsconfig not found.

I google it, but found nothing of the sort. Both creating a tsconfig.json and running yarn add -D @sindresorhus/tsconfig didn't help...

Am I just being an idiot?