From 38aaa2aa6aba8dcaffea28192567c983a5a10853 Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:29:38 -0300 Subject: fix matching split returning list with Nil on JS --- src/gleam_stdlib.mjs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gleam_stdlib.mjs') diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs index 40fcc3f..d921c63 100644 --- a/src/gleam_stdlib.mjs +++ b/src/gleam_stdlib.mjs @@ -402,6 +402,10 @@ export function compile_regex(pattern, options) { } } +export function regex_split(regex, string) { + return List.fromArray(string.split(regex).map(item => item === undefined ? "" : item)); +} + export function regex_scan(regex, string) { const matches = Array.from(string.matchAll(regex)).map((match) => { const content = match[0]; -- cgit v1.2.3