@mocanvas/store · function

iterateGraphemes

declare function iterateGraphemes(str: string): Generator<string, void, undefined>

Iterate the grapheme clusters of str.

Uses Intl.Segmenter where it exists and falls back to code-point iteration otherwise — which keeps surrogate pairs intact (so a plain emoji survives) but cannot join a ZWJ sequence or a combining mark to its base.

``ts [...iterateGraphemes("a👍🏽b")] // ["a", "👍🏽", "b"] ``

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.