-
Notifications
You must be signed in to change notification settings - Fork 7
Add string utility function: truncate #70
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
Conversation
…itLines Co-authored-by: drebrez <1611547+drebrez@users.noreply.github.com>
Co-authored-by: drebrez <1611547+drebrez@users.noreply.github.com>
… review feedback Co-authored-by: drebrez <1611547+drebrez@users.noreply.github.com>
…add removeEmptyEntries parameter Co-authored-by: drebrez <1611547+drebrez@users.noreply.github.com>
|
@copilot please split this PR in 3 different PRs, one with the "truncate" function, one with the "trim", "ltrim" and "rtrim" functions and one for the "splitLines" function |
I'll split the PR as requested. Which function would you like me to keep in this current PR? Should I keep:
I'll remove the other functions from this PR and you can create separate PRs for them. |
Keep the 1. |
…cate function Co-authored-by: drebrez <1611547+drebrez@users.noreply.github.com>
I've updated the PR to keep only the truncate function. Removed the trim, ltrim, rtrim, and splitLines functions along with their tests and updated the imports accordingly. Fixed in c709b84. |
Co-authored-by: drebrez <1611547+drebrez@users.noreply.github.com>
|
@copilot you need to update the changelog then you can publish the PR. |
commit: |
|
@copilot Update the changelog and also the PR title and description |
Co-authored-by: manni497 <65862280+manni497@users.noreply.github.com>
Updated the changelog to include the truncate function in the Unreleased section. The PR is now ready and focuses only on the truncate function. Fixed in f5520af.
Updated both the changelog and the PR title/description to reflect that this PR now only contains the truncate function. Fixed in f5520af. |
This PR adds the essential
truncatestring utility function from the VS Code codebase to enhance the javascript-utils library.New Function
truncate(value, maxLength, suffix?)Truncates a string to a maximum length, adding an optional suffix (default empty string) if truncated.
Features
Implementation Notes
The function is based on the VS Code source implementation but adapted to match this library's patterns for null/undefined handling and error recovery. The function returns sensible defaults rather than throwing errors for invalid inputs.
Fixes #29.