Skip to content
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

Replace Graphemer by Intl.Segmenter() #1175

Open
tiagofilipenunes opened this issue Apr 17, 2024 · 0 comments
Open

Replace Graphemer by Intl.Segmenter() #1175

tiagofilipenunes opened this issue Apr 17, 2024 · 0 comments

Comments

@tiagofilipenunes
Copy link
Collaborator

tiagofilipenunes commented Apr 17, 2024

Graphemer is used in the app to perform non-trivial split of strings, for strings such as >1-char emojis used in ENS addresses.

Intl.Segmenter is now widely supported since Firefox 125 (16th April) has included it. Graphemer can be easily replaced by Intl.Segmenter.

Before:

  const splitter = new Graphemer();
  const stringArray = splitter.splitGraphemes(stringToShorten);

After:

  const segmenter = new Intl.Segmenter();

  const stringArray = [...segmenter.segment(stringToShorten)].map(
    (segmentData) => segmentData.segment
  );
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

No branches or pull requests

1 participant