Skip to content

feat: add string/base/truncate-grapheme-cluster - #13861

Open
ujjwalv01 wants to merge 4 commits into
stdlib-js:developfrom
ujjwalv01:feat-string-base-truncate-grapheme-cluster
Open

feat: add string/base/truncate-grapheme-cluster#13861
ujjwalv01 wants to merge 4 commits into
stdlib-js:developfrom
ujjwalv01:feat-string-base-truncate-grapheme-cluster

Conversation

@ujjwalv01

Copy link
Copy Markdown
Contributor

Progresses #1062

Description

What is the purpose of this pull request?

This pull request:

  • Adds @stdlib/string/base/truncate-grapheme-cluster, a new base package that truncates strings to a specified length in grapheme clusters.
  • Provides a foundational utility necessary for refactoring the top-level @stdlib/string/truncate package to support grapheme clusters.

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.

This is the first of several PRs to address the string/truncate refactor. The implementation utilizes @stdlib/string/num-grapheme-clusters and @stdlib/string/next-grapheme-cluster-break to chunk the string accurately by user-perceived visual characters without native input validation, matching standard base package paradigms.

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 help scaffold the test cases and benchmark boilerplate for this package. The implementation and tests were subsequently manually verified and adjusted by me locally.


@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-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\\%$

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

@ujjwalv01
ujjwalv01 marked this pull request as ready for review August 2, 2026 18:57
@ujjwalv01
ujjwalv01 requested a review from a team August 2, 2026 18:57
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants