Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add truncationCharacter option #19

Merged
merged 17 commits into from Oct 9, 2021
Merged

Conversation

codemaster138
Copy link
Contributor

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

The new 'ellipsis' option allows replacing the ellipsis character with another character (or completely removing the ellipsis)
Update index.d.ts to accomodate the `ellipsis` option
index.d.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

This will need tests.

@codemaster138
Copy link
Contributor Author

I'm on it

@codemaster138
Copy link
Contributor Author

@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?

readme.md Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.js Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Allow users to set custom ellipsis character Add truncationCharacter option Oct 9, 2021
@sindresorhus sindresorhus merged commit 23b40dc into sindresorhus:main Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use other character (or no character) instead of elipsis
2 participants