aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gleam_stdlib.mjs')
-rw-r--r--src/gleam_stdlib.mjs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs
index b4f3d22..35c31c4 100644
--- a/src/gleam_stdlib.mjs
+++ b/src/gleam_stdlib.mjs
@@ -93,6 +93,12 @@ export function string_length(string) {
}
}
+export function graphemes(string) {
+ return List.fromArray(
+ Array.from(graphemes_iterator(string)).map(((item) => item.segment ))
+ );
+}
+
function graphemes_iterator(string) {
if (Intl && Intl.Segmenter) {
return new Intl.Segmenter().segment(string)[Symbol.iterator]();