aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gleam_stdlib.mjs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs
index a908b23..45c28cf 100644
--- a/src/gleam_stdlib.mjs
+++ b/src/gleam_stdlib.mjs
@@ -147,9 +147,12 @@ export function string_length(string) {
}
export function graphemes(string) {
- return List.fromArray(
- Array.from(graphemes_iterator(string)).map((item) => item.segment)
- );
+ const iterator = graphemes_iterator(string);
+ if (iterator) {
+ return List.fromArray(Array.from(iterator).map((item) => item.segment));
+ } else {
+ return List.fromArray(string.match(/./gsu));
+ }
}
function graphemes_iterator(string) {