feat(string): add strTruncate, and strCount utilities#529
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #529 +/- ##
==========================================
+ Coverage 98.81% 98.83% +0.01%
==========================================
Files 136 138 +2
Lines 3973 4019 +46
Branches 849 858 +9
==========================================
+ Hits 3926 3972 +46
Misses 47 47
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds two new string utilities to @nevware21/ts-utils (strTruncate and strCount) along with common-suite tests, public exports, documentation updates, and adjusted bundle-size limits to accommodate the added functionality.
Changes:
- Introduce
strTruncate()(max-length truncation with optional suffix) andstrCount()(non-overlapping substring occurrence counting). - Add common tests for both new utilities and export them from the package index.
- Update docs/README usage examples and bump size thresholds in bundle checks.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/string/truncate.ts | New strTruncate implementation with suffix support and max-length boundary behavior. |
| lib/src/string/count.ts | New strCount implementation for counting non-overlapping matches. |
| lib/src/index.ts | Exposes strCount and strTruncate from the public API. |
| lib/test/src/common/string/truncate.test.ts | Adds coverage for truncation behavior, suffix handling, and null/undefined input throwing. |
| lib/test/src/common/string/count.test.ts | Adds coverage for counting semantics, empty matcher behavior, and null/undefined input throwing. |
| docs/usage-guide.md | Documents new string helpers in the usage snippet. |
| README.md | Adds new helpers to the public utilities matrix/links. |
| docs/feature-backlog.md | Updates backlog organization and removes completed items from the list. |
| lib/test/bundle-size-check.js | Increases bundle-size thresholds for minified bundles. |
| .size-limit.json | Increases size-limit thresholds for ES5/ES6 full builds. |
- **strTruncate**: Truncate strings to maximum length with optional suffix support - Preserves hard max length boundary (suffix included within limit) - Truncates suffix if needed to maintain max length constraint - Type coercion via asString(); throws for null/undefined - **strCount**: Count non-overlapping substring occurrences - Returns 0 for empty search strings (prevents unbounded matches) - Type coercion via asString(); throws for null/undefined
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
nevware21-bot
approved these changes
Mar 20, 2026
Contributor
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
strTruncate: Truncate strings to maximum length with optional suffix support
strCount: Count non-overlapping substring occurrences