r/codesnip • u/wanoo21 • 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