Skip to content

Middle string truncation #59

@rzhw

Description

@rzhw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions