feat(string): add strReplace + strReplaceAll, refactor internal replacements, and expand coverage#527
feat(string): add strReplace + strReplaceAll, refactor internal replacements, and expand coverage#527
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
strReplacewrapper andstrReplaceAllwithpolyStrReplaceAllfallback; registerreplaceAllinpolyfills.ts. - Refactor several helpers/polyfills to use
strReplaceinstead of direct.replace(...). - Add/expand test coverage for
replace/replaceAll, adjustpolyArrWithinvalid-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
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
There was a problem hiding this comment.
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
strReplaceandstrReplaceAll(+polyStrReplaceAll) and wirereplaceAllintopolyfills.ts. - Refactor multiple existing
.replace(...)call sites to usestrReplace(...). - Add/expand tests for replace/replaceAll and additional trim falsy-value cases; align
polyArrWithinvalid-array error path tothrowRangeError.
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
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
There was a problem hiding this comment.
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
strReplaceandstrReplaceAll(withpolyStrReplaceAll) and wirereplaceAllintopolyfills.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
left a comment
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) andstrReplaceAll(native wrapper +polyStrReplaceAllfallback) and wirereplaceAllintopolyfills.ts. - Refactor multiple helpers/polyfills to use
strReplace, and fixpolyTrimbehavior 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. |
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
bug(polyTrim): This causes incorrect behavior for non-null/undefined falsey values (e.g. 0/false)