Skip to content

feat(string): add strReplace + strReplaceAll, refactor internal replacements, and expand coverage#527

Merged
nev21 merged 1 commit intomainfrom
nev21/replace
Mar 18, 2026
Merged

feat(string): add strReplace + strReplaceAll, refactor internal replacements, and expand coverage#527
nev21 merged 1 commit intomainfrom
nev21/replace

Conversation

@nev21
Copy link
Contributor

@nev21 nev21 commented Mar 18, 2026

  • add new native string helper strReplace
  • add strReplaceAll with polyfill fallback (polyStrReplaceAll) and wire it into polyfills.ts
  • refactor existing string replacement call sites to use strReplace in:
    • encoding helpers
    • regexp helpers
    • string conversion helpers
    • string null/whitespace checks
    • trim polyfill
    • replace_all implementation
  • align polyArrWith invalid-array path to use throwRangeError

bug(polyTrim): This causes incorrect behavior for non-null/undefined falsey values (e.g. 0/false)

@nev21 nev21 added this to the 0.14.0 milestone Mar 18, 2026
@nev21 nev21 requested review from a team as code owners March 18, 2026 03:59
Copilot AI review requested due to automatic review settings March 18, 2026 03:59
@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.81%. Comparing base (75626d3) to head (631f85c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #527      +/-   ##
==========================================
- Coverage   98.82%   98.81%   -0.01%     
==========================================
  Files         134      136       +2     
  Lines        3905     3969      +64     
  Branches      829      849      +20     
==========================================
+ Hits         3859     3922      +63     
- Misses         46       47       +1     
Files with missing lines Coverage Δ
lib/src/array/with.ts 100.00% <100.00%> (ø)
lib/src/helpers/encode.ts 100.00% <100.00%> (ø)
lib/src/helpers/regexp.ts 100.00% <100.00%> (ø)
lib/src/polyfills.ts 51.06% <100.00%> (-0.05%) ⬇️
lib/src/polyfills/trim.ts 100.00% <100.00%> (ø)
lib/src/string/conversion.ts 100.00% <100.00%> (ø)
lib/src/string/is_null_or.ts 100.00% <100.00%> (ø)
lib/src/string/replace.ts 100.00% <100.00%> (ø)
lib/src/string/replace_all.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

This PR adds new string replacement helpers (strReplace, strReplaceAll) to @nevware21/ts-utils, wires replaceAll into the polyfill installer, and refactors existing internal call sites to route through the new helper(s), with added tests and minor supporting updates.

Changes:

  • Add strReplace wrapper and strReplaceAll with polyStrReplaceAll fallback; register replaceAll in polyfills.ts.
  • Refactor several helpers/polyfills to use strReplace instead of direct .replace(...).
  • Add/expand test coverage for replace/replaceAll, adjust polyArrWith invalid-input behavior, and update bundle-size budget/doc.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/src/string/replace.ts Adds strReplace wrapper around String.prototype.replace.
lib/src/string/replace_all.ts Adds strReplaceAll with polyStrReplaceAll implementation.
lib/src/polyfills.ts Registers replaceAll for runtime polyfill installation; exports polyStrReplaceAll.
lib/src/index.ts Exposes strReplace / strReplaceAll from the main entrypoint.
lib/src/string/is_null_or.ts Refactors whitespace stripping to use strReplace.
lib/src/string/conversion.ts Refactors case conversion replacements to use strReplace.
lib/src/helpers/regexp.ts Refactors wildcard/glob regex building to use strReplace.
lib/src/helpers/encode.ts Refactors encoding-related replacements to use strReplace.
lib/src/polyfills/trim.ts Refactors trim polyfill internals to use strReplace.
lib/src/array/with.ts Uses throwRangeError for invalid-array path in polyArrWith.
lib/test/src/common/string/replace.test.ts Adds tests for strReplace parity with native replace.
lib/test/src/common/string/replace_all.test.ts Adds tests for strReplaceAll + polyStrReplaceAll parity with native replaceAll.
lib/test/src/common/array/with.test.ts Tightens null/undefined typing in tests; adds invalid-input RangeError assertions for polyArrWith.
lib/test/bundle-size-check.js Increases bundle size limit (comment needs update).
README.md Documents strReplace / strReplaceAll in the function list and usage snippet.

nevware21-bot
nevware21-bot previously approved these changes Mar 18, 2026
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

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 new string replacement helpers to @nevware21/ts-utils (a strReplace wrapper and strReplaceAll with polyfill fallback), then refactors internal callers to route through the wrapper for consistency and cross-environment behavior. The PR also expands test coverage and updates polyfill wiring/docs and bundle size thresholds.

Changes:

  • Introduce strReplace and strReplaceAll (+ polyStrReplaceAll) and wire replaceAll into polyfills.ts.
  • Refactor multiple existing .replace(...) call sites to use strReplace(...).
  • Add/expand tests for replace/replaceAll and additional trim falsy-value cases; align polyArrWith invalid-array error path to throwRangeError.

Reviewed changes

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

Show a summary per file
File Description
lib/test/src/common/string/trim.test.ts Adds trim coverage for non-nullish falsy values; adjusts a trimEnd test list entry.
lib/test/src/common/string/replace_all.test.ts New tests for strReplaceAll / polyStrReplaceAll, including native-parity checks.
lib/test/src/common/string/replace.test.ts New tests for strReplace with basic/native-parity coverage.
lib/test/src/common/array/with.test.ts Strengthens null/undefined typing in tests and adds RangeError assertions for invalid array-like in polyArrWith.
lib/test/bundle-size-check.js Updates es5 min bundle threshold.
lib/src/string/replace_all.ts Implements strReplaceAll and polyStrReplaceAll (regex/global handling, escaping, @@replace delegation).
lib/src/string/replace.ts Adds strReplace wrapper around String.prototype.replace.
lib/src/string/is_null_or.ts Refactors whitespace check to use strReplace.
lib/src/string/conversion.ts Refactors case conversion helpers to use strReplace.
lib/src/polyfills/trim.ts Ensures trim polyfills coerce via asString and use strReplace consistently.
lib/src/polyfills.ts Registers replaceAll polyfill and exports polyStrReplaceAll.
lib/src/index.ts Exposes strReplace and strReplaceAll from the main entrypoint.
lib/src/helpers/regexp.ts Refactors wildcard/filename/glob regex builders to use strReplace.
lib/src/helpers/encode.ts Refactors encoding helpers to use strReplace (including chained replacements).
lib/src/array/with.ts Uses throwRangeError for invalid-array path in polyArrWith.
docs/feature-backlog.md Adds a request-tracking/backlog document.
README.md Adds strReplace / strReplaceAll to the utility matrix and usage example.
.size-limit.json Updates ES6 bundle size limit threshold.

nevware21-bot
nevware21-bot previously approved these changes Mar 18, 2026
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

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

This PR adds new string replacement helpers (strReplace, strReplaceAll w/ polyfill), refactors existing replacement call sites to consistently use the new helper, and expands test coverage (including fixing polyTrim behavior for non-nullish falsy values).

Changes:

  • Add strReplace and strReplaceAll (with polyStrReplaceAll) and wire replaceAll into polyfills.ts.
  • Refactor multiple string/encoding/regexp helpers and the trim polyfill to use strReplace.
  • Expand tests for trim falsy handling, add replace/replaceAll parity tests, and adjust bundle size limits.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/src/string/replace.ts Introduces strReplace wrapper for String.prototype.replace.
lib/src/string/replace_all.ts Adds strReplaceAll wrapper and polyStrReplaceAll implementation.
lib/src/polyfills.ts Registers replaceAll polyfill injection and exports polyStrReplaceAll.
lib/src/index.ts Exports strReplace and strReplaceAll from the public entrypoint.
lib/src/polyfills/trim.ts Fixes falsy non-nullish trimming by coercing via asString() and using strReplace.
lib/src/helpers/encode.ts Refactors internal string replacements to use strReplace.
lib/src/helpers/regexp.ts Refactors wildcard/filename/glob regex generation to use strReplace.
lib/src/string/conversion.ts Refactors case conversion helpers to use strReplace.
lib/src/string/is_null_or.ts Refactors whitespace stripping to use strReplace.
lib/src/array/with.ts Uses throwRangeError() for invalid inputs and bounds errors.
lib/test/src/common/string/trim.test.ts Adds coverage for non-nullish falsy values and fixes a trimEnd test call.
lib/test/src/common/string/replace.test.ts Adds parity-oriented tests for strReplace.
lib/test/src/common/string/replace_all.test.ts Adds comprehensive strReplaceAll / polyStrReplaceAll tests and native parity checks.
lib/test/src/common/array/with.test.ts Tightens typings for nullish tests and adds RangeError expectations for polyArrWith.
lib/test/bundle-size-check.js Updates ES5 min bundle threshold.
.size-limit.json Updates ES6 gzip bundle threshold.
README.md Documents strReplace / strReplaceAll in the utility list and usage examples.
docs/feature-backlog.md Adds backlog tracking doc mentioning strReplaceAll as a suggested addition.

nevware21-bot
nevware21-bot previously approved these changes Mar 18, 2026
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

…cements, and expand coverage

- add new native string helper strReplace
- add strReplaceAll with polyfill fallback (polyStrReplaceAll) and wire it into polyfills.ts
- refactor existing string replacement call sites to use strReplace in:
  - encoding helpers
  - regexp helpers
  - string conversion helpers
  - string null/whitespace checks
  - trim polyfill
  - replace_all implementation
- align polyArrWith invalid-array path to use throwRangeError

bug(polyTrim): This causes incorrect behavior for non-null/undefined falsy values (e.g. 0/false)
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

This PR extends @nevware21/ts-utils string utilities by introducing minification-friendly wrappers for string replacement operations (including an ES2021 replaceAll polyfill path), refactors internal call sites to use the new helper(s), and expands test coverage around trimming/replacement behavior.

Changes:

  • Add strReplace (native wrapper) and strReplaceAll (native wrapper + polyStrReplaceAll fallback) and wire replaceAll into polyfills.ts.
  • Refactor multiple helpers/polyfills to use strReplace, and fix polyTrim behavior for non-nullish falsy values.
  • Expand tests and update size-limit thresholds/docs to account for the new surface area.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/src/string/replace.ts Adds strReplace wrapper around String.prototype.replace.
lib/src/string/replace_all.ts Adds strReplaceAll + polyStrReplaceAll implementation and symbol-based delegation behavior.
lib/src/polyfills.ts Installs replaceAll polyfill onto String.prototype when missing; exports polyStrReplaceAll.
lib/src/index.ts Exposes strReplace and strReplaceAll at the package entrypoint.
lib/src/polyfills/trim.ts Fixes poly trim to correctly handle non-nullish falsy values by coercing via asString.
lib/src/string/is_null_or.ts Uses strReplace for whitespace stripping.
lib/src/string/conversion.ts Uses strReplace for case conversion regex replacements.
lib/src/helpers/regexp.ts Uses strReplace for regexp-building escaping/rewrites.
lib/src/helpers/encode.ts Uses strReplace for encoding-related replacement chains.
lib/src/array/with.ts Uses throwRangeError for consistent RangeError throwing in polyArrWith.
lib/test/src/common/string/trim.test.ts Adds coverage for trim/polyTrim with falsy non-nullish values; fixes a mis-called helper in the trimEnd block.
lib/test/src/common/string/replace.test.ts Adds tests for strReplace including native parity.
lib/test/src/common/string/replace_all.test.ts Adds tests for strReplaceAll/polyStrReplaceAll including native parity and symbol delegation.
lib/test/src/common/array/with.test.ts Adds/adjusts tests around invalid inputs and error types for polyArrWith.
lib/test/bundle-size-check.js Updates bundle-size thresholds for ES5 bundles.
.size-limit.json Updates size-limit threshold for es6-zip.
README.md Adds strReplace/strReplaceAll to the utility matrix and usage snippet for strReplaceAll.
docs/feature-backlog.md Adds a feature backlog doc capturing suggested future additions and rationale.

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 b8fed19 into main Mar 18, 2026
14 checks passed
@nev21 nev21 deleted the nev21/replace branch March 18, 2026 17:32
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