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

Use Intl.Segmenter when available? #14

Closed
sindresorhus opened this issue Jan 11, 2021 · 4 comments · Fixed by #17
Closed

Use Intl.Segmenter when available? #14

sindresorhus opened this issue Jan 11, 2021 · 4 comments · Fixed by #17

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented Jan 11, 2021

Investigate using https://github.com/tc39/proposal-intl-segmenter when/if it becomes available.

new Intl.Segmenter('en', {granularity: 'grapheme'});
@Richienb
Copy link
Contributor

By using a ponyfill as a fallback when Intl.Segmenter is not available, it is possible to split a string by each character: https://github.com/Richienb/split-chars

@sindresorhus
Copy link
Owner Author

I don't want to bring in a polyfill and all the potential problems and bloat that comes with that. The current code works ok, so we can just wait until it becomes available in Node.js.

@Richienb
Copy link
Contributor

Richienb commented Jan 31, 2021

Ok. Looks like Intl.Segmenter will be available in Node.js 16.

@Mini-ghost
Copy link

Should we mention in the Readme that FireFox does not currently support Intl.Segmenter? After all, this API is being used in the source code.

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 a pull request may close this issue.

3 participants