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

Middle string truncation #59

Open
rzhw opened this issue Jul 24, 2023 · 0 comments
Open

Middle string truncation #59

rzhw opened this issue Jul 24, 2023 · 0 comments

Comments

@rzhw
Copy link

rzhw commented Jul 24, 2023

Hey, I'm looking for something that can help truncate strings and add an ellipsis, similar to how macOS's Finder will truncate filenames in the middle of the string.

Would something that either achieves this or helps with it be considered within scope?

(Happy to try and write up a PR if so.)

For the former (achieving this), I'd imagine adding a new package that does this middle truncation, and similar to truncate would take a parameter similar to tail. (Not sure what a good name for the param would be off the top of my head, though.)

For the latter (helping with this), I have in mind a version of truncate that truncates counting from the right. (I guess it could almost be thought of like an RTL truncate?) An end-user would then end up using both truncate-from-left and truncate-from-right.

@rzhw rzhw changed the title macOS Finder style string truncation Middle string truncation Jul 24, 2023
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

No branches or pull requests

1 participant