-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(string): add strReplace + strReplaceAll, refactor internal replacements, and expand coverage #527
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
Merged
Merged
feat(string): add strReplace + strReplaceAll, refactor internal replacements, and expand coverage #527
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Feature Backlog and Request Tracking | ||
|
|
||
| This document tracks suggested additions for `@nevware21/ts-utils`. | ||
|
|
||
| ## Request RQ-2026-03-17-ADDITIONS | ||
|
|
||
| - Request: Identify what additions could be added to ts-utils | ||
| - Requested by: Maintainer discussion | ||
| - Priority: High | ||
| - Scope: Array, object, string, iterator, typing, and documentation improvements | ||
|
|
||
| ### Objective | ||
|
|
||
| Identify practical, minification-friendly, cross-environment additions that fit the library design principles: | ||
|
|
||
| - zero dependencies | ||
| - ES5 compatibility for v0.x / v1.x | ||
| - polyfill-backed behavior where needed | ||
| - strong tree-shaking and small bundles | ||
|
|
||
| ## Suggested Additions (Proposed Only) | ||
|
|
||
| ### Language-Native Suggestions (with ECMAScript Version) | ||
|
|
||
| The following suggestions map directly to JavaScript language / standard library features: | ||
|
|
||
| - `strReplaceAll` wrapper/polyfill path | ||
| - JavaScript feature: `String.prototype.replaceAll()` | ||
| - Added in: **ECMAScript 2021 (ES12)** | ||
|
|
||
| | Suggestion | JavaScript Feature | ECMAScript Version | | ||
| | --- | --- | --- | | ||
| | `strReplaceAll` wrapper/polyfill path | `String.prototype.replaceAll()` | ECMAScript 2021 (ES12) | | ||
|
|
||
| Notes: | ||
|
|
||
| - Other suggestions below are library-level utilities (not direct language features). | ||
| - Iterator helpers are intentionally listed as utility suggestions here rather than standard-language mappings. | ||
|
|
||
| ### A. Typing Improvements (High Value) | ||
|
|
||
| - `ReadonlyRecord<K, V>` helper type alias for API ergonomics | ||
| - `DeepPartial<T>` utility type | ||
| - `DeepReadonly<T>` utility type | ||
| - `Mutable<T>` utility type for controlled writable transformations | ||
|
|
||
| ### B. Object Utilities (Medium Value) | ||
|
|
||
| - `objPick` / `objOmit` | ||
| - `objMapValues` | ||
| - `objMergeIf` | ||
| - `objDiff` | ||
|
|
||
| Notes: | ||
|
|
||
| - maintain plain-object safety patterns | ||
| - avoid behavior changes to existing deep copy helpers | ||
|
|
||
| ### C. String Utilities (Medium Value) | ||
|
|
||
| - `strTruncate` (with optional suffix) | ||
| - `strCount` (substring occurrences) | ||
| - `strReplaceAll` wrapper/polyfill path **(ECMAScript 2021 / ES12 language feature wrapper)** | ||
| - `strCapitalizeWords` | ||
|
|
||
| ### D. Iterator and Collection Helpers (Medium Value) | ||
|
|
||
| - `iterMap`, `iterFilter`, `iterTake` | ||
| - `arrToMap` helpers with stable key selection | ||
| - lightweight set operations for iterables | ||
|
|
||
| ### E. Reliability and Tooling (High Value) | ||
|
|
||
| - keep bundle-size thresholds justified with measured report | ||
| - require test parity for polyfill vs native behavior | ||
| - ensure newly exported functions are reflected in README utility matrix | ||
|
|
||
| ## Acceptance Criteria for this Request | ||
|
|
||
| - [x] Identify additions by category | ||
| - [x] Prioritize additions by value and fit | ||
| - [ ] Create follow-up issue list for proposed items | ||
| - [ ] Add ownership and target milestone per item | ||
|
|
||
| ## Next Actions | ||
|
|
||
| 1. Open GitHub issues for sections A-D candidates. | ||
| 2. Add milestone tags for upcoming releases. | ||
| 3. Keep this document focused on proposed additions only. |
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * @nevware21/ts-utils | ||
| * https://github.com/nevware21/ts-utils | ||
| * | ||
| * Copyright (c) 2026 NevWare21 Solutions LLC | ||
| * Licensed under the MIT license. | ||
| */ | ||
|
|
||
| import { StrProto } from "../internal/constants"; | ||
| import { _unwrapFunction } from "../internal/unwrapFunction"; | ||
|
|
||
| /** | ||
| * The strReplace() method returns a new string with one, some, or all matches of a pattern replaced | ||
| * by a replacement. | ||
| * @function | ||
| * @since 0.14.0 | ||
| * @group String | ||
| * @param value - The string value to search and replace within. | ||
| * @param searchValue - The value to search for. Can be a string or regular expression. | ||
| * @param replaceValue - The replacement string or replacer function. | ||
| * @returns A new string with one, some, or all matches replaced. | ||
| * @example | ||
| * ```ts | ||
| * strReplace("a-b-a", "a", "x"); // "x-b-a" | ||
| * strReplace("a1b2", /\d/g, "#"); // "a#b#" | ||
| * strReplace("hello", /[aeiou]/, "*"); // "h*llo" | ||
| * ``` | ||
| */ | ||
| export const strReplace: (value: string, searchValue: string | RegExp, replaceValue: string | ((substring: string, ...args: any[]) => string)) => string = (/*#__PURE__*/_unwrapFunction("replace", StrProto as any)); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.