Skip to content

feat: add @stdlib/string/base/truncate-middle-grapheme-clusters - #13781

Open
ujjwalv01 wants to merge 3 commits into
stdlib-js:developfrom
ujjwalv01:feat-base-truncate-middle-grapheme-clusters
Open

feat: add @stdlib/string/base/truncate-middle-grapheme-clusters#13781
ujjwalv01 wants to merge 3 commits into
stdlib-js:developfrom
ujjwalv01:feat-base-truncate-middle-grapheme-clusters

Conversation

@ujjwalv01

Copy link
Copy Markdown
Contributor

Resolves part of #1062

Description

What is the purpose of this pull request?

This pull request:

  • Adds the @stdlib/string/base/truncate-middle-grapheme-clusters package.
  • Implements a base utility function that truncates a string in the middle to a specified length based on grapheme clusters.
  • Ensures that complex visual characters spanning multiple Unicode code points (such as emojis with modifiers) are not split when truncating strings.
  • Serves as the default dispatching target for the top-level @stdlib/string/truncate-middle package.

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.

No.

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 assistant to automate the generation of test cases and benchmark scaffolding. The core logic implementation and integration were authored manually.


@stdlib-js/reviewers

@ujjwalv01
ujjwalv01 requested a review from a team July 30, 2026 13:30
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jul 30, 2026
@stdlib-bot

stdlib-bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
string/base/truncate-middle-grapheme-clusters $\\color{green}155/155$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}155/155$
$\\color{green}+100.00\\%$

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

@ujjwalv01

Copy link
Copy Markdown
Contributor Author

Closing this PR in favor of #13782 , which consolidates all three packages (truncate-middle-code-points, truncate-middle-grapheme-clusters, and the top-level truncate-middle refactor) into a single PR for easier review. All changes from this PR are included there.

@ujjwalv01 ujjwalv01 closed this Jul 30, 2026
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jul 30, 2026
@kgryte

kgryte commented Jul 31, 2026

Copy link
Copy Markdown
Member

Reopening, as our preference is that PRs adding new packages only contain a single package.

@kgryte kgryte reopened this Jul 31, 2026
@ujjwalv01

Copy link
Copy Markdown
Contributor Author

Thanks for reopening! These are up-to-date and ready for review.

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