Skip to content

refactor: update string/truncate to dispatch to base packages based on mode - #13865

Draft
ujjwalv01 wants to merge 11 commits into
stdlib-js:developfrom
ujjwalv01:feat-string-truncate
Draft

refactor: update string/truncate to dispatch to base packages based on mode#13865
ujjwalv01 wants to merge 11 commits into
stdlib-js:developfrom
ujjwalv01:feat-string-truncate

Conversation

@ujjwalv01

Copy link
Copy Markdown
Contributor

Progresses #1062

Description

What is the purpose of this pull request?

This pull request:

  • Refactors @stdlib/string/truncate to act as a mode-based dispatcher, aligning with the standard stdlib string API structure.
  • Adds an options.mode parameter supporting grapheme (default), code_point, and code_unit string truncation types.
  • Delegates execution to the respective base packages (base/truncate, base/truncate-code-point, and base/truncate-grapheme-cluster).

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Note: This is a Draft PR because it relies on the pending merge of three prerequisite base packages:

  1. string/base/truncate-grapheme-cluster
  2. string/base/truncate-code-point
  3. string/base/truncate

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

I utilized an AI coding assistant to scaffold the options.mode dispatching boilerplate and to expand the test/types coverage across the three new base modes.


@stdlib-js/reviewers

@stdlib-bot

stdlib-bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
string/base/truncate-code-point $\\color{red}139/142$
$\\color{green}+0.00\\%$
$\\color{red}12/13$
$\\color{green}+0.00\\%$
$\\color{green}1/1$
$\\color{green}+0.00\\%$
$\\color{red}139/142$
$\\color{green}+0.00\\%$
string/base/truncate-grapheme-cluster $\\color{green}133/133$
$\\color{green}+0.00\\%$
$\\color{green}9/9$
$\\color{green}+0.00\\%$
$\\color{green}1/1$
$\\color{green}+0.00\\%$
$\\color{green}133/133$
$\\color{green}+0.00\\%$
string/base/truncate $\\color{green}119/119$
$\\color{green}+0.00\\%$
$\\color{green}7/7$
$\\color{green}+0.00\\%$
$\\color{green}1/1$
$\\color{green}+0.00\\%$
$\\color{green}119/119$
$\\color{green}+0.00\\%$
string/truncate $\\color{red}184/186$
$\\color{green}+0.00\\%$
$\\color{red}19/20$
$\\color{green}+0.00\\%$
$\\color{green}1/1$
$\\color{green}+0.00\\%$
$\\color{red}184/186$
$\\color{green}+0.00\\%$

The above coverage report was generated for the changes in this PR.

@ujjwalv01
ujjwalv01 force-pushed the feat-string-truncate branch from dab57ed to 34b50eb Compare August 2, 2026 18:49
@ujjwalv01

Copy link
Copy Markdown
Contributor Author

This is a Draft PR for the top-level string/truncate refactor. Because this package acts as a dispatcher for the base utilities, I have temporarily merged the following three branches into this one for local testing and CI verification purposes:

  • feat-string-base-truncate-grapheme-cluster
  • feat-string-base-truncate-code-point
  • feat-string-base-truncate

Once those three upstream PRs are reviewed and merged into develop, I will rebase this branch to clean up the commit history so that only the changes for the top-level @stdlib/string/truncate package remain.

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.

2 participants