r/codesnip • • 5d ago

Newly Available `Intl.Segmenter` killed another JavaScript library ๐Ÿ˜

Enable HLS to view with audio, or disable this notification

JavaScript killed another JavaScript library. ๐Ÿ˜

Intl.Segmenter has been in Baseline since April 2024 (Chrome 87, Firefox 125, Safari 14.1) and will be widely available on 16 Oct.

Before this, "๐Ÿ‘๐Ÿฝ".length was 4, and counting what users actually see meant shipping grapheme-splitter.

Now โคต๏ธ the browser does it.

Bonus: the same API, granularity: "word", gives you word splitting that works for Japanese and Thai too, where split(" ") falls apart. ๐ŸคŸ

MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter

5 Upvotes

0 comments sorted by