Skip to content

feat(string): add strTruncate, and strCount utilities#529

Merged
nev21 merged 4 commits intomainfrom
nev21/strConvert
Mar 20, 2026
Merged

feat(string): add strTruncate, and strCount utilities#529
nev21 merged 4 commits intomainfrom
nev21/strConvert

Conversation

@nev21
Copy link
Contributor

@nev21 nev21 commented Mar 20, 2026

  • 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

@nev21 nev21 added this to the 0.14.0 milestone Mar 20, 2026
Copilot AI review requested due to automatic review settings March 20, 2026 04:28
@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.83%. Comparing base (4f3d60a) to head (1e7fcd1).
⚠️ Report is 1 commits behind head on main.

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              
Files with missing lines Coverage Δ
lib/src/string/count.ts 100.00% <100.00%> (ø)
lib/src/string/truncate.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and strCount() (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.

@nev21 nev21 force-pushed the nev21/strConvert branch from 27a4450 to c4c3d2f Compare March 20, 2026 04:47
@nev21 nev21 requested review from a team as code owners March 20, 2026 04:47
@nev21 nev21 requested a review from Copilot March 20, 2026 04:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

- **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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

nev21 and others added 3 commits March 19, 2026 22:03
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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

@nev21 nev21 enabled auto-merge (squash) March 20, 2026 05:14
Copy link
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

@nev21 nev21 merged commit 43becdc into main Mar 20, 2026
14 checks passed
@nev21 nev21 deleted the nev21/strConvert branch March 20, 2026 05:30
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.

3 participants